Artificial intelligent assistant

How to get current working directory before changing it 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

The easiest way is making your works in a subshell only:


snip-git() (
cd -- "$snippetdir"
git add .
git commit -m "."
git push -u
)


* * *

There're some thing you want to fix in your function:

* Remember to always quote your variables.
* You refer variable using `$cwd` instead of `cwd`.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy ca1d84d40a9d8d8c1dfe98a04e2fe0b5