简体   繁体   中英

Fish shell list with +30 aliases

I tried fish shell and like it so far - now I want to add all my aliases (+30, for servers and so on) and only found that I can add functions in my .config/fish/functions folder.

Is there an easier more "badge" way of importing them from a normal .bash_aliases file?

The first thing to note is that alias in fish does something very different from what it does in bash . In fish alias is just a way to write one-liner functions. In other words this

alias xyz 'echo hello'

is just a shortcut for writing

function xyz
    echo hello $argv
end

A lot of the time when people are talking about converting bash aliases to fish what they really want is the fish abbr command to create an abbreviation.

Glenn's answer may work for you but only if your bash aliases are so trivial they are compatible with fish syntax. Not something I would bet on without having reviewed your aliases.

You can start by just copying your aliases into either your ~/.config/fish/config.fish or a file that you source from your config.fish. Then review them to see if they are valid fish statements.

fish has the same alias syntax as bash. It just converts the aliases to functions for you. All you need to do is funcsave them to make them "permanent".

Perhaps this will work for you:

awk -F '[ =]' '$1 == "alias" {print; print "funcsave", $2}' ~/.bashrc | source -

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM