cdx
cdx (Accelerated cd) is a modern, simple and interactive cd command alternative for CLI lovers, written in Rust. It provides a fast and light TUI to incrementally search and navigate directories with ease.
Features
- Interactive TUI: Navigate through directories with an intuitive terminal interface.
- Non-Interactive Mode: Supports standard
cd-like usage with arguments for a seamless transition. - Incremental Search: Quickly filter directories with minimal typing.
- Case-Insensitive Search: Search without distinguishing between uppercase and lowercase letters.
- Keyboard-Driven: Use standard navigation keys for fast and seamless movement.
- Cross-Platform: Built with
crossterm, ensuring smooth execution on various platforms.
Installation
Ensure you have Rust and Cargo installed. Then, install cdx via crates.io:
From GitHub repository:
From local source:
Uninstallation
To remove cdx, run:
Shell Integration
Because cdx runs as a child process, it cannot directly change the working directory of your current shell. Instead, it prints the selected directory's absolute path to the standard output.
To make it work as a seamless cd replacement, add the initialization command to your shell configuration file.
Note: Ensure that the cargo installation directory (typically
~/.cargo/bin) is included in your system's$PATH. Otherwise, the shell will not be able to find thecdxbinary.
bash
Add the following to your ~/.bashrc:
zsh
Add the following to your ~/.zshrc:
fish
Add the following to your ~/.config/fish/config.fish:
cdx init fish | source
If you prefer to define the wrapper function manually without eval:
bash / zsh:
fish:
function cdx
if test (count $argv) -gt 0 -a "$argv[1]" = "init"
command cdx $argv
return
end
set dest (command cdx $argv)
if test -n "$dest" -a -d "$dest"
builtin cd "$dest"
end
end
Usage
You can use cdx in two ways (very simple!!):
- Interactive Mode: Simply type
cdxwithout arguments to open the simple TUI. - Direct Mode: Type
cdx <directory>to get the absolute path of the target directory. (Useful for scripting or quick resolution).
Keybindings (TUI Mode)
| Key | Action |
|---|---|
Up / Down |
Move selection up or down. |
Tab |
Enter the selected directory (or go up if .. is selected). |
Enter |
Confirm and change to the selected directory (or parent/current directory if .. / . is selected). |
Backspace |
Delete the last typed character in the search. If search is empty, go up to the parent directory. |
Esc / Ctrl-C |
Cancel and exit without changing the directory. |
TOML Configuration
You can create config.toml in ~/.config/cdx/ to configure cdx.
[]
= "<color>"
= "<color>"
= "<color>"
[]
= true|false
= true|false
<color>:- Named colors:
black|gray|white|red|green|yellow|blue|magenta|cyan
(Prefix withdarkfor darker shades, e.g.,dark red.dark whiteis an alias forgray.) - Hex RGB colors:
#RGBor#RRGGBB(e.g.,#f00,#ff0000)
- Named colors:
Tip: You can use
config.schema.jsonfor validation and autocompletion in editors supporting JSON Schema (e.g. Even Better TOML).
Planned Features
- Easy Home Directory Transition: Initial focus on home directory (
~) for seamless navigation to the home directory when runningcdxand pressing Enter, matching standardcdbehavior. - Colorize Entries List: Use distinct colors for directories, symbolic links, hidden entries, and other entry types to make the list easier to scan.
- Easy Installation: Distribute pre-compiled binaries via package managers like Homebrew.
- Hidden & Gitignore Support: Add toggles for hidden directories and respect
.gitignorerules. - Vim Keybindings: Support
h/j/k/lnavigation for power users. - Directory Bookmarks: Save and jump to your favorite directories instantly.
License
This project is licensed under the MIT License - see the LICENSE file for details.