You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+2-1Lines changed: 2 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
9
9
10
10
### Added
11
11
12
-
- Git integration to display file statuses with a new `-G, --git-status` flag.
12
+
-**Shell integration:** In interactive mode, pressing `Ctrl+s` now quits the application and prints the selected path to standard output, allowing `lstr` to be used as a file picker for other shell commands.
13
+
-**Git integration:** To display file statuses, use the new `-G, --git-status` flag.
13
14
- Shows status indicators for modified (`M`), new (`A`), untracked (`?`), and more.
14
15
- Available in both classic `view` and `interactive` modes.
15
16
- Added an optional `-s, --size` flag to display file sizes in both classic and interactive modes.
A blazingly fast, minimalist directory tree viewer, written in Rust. Inspired by the command line program [tree](https://github.com/Old-Man-Programmer/tree), with a powerful interactive mode.
8
8
9
9

10
-
*An interactive overview of **lstr**'s project structure... using **lstr**.*
10
+
*An interactive overview of `lstr`'s project structure... using `lstr`.*
11
11
## Philosophy
12
12
13
13
-**Fast:** Runs directory scans in parallel by default to maximize speed on modern hardware.
@@ -29,7 +29,7 @@ A blazingly fast, minimalist directory tree viewer, written in Rust. Inspired by
29
29
30
30
## Installation
31
31
32
-
You need the Rust toolchain installed on your system to build **lstr**.
32
+
You need the Rust toolchain installed on your system to build `lstr`.
33
33
34
34
1.**Clone the repository:**
35
35
```bash
@@ -62,7 +62,7 @@ Note that `PATH` defaults to the current directory (`.`) if not specified.
62
62
|`-L`, `--level <LEVEL>`| Maximum depth to descend. |
63
63
|`-p`, `--permissions`| Display file permissions (Unix-like systems only). |
64
64
|`-s`, `--size`| Display the size of files. |
65
-
|`--expand-level <LEVEL>`|**Interactive mode only:** Initial depth to expand the interactive tree. |
65
+
|`--expand-level <LEVEL>`|**Interactive mode only:** Initial depth to expand the interactive tree. |
66
66
67
67
-----
68
68
@@ -78,6 +78,8 @@ Launch the TUI with `lstr interactive [OPTIONS] [PATH]`.
78
78
|`↓` / `j`| Move selection down. |
79
79
|`Enter`|**Context-aware action:**\<br/\>- If on a file: Open it in the default editor (`$EDITOR`).\<br/\>- If on a directory: Toggle expand/collapse. |
80
80
|`q` / `Esc`| Quit the application normally. |
81
+
|`Ctrl`+`s`|**Shell integration:** Quits and prints the selected path to stdout. |
82
+
81
83
82
84
## Examples
83
85
@@ -111,21 +113,21 @@ lstr -aG
111
113
lstr interactive -gG --icons -s -p
112
114
```
113
115
114
-
## Piping and Shell Interaction
116
+
## Piping and shell interaction
115
117
116
118
The classic `view` mode is designed to work well with other command-line tools via pipes (`|`).
117
119
118
-
### Interactive Fuzzy Finding with **fzf**
120
+
### Interactive fuzzy finding with `fzf`
119
121
120
122
This is a powerful way to instantly find any file in a large project.
121
123
122
124
```bash
123
125
lstr -a -g --icons | fzf
124
126
```
125
127
126
-
**fzf** will take the tree from **lstr** and provide an interactive search prompt to filter it.
128
+
`fzf` will take the tree from `lstr` and provide an interactive search prompt to filter it.
127
129
128
-
### Paging Large Trees with less or bat
130
+
### Paging large trees with `less` or `bat`
129
131
130
132
If a directory is too large to fit on one screen, pipe the output to a *pager*.
131
133
@@ -137,9 +139,37 @@ lstr -L 10 | less -R
137
139
lstr --icons | bat
138
140
```
139
141
142
+
### Changing directories with `lstr`
143
+
144
+
You can use `lstr` as a visual `cd` command. Add the following functionto your shell's startup file (e.g., `~/.bashrc`, `~/.zshrc`):
145
+
146
+
```bash
147
+
# A function to visually change directories with lstr
148
+
lcd() {
149
+
# Run lstr and capture the selected path into a variable.
150
+
# The TUI will draw on stderr, and the final path will be on stdout.
151
+
local selected_dir
152
+
selected_dir="$(lstr interactive -g --icons)"
153
+
154
+
# If the user selected a path (and didn't just quit), `cd` into it.
155
+
# Check if the selection is a directory.
156
+
if [[ -n"$selected_dir"&&-d"$selected_dir" ]];then
157
+
cd"$selected_dir"
158
+
fi
159
+
}
160
+
```
161
+
162
+
After adding this and starting a new shell session (or running `source ~/.bashrc`), you can simply run:
163
+
164
+
```bash
165
+
lcd
166
+
```
167
+
168
+
This will launch the `lstr` interactive UI. Navigate to the directory you want, press `Ctrl+s`, and your shell's current directory will instantly change.
169
+
140
170
## Performance and concurrency
141
171
142
-
By default, **lstr** uses a parallel directory walker to maximize speed on multi-core systems. This parallelism is managed by the excellent [rayon](https://crates.io/crates/rayon) thread pool, which is used internally by **lstr**'s directory traversal engine.
172
+
By default, `lstr` uses a parallel directory walker to maximize speed on multi-core systems. This parallelism is managed by the excellent [rayon](https://crates.io/crates/rayon) thread pool, which is used internally by `lstr`'s directory traversal engine.
143
173
144
174
For advanced use cases, such as benchmarking or limiting CPU usage, you can control the number of threads by setting the `RAYON_NUM_THREADS` environment variable before running the command.
145
175
@@ -151,4 +181,4 @@ RAYON_NUM_THREADS=1 lstr .
151
181
152
182
## Inspiration
153
183
154
-
The philosophy and functionality of **lstr** are heavily inspired by the excellent C-based [tree](https://github.com/Old-Man-Programmer/tree) command line program. This project is an attempt to recreate that classic utility in modern, safe Rust.
184
+
The philosophy and functionality of `lstr` are heavily inspired by the excellent C-based [tree](https://github.com/Old-Man-Programmer/tree) command line program. This project is an attempt to recreate that classic utility in modern, safe Rust.
0 commit comments