jacobaustin123 / fancy-cd

A fancy version of the default Bash cd command that allows you to jump to previously visited directories

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

fancy-cd

fancy-cd is a fancy version of the default Bash cd command that allows you to jump to previously visited directories. Specifically, it caches previously visited directories, ranked by frequency of use, and if a directory is not found in the current directory when using the cd command, you can instead jump to a previously visited directory with the same name.

Installation

Run the following commands to install this utility. You can also use the install.sh script. This will override the default cd command with this script. You can uninstall by removing the added lines from your .bash_profile.

git clone https://github.com/jacobaustin123/fancy-cd.git ~/Documents/fancy-cd/
cat >> ~/.bash_profile <<'EOF'
fancycd() {
    cd "$(python ~/Documents/fancy-cd/fancycd.py "$*")"
}
EOF
echo 'alias cd="fancycd"' >> ~/.bash_profile
bash

Examples

Simple caching of past directories

username@:~$ cd Documents
username@:~/Documents$ cd ..
username@:~$ cd Desktop
username@:~/Desktop$ cd Documents
username@:~/Documents$

No need to escape directories with spaces

username@~$ cd dir1/dir2/Fun Stuff/December 2019
username@~/dir1/dir2/Fun Stuff/December 2019$ ls

Conflicts are resolved by frequency of access

username@:~$ cd Documents
username@:~/Documents$ cd ..
username@:~$ cd Documents
username@:~/Documents$ cd ..
username@:~$ cd Desktop/Documents
username@:~/Desktop/Documents$ cd ~/Downloads
username@:~$ cd Documents
username@:~/Documents$ cd ..

Issues

Since this script uses Python, some conflicts can arise with inconveniently named files in the current directory. These can include things like io.py. If issues are encountered, just escape the alias using \cd [dirname].

About

A fancy version of the default Bash cd command that allows you to jump to previously visited directories

License:Other


Languages

Language:Python 95.5%Language:Shell 4.5%