Reputation: 75
I try to create an alias for ls (should basically just map to ls -lah
)
I've tried the following code, but it's not working:
function ls
ls -lah
end
funcsave ls
but when I call it I get this message:
The function 'ls' calls itself immediately, which would result in an infinite loop. in function 'ls' called on standard input
Upvotes: 3
Views: 7358
Reputation: 302
What you're looking for is the command
command.
I would also recommend to pass any arguments (stored in $argv
) to the aliased command.
So your example should be:
function ls
command ls -lah $argv
end
And to do all this with a simple command, you can simply use the alias
command.
alias ls "command ls -lah"
You can use the complete
command to tell fish that your alias uses the same completions as the aliased command.
The balias
plugin
serves as an alternative to alias
and does just that.
fish also offers an abbr
command. It works slightly different and will actually expand the abbreviated command to the full command in the command line, and then fish will have no problem giving you all the auto-completion suggestions that it knows.
Upvotes: 5
Reputation: 30
If you need to make alias of ls
, then the above answers are OK.
However, fish already has a command for ls -lah
, which is la
.
Upvotes: 0
Reputation: 247172
You need the command
keyword. Also, pass the function's arguments to ls
function ls
command ls -lah $argv
end
Upvotes: 3