I have this function
snip-git(){
cd ${snippetdir}
git add .
git commit -m "."
git push -u
}
When git finishes pushing the changes, I want to get back to the directory I was when I called snip-git.
I tried this
snip-git(){
cwd=$(pwd)
cd ${snippetdir}
...
cd cwd
}
But it ends up reading the ned directory rather than the old one
snip-gitdefinition to use(...)instead of{ ... }? – cuonglm Mar 22 '16 at 10:29( )and{ }. Thanks @cuonglm – relidon Mar 22 '16 at 10:35( )ran your commands in subshell, after your command done, the environment was restored. – cuonglm Mar 22 '16 at 10:36