cd - How can I save the path to a frequently used directory in UNIX? -
is there way save path used directory in unix, instead of having manually cd /path/to/directory can enter shortcut cd myfavoritepath ??
define favorite directories in cdpath environment variable. it's colon-separated list of search paths available cd command. should specify not directory want switch parent directory.
here brief info it: http://docstore.mik.ua/orelly/unix/upt/ch14_05.htm
for example have 3 directories work frequently:
/home/user/scripts/favorite/ /var/log/ /var/lib/
add ~/.bash_profile (or shell profile file use) next line:
export cdpath=.:/home/user/scripts:/var
in example below redefine cdpath in shell current session
[user@server lib]$ cdpath=.:/var:/home/user/scripts [user@server lib]$ cd log /var/log [user@server log]$ cd lib /var/lib [user@server lib]$ cd favorite /home/user/scripts/favorite
if want use tab while execute cd
can install bash-completion http://bash-completion.alioth.debian.org/ it's optional
also not forget cd -
command quick switching previous working dir
Comments
Post a Comment