1

In Bash, the positional parameter $_ holds the last argument in the previous command:

$ /home/joe> some-script foo bar
$ /home/joe> cd $_
$ /home/joe/bar> 

The positional parameter $_ does not seem to work in the fish shell.

Is there some way in the fish shell using which I can get the last argument in the previous command? This can be useful in cases where that argument is a really long path, which can be painful to type again.

  • For some people, fizsh might be an alternative. – Tarrasch May 27 '13 at 5:18
1

fish uses $_ for the currently running program: http://fishshell.com/docs/current/index.html#title

To get the last arg of the last command, use Alt+Up

  • Alt+Up is gobbled up the GNOME Terminal I'm using. Is it possible to remap this to some other keyboard shortcut? – Ashwin Nanjappa Nov 21 '13 at 2:50
  • Yes. For example, to bind "alt+." to the same thing: bind \e. history-token-search-forward -- see "help bind" – glenn jackman Nov 21 '13 at 16:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.