In Fish, an alias is actually implemented as a function. To make it permanent, you need to save the function using funcsave.
alias foo=bar
funcsave fooThis creates the file ~/.config/fish/functions/foo.fish, making the alias available in all future Fish sessions.
I prefer this method because it allows me to manage all my aliases in a single file.
- Open
~/.config/fish/config.fishin your favorite editor. If the file doesn't exist yet, create it. - Add the aliases you want to use.
- Save the file.
- Reload the configuration:
source ~/.config/fish/config.fishSince config.fish is loaded whenever Fish starts, your aliases will be available in every new shell session.
Enjoy!
Tip
If the alias doesn't work immediately, run source ~/.config/fish/config.fish or open a new terminal window to reload your Fish configuration.
Thanks a lot, man, I was going crazy trying to find it. I’m a beginner, so this might be obvious, but once you’ve written the command using the second method, you have to close the terminal and reopen it. I couldn't figure out why it wasn't working for me, and then I found the reason.