Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You can also get at the arguments of the previous command line with !!:n, where n is the position of the argument.

i.e.

  host:test user$ touch one two three four five
  host:test user$ ls
  five	four	one	three	two
  host:test user$ cat four
  host:test user$ echo !!:1
  echo four
  four
Also, "Esc, dot" is an awesome bash shortcut. (Press them consecutively, not concurrently). It inserts the last argument of the previous command in place. So if you're doing something to the same file, Esc, . will usually bring up the file name.

i.e.

  host:test user$ cat five
  host:test user$ touch [Esc, .]


Easier than [Esc, .] is !$. Does the same thing.


Either work, it all amounts to habit. My fingers are just used to hitting esc, . and it's nice to see the argument get inserted inline as I'm editing.


Except you can press [esc, .] multiple times.


In most "Esc then X" cases, you should also be able to type Alt+X, which jives better with some folks' preferences.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: