5

In zsh, I can execute them.

$ sleep 1
$ echo !$ # !$ equals 1
$ echo !! # !! equals sleep 1

But I can't execute them in fish shell. Could tell me why and where the zsh documentation is?

1

1 Answer 1

6

This is history expansion, which has a lot more to it then those simple examples.

Fish supports none of it (and probably never will). The usual workaround is to use keybindings. By default, alt-up and alt-down should go through the history token-wise, so you can press alt-up once to get what is effectively !$.

If you wish to prepend something to a command from history, recall that command, go to the beginning (e.g. with ctrl-a) and insert what you want.

Other possibilities are functions to bind e.g. !! to something to insert the previous command or to make a command called !!.

This is still discussed in fish issue #288, though concensus seems to be against adding history expansion.

1
  • I will check them.
    – shigemk2
    Sep 25, 2016 at 10:38

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