I would like to define some aliases in fish. Apparently it should be possible to define them in
~/.config/fish/functions
but they don't get auto loaded when I restart the shell. Any ideas?
Just use alias
. Here's a basic example:
# Define alias in shell
alias rmi "rm -i"
# Define alias in config file
alias rmi="rm -i"
# This is equivalent to entering the following function:
function rmi
rm -i $argv
end
# Then, to save it across terminal sessions:
funcsave rmi
This last command creates the file ~/.config/fish/functions/rmi.fish
.
Interested people might like to find out more about fish aliases in the official manual.
Also note that in fish an alias is just a shellscript wrapper around a function.
@user456584 ...and that's to bad, because you can't do
alias local "set -l"
;-(Just a note of which file to put this in. I put mine in
~/.config/fish/config.fish
so it loads every time I run a terminal.Don't we need to quote
"$argv"
to handle arguments with spaces like we do with bash"$@"
?@kyb, nope, fish is smarter than bash like that. Actually, ALL variables in fish are arrays. Go to Shell variables and scroll down to the Arrays subsection