Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to get last argument of previous command in Fish

📅 2019-Jan-21 ⬩ ✍️ Ashwin Nanjappa ⬩ 📚 Archive

While working at the Bash shell prompt, you can access the very last argument of the preceding command using $_.

For example:

$ vim foobar.txt
$ vim $_

To get the effect of $_ in Fish, press Alt+Up. Fish will insert the last argument of the previous command for you right there at the shell prompt.

If you find this command is not working, please check if your terminal multiplexer (tmux or Byobu) or your GUI terminal or windowing environment has not already assigned that key for something else.