5 ms·
My tip: pushd without an arg pushes the current directory onto the stack, and then switches to what popd would have. Hence, repeated invocations of pushd let y
by jrockway 17y ago
My tip: pushd without an arg pushes the current directory onto the stack, and then switches to what popd would have. Hence, repeated invocations of pushd let you cycle between two directories without thinking.
$CDPATH is also amusing:
$ mkdir /foo/bar/baz
$ cd baz
bash: cd: baz: no such file or directory
$ export CDPATH="/foo/bar"
$ cd baz
$ pwd
/foo/bar/baz
- xpaulbettsx 17y agoYou can also do this with "cd -"
- etherealG 17y agocould you give an example of the pushd thing you mentioned?
- jrockway 17y ago$ pwd /home/jrockway $ pushd foo $ pwd /home/jrockway/foo $ popd $ pwd /home/jrockway $ popd error: directory stack empty $ pushd error: directory stack empty $ pushd foo $ pwd /home/jrockway/foo $ pushd /home/jrockway $ pushd /home/jrockway/foo $ pushd /home/jrockway ...