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 g
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.
If you add an abbr
instead of an alias
you'll get better auto-complete. In fish abbr
more closely matches the behavior of a bash alias.
abbr -a gco git checkout
Will -a
dd a new abbr
eviation gco
that expands to git checkout
.
Here's a video demo of the resulting auto-complete features
make a function in ~/.config/fish/functions called mkalias.fish and put this in
function mkalias --argument key value
echo alias $key=$value
alias $key=$value
funcsave $key
end
and this will create aliases automatically.
fish starts by executing commands in ~/.config/fish/config.fish. You can create it if it does not exist:
vim ~/.config/fish/config.fish
and save it with :wq
step1. make configuration file (like .bashrc)
config.fish
step2. just write your alias like this;
alias rm="rm -i"
function name; command; end
I found the prior answers and comments to be needlessly incomplete and/or confusing. The minimum that I needed to do was:
~/.config/fish/config.fish
. This file can optionally be a softlink.alias myalias echo foo bar
.fish
. To confirm the definition, try type myalias
. Try the alias.