Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to get last argument of previous command in Fish

📅 2019-Jan-21 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ bash, fish ⬩ 📚 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.


© 2023 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘 Mastodon📧 Email