The equivalent of bash’s !$ and !! in the fish shell

bashcommand linefishshell

I've been using bash for a decade or so and have gotten used to being able to type !$ to repeat the last argument, e.g.:

$ mkdir foo
$ cd !$
cd foo

(That last line is printed by the shell to tell you what your command evaluated to). Likewise I often to the following:

$ make_sandwich
-bash: make_sandwich: Permission denied
$ sudo !!
sudo make_sandwich

I'm really liking the fish shell, but my muscle memory is pretty established. Is there an equivalent in fish? Can I configure fish to use the same commands?

Best Answer

Alt-Up arrow gives you the last argument from the previous command. Subsequent pushes cycle throught prior arguments.

I haven't found a satisfactory equivalent to !!, except Up then Ctrl-A

Related Question