I am trying to source
the Firefox addon sdk. To do so, I must cd
into the sdk's dir, then run source bin/activate
. If I don't cd
into that dir, and source directly from whatever path I am in currently, the following happens:
$ source ~/src/devtools/addon-sdk/bin/activate Welcome to the Add-on SDK. Run 'cfx docs' for assistance. $ cfx -bash: cfx: command not found
I want to have an alias for that, which cd's into the sdk, sources it, then returns to my current directory:
alias acfx='cd ~/src/devtools/addon-sdk && source bin/activate && cd "$(dirname "$0")"'
This sources the sdk correctly, but alas does not return to the directory I invoked the alias:
$ acfx Welcome to the Add-on SDK. Run 'cfx docs' for assistance. dirname: illegal option -- b usage: dirname path
I am lost here, how do I return to the original directory? Or specify a 'working directory' for source
?
You can execute cd and subsequent command in a sub-shell like this:
(cd ~/src/devtools/addon-sdk && source bin/activate)
If for some reason you don't want to create sub-shell then use cd -
to change dir to the the previous dir:
cd ~/src/devtools/addon-sdk && source bin/activate && cd -