How 2 Know
If you can't Google it, You Can Knowing it.

how to ease navigation with CDPATH

$CDPATH=:..:~:~/projects

Set CDPATH to ease navigation

CDPATH tells the cd command to look in this colon-separated list of directories for your destination. My preferred order are

1) the current directory, specified by the empty string between the = and the first colon,

2) the parent directory (so that I can cd lib instead of cd ../lib),

3) my home directory, and 4) my ~/projects directory.

 

for example, if there is a directory under my home directory called “test” and my current location is “/tmp” and there is  directory under ” /tmp” called “test”, if i write “$ cd test” i will navigate to “my home directory/test”

see the following codes :

$ pwd
/home/unix/test
$ cat .profile
PATH=/usr/bin:/etc:/usr/sbin:/usr/ucb:$HOME/bin:/usr/bin/X11:/sbin:.
export PATH
if [ -s "$MAIL" ]           # This is at Shell startup.  In normal
then echo "$MAILMSG"        # operation, the Shell checks
fi                          # periodically.
CDPATH=:..:~
export CDPATH

$ ls -ltr
total 0
$ mkdir test
$ ls -ltr
total 0
drwxr-xr-x    2 test     staff           256 Oct 07 14:25 test
$ cd /tmp
$ ls -ld test
-rw-r--r--    1 ahmed    unix              0 Jan 20 2013  test
$ cd test
/home/unix/test/test

reference:
http://www.commandlinefu.com/commands/view/1560/set-cdpath-to-ease-navigation

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from How 2 Know

Subscribe now to keep reading and get access to the full archive.

Continue reading