Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select frequently used directories from a list 6

Status
Not open for further replies.

Ygor

Programmer
Feb 21, 2003
623
0
0
GB
A recent post has prompted me to share something with you all. To navigate to frequently-used directories, I have the following line in my .profile…

alias ycd='select ID in $(<$HOME/.ycd_list);do [ $ID ] && cd $ID;break;done'

… and I maintain a list of directories in $HOME/.ycd_list

Use it like this…
[tt]
$ ycd
1) /very/long/path/to/some/working/directory
2) /extremely/long/path/name
3) /etc/you/get/the/idea
#? 2 [/tt][gray] <<-- note: I keyed 2 here, use 0 or q to quit[/gray]
[tt] $ pwd
/extremely/long/path/name
[/tt]
Note that it only works with ksh-based shells which have a select function. Take a look and the manual pages for a proper description of select and the PS3 prompt.
 
Although it may not suitable for me(remember the path also be my job nature). But it is really a good reference to me about the alias using as one command line. A star is given to you.
 
Good post Ygor!! That is quite useful. I normally just have variables set up for my commonly used path names, but this is very simple as well.

Thanks,

John

[thumbsup]
 
Very cool! I like little tools like this!

Have another star!

 
I liked this idea too - so have a star
 
Just FYI, it also works in the bash shell.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top