Lurker News
OSX Terminal: hold option and click a position in the current line to move your cursor to that position. #yearslost

Comments (395) 107 threads

Show all comments

Showing thread 35 of 107

etoulas1 reply#
As it wasn't mentioned yet: pushd / popd

These two commands replace 'cd' and work with a directory stack of different paths.

   $ pushd tmp   # cd to tmp and remember current path /
   /tmp /
   $ pwd
   /tmp
   $ cd /usr   # normal cd to wherever you want...
   $ pwd
   /usr
   $ popd   # pop the stck and get back to the previous path
   /
   $ pwd
   /
Subsequent pushd will stack multiple paths.

It's a built-in of bash and other shells. It works even with Windows' cmd.exe

nightwolf#
You can also use "cd -" to go back to the previous path:

  $ cd /
  $ pwd
  /
  $ cd /tmp
  $ pwd
  /tmp
  $ cd -
  $ pwd
  /
Not the same, of course, but still useful, I think.