.bash_cds - GiselleSerate/myaliases GitHub Wiki
.bash_cds
A function for more convenient directory navigation.
The cds
command can create and delete shortcuts to any directory on your file system, allowing you to jump to any directory you've bookmarked.
Unless your system is unsupported, all such commands can be tab completed.
Usage
cds + [shortcut name]
Creates a shortcut to the current working directory with the given shortcut name.
- uses the current directory name if
.
(a period) is supplied as the shortcut name - overrides any existing shortcuts with the same name
-
is an invalid shortcut name
cds [shortcut name]
Jumps to the directory corresponding to the given shortcut name (or directory name).
- gives precedence to folders in the current directory if they have the same name as one of your shortcuts
- permits appending a relative filepath to the shortcut name
cds .
Lists your current shortcuts.
cds - [shortcut name 1] [shortcut name 2] [...]
Deletes the shortcut(s) with the given name(s).
cd
Replace The cds
command is a wrapper around cd
, extending its interface without clobbering it. In other words, it acts exactly like cd
except when you use cds
-specific features. Note that the one exception to this statement is the behavior of cd .
(which is normally nothing).
The following code will replace cd
with cds
, so that calling cd
will actually call cds
. It can be placed at the end of your .bashrc
or .bash_aliases
file.
# alias cd to cds
if typeset -f cds > /dev/null; then
alias cd='cds'
fi
# provides cds tab completions for cd
# this only works for bash users
if typeset -f cds > /dev/null && [ -n "$BASH_VERSION" ]; then
complete -r cd
complete -o nospace -F _cds cd
fi
Note: If you choose to put this code within your .bash_aliases
file, you should make sure that your .bash_aliases
] file is sourced after bash's programmable completion features in your .bashrc
.