You are not logged in.
Pages: 1
Hello arch.
I have cd aliased to pushd in my .bashrc, and bd aliased to popd. Thishas been treating me well for a while now, but it's a pain that if I do cd ./docs/code/perl for example then if I bd, as opposed to cd .., then it takes me right back to my start and not to the directory above. (This practice may seem eccentric to you, but it works in my head so bear with me...)
So I decided to write a script to include in my alias so that if I cd docs/code/perl it'll cd to docs, then to code and then to perl instead of all at once. This works great, and it does what I want, only when I call the script to test it (and I am aware that it's necessary to do . ./script.sh or source ./script.sh) it jsut refuses to work!
Am I right in the understanding that if I have a script that changes the working directory then if I run it with source ./script.sh then it will change the working directory i nthe terminal i run it from?
Here's a little output:
pete@psilocybin bash]$ . ./cdscript.sh /home/pete/docs/code/perl
/ ~/docs/code/bash ~/docs/code ~/docs ~
/home / ~/docs/code/bash ~/docs/code ~/docs ~
~ /home / ~/docs/code/bash ~/docs/code ~/docs ~
~/docs ~ /home / ~/docs/code/bash ~/docs/code ~/docs ~
~/docs/code ~/docs ~ /home / ~/docs/code/bash ~/docs/code ~/docs ~
~/docs/code/perl ~/docs/code ~/docs ~ /home / ~/docs/code/bash ~/docs/code ~/docs ~
~/docs/code/perl ~/docs/code/perl ~/docs/code ~/docs ~ /home / ~/docs/code/bash ~/docs/code ~/docs ~
pete@psilocybin bash]$ pwd
~/docs/code/bash
That looks like a much better way of trying to do what I was trying to do than trying to do what I was trying to do...
Offline
Pages: 1