Hacker News new | ask | show | jobs
by rwl4 4616 days ago
My favorite shell trick (not in the link) is this: ~-

Tilde-hyphen expands to the previous directory you were in, and of course "cd -" returns you to your previous directory, so I put them together all the time.

Here's an example workflow (with a fake PS1):

  mac:/Users/me/Projects/my_new_app$ cd ~/.pow

  mac:/Users/me/.pow$ ln -s ~- .

  mac:/Users/me/.pow$ cd -

  mac:/Users/me/Projects/my_new_app$
Now I can continue working on my app.

<disclaimer>

That's bit of a contrived example above. Here's a more realistic way to do a symlink for pow:

  mac:/Users/me/Projects/my_new_app$ ln -s `pwd` ~/.pow/
</disclaimer>
1 comments

Save the earth, fork less:

    ln -s $PWD ~/.pow
(Interesting tip about ~-, didn't know that one)