quick(er) way to symlink your `pwd`

I learned the other day about a neat shortcut for tilde expansion in bash.

$ ls ~-/

The neat thing about this expansion is that it does tab completion. What this lead me to discover is that you can also do ~N, where n is a number refering to your directory stack. (the bash man page says you can use the command `dirs’ to view the stack, but it doesn’t seem to work for me. When you put in a 0 (zero), it is the current working dir.  Combined with tab completion, this gave me a great way for creating symlinks. Before, I had to do something like

$ ls `pwd`/

Which does do tab completion. But if you want to save a whopping 3 key strokes!, you can do something like this:

$ pwd
 
/Users/bhenderson/programming/ruby/guides.rubyonrails.org
 
$ ln -s ~0/index.html ~/Sites/ruby_guides
 
$ ls -l !:$
 
ls -l ~/Sites/ruby_guides
 
lrwxr-xr-x  1 bhenderson  staff  68 Jan 12 08:47 /Users/bhenderson/Sites/ruby_guides -> /Users/bhenderson/programming/ruby/guides.rubyonrails.org/index.html
 
$

Guide spidered from here.

Share:
  • del.icio.us
  • Reddit
  • Technorati
  • Twitter
  • Facebook
  • Google Bookmarks
  • HackerNews
  • PDF
  • RSS
This entry was posted in programming. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.