cdt
A neo-tree style terminal UI for picking a directory to cd into — browse the
tree, search it with ripgrep, press Enter, and your shell is there.
Install
The crate is cdtui because cdt was taken on crates.io. Both commands are
installed, so cdt works whether or not you remember the abbreviation.
Needs the rg binary on PATH for full-text search (s); browsing and
file-name search work without it.
Shell setup
A process cannot change its parent's directory, so cdt draws its UI on stderr
and prints only the chosen path to stdout. A one-line shell wrapper does the
cd, and cdt --init prints it, detecting your shell from the parent process:
bash / zsh — add to ~/.bashrc or ~/.zshrc:
PowerShell — add to $PROFILE:
cdt --init | Out-String | Invoke-Expression
Command Prompt has no shell functions, so it needs a file on PATH instead:
cdt --init > "%USERPROFILE%\bin\cdt.cmd"
Put that directory on PATH before %USERPROFILE%\.cargo\bin. Within a
single directory cmd prefers .EXE over .CMD, so next to cdt.exe the
wrapper would never run; where cdt should list cdt.cmd first. Inside your
own .bat, write call cdt — cmd ends a script when it runs another one.
Pass a shell name to override the detection: cdt --init powershell.
Until a wrapper is in place cdt prints the path and says so on stderr, with
the line to add for the shell you are in, rather than appearing to do nothing.
Quitting with q prints nothing and leaves the directory alone.
Usage
| key | |
|---|---|
j / k |
move |
l / Space / Tab |
expand / collapse a directory |
h |
collapse, then step out to the parent, then re-root one level up |
g / G |
first / last |
/ |
search names — files and folders (honours .gitignore) |
s |
full-text search of file contents with ripgrep |
. |
toggle hidden files |
Enter |
cd there and exit (a file resolves to its directory) |
q / Esc |
exit without changing directory |
While / or s is open every letter types into the query, so q and .
search rather than act:
| key | |
|---|---|
↑ / ↓ / Tab |
move through the hits |
Backspace |
edit the query |
Enter |
cd to the selected hit and exit |
Esc |
back to the tree |
/ does not need ripgrep installed: it uses ripgrep's own walker (the ignore
crate) as a library. s shells out to rg. Both run on a worker thread, so
typing stays responsive on a large tree and the status bar shows searching…
until the hits land. A count shown as 500+ means the list was capped.
Libraries
The parts are published separately and usable on their own:
cdt-tree (tree model),
cdt-search (name and content search),
cdt-view (the ratatui picker).
Contributing
Workspace layout, dev commands, CI and the release procedure: .github/CONTRIBUTING.md.
License
MIT