[plug] bash: making cd persist after script has run
Anthony J. Breeds-Taurima
tony at cantech.net.au
Mon Feb 11 10:35:12 WST 2002
On Mon, 11 Feb 2002, Colin Muller wrote:
> I'd like to have a small bash script which I can use to do quick cd's
> to the directories I visit most frequently as I work. So, being a
> shell scripting naif, I wrote one like this:
>
> case $1
> in
> perl)
> cd /home/colin/info/tech/perl
> ;;
> xml)
> cd /home/colin/info/tech/xml-sgml
> ;;
> esac
If you script is that simpple then take the "#!" line from the top.
ie
~$ cat ~/bin/ccd
cd ~/src/$1
~$ alias CCD='. ~/bin/ccd'
~$ CCD perl
~/src/perl$ CCD c
~/src/c$ CCD java
~/src/java$
etc etc
The wreason this works is "." (or source for tcsh) runs in the current shell
ie no fork/exec
If you scripts get more compleicated you need to worry about polution leaking
back into your main shell.
Yours Tony.
/*
* "The significant problems we face cannot be solved at the
* same level of thinking we were at when we created them."
* --Albert Einstein
*/
More information about the plug
mailing list