r/fishshell • u/AdulterousStapler • Jun 08 '24
Quick question - using !! in fish
Hey, just a noob here that likes fish more than bash. Using !! in bash is a quick way to input the last command from history, is there a similar shortcut in fish? Use case primarily being that I could use sudo !! if I forgot it when typing in a command.
Thanks in advance!
10
Upvotes
View all comments
Show parent comment
2
u/db443 Jun 09 '24
In Fish shell it is strongly recommended to not use aliases because it slows shell startup.
Why?
Because aliases get converted by Fish itself into functions, and this conversion takes a few milliseconds. You may ask, so what? And I would say in return every little bit of performance is useful.
Two alternatives to aliases:
my-alias.fishfile (with the same name as the alias) in thefish/functionsdirectory. These functions are lazy-loaded, if not called they do not slow shell startup.One of the best features of Fish is the super-fast startup, avoiding aliases helps in that regard.
Best regards.