4 ms·
Yeah, whenever you cd, OLDPWD gets set to the directory you just changed from. cd will substitute $OLDPWD when you cd to "-". Perhaps even less well know, the
by gmjosack 13y ago
Yeah, whenever you cd, OLDPWD gets set to the directory you just changed from. cd will substitute $OLDPWD when you cd to "-". Perhaps even less well know, the shell itself will expand ~- to $OLDPWD so if you ever want to see where cd - would take you, or just list the files from your previous working directory you could do "echo ~-" or "ls ~-" respectively.
- oftenwrong 13y agoPWD, OLDPWD, and cd - are POSIX ~- is a bashism You can add a number to navigate the pushd/popd/dirs stack https://www.gnu.org/software/bash/manual/bashref.html#Tilde-Expansion https://www.gnu.org/software/bash/manual/bashref.html#Tilde-...