[plug] bash: making cd persist after script has run

Brian Tombleson brian at paradigmit.com.au
Mon Feb 11 10:26:37 WST 2002


Err .. you could try it with aliases instead..

In your ~/.bash_profile (or other choice of login script)

alias cdperl="cd /home/colin/info/tech/perl"
alias cdxml="cd /home/colin/info/tech/xml-sgml"

Less to type, just have to rmember not to put the space in it.

YMMV, HTH.
- Brian.

----- Original Message ----- 
From: "Colin Muller" <colin at twobluedots.com.au>
To: <plug at plug.linux.org.au>
Sent: Monday, February 11, 2002 10:22 AM
Subject: [plug] bash: making cd persist after script has run


> 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
> 
> Then I placed this (named ccd) in my home directory, and typed:
> ~/ccd xml
> ~/ccd perl
> etc etc
> 
> But of course, the shell script returns me to the directory I invoked
> it from once it has run (it does cd to the wanted dir in between - I
> checked that by placing a pwd in the script above). Is there a way to
> make the 'cd' performed in the script persist after it's run?
> 
> Or is there some better way I could approach this?
> 
> I'm on bash 2.05
> 
> Colin
> 
> 



More information about the plug mailing list