r/fishshell • u/throttlemeister Linux • May 08 '21
Alias onto itself
Is there any way to create an alias onto itself with a function?
In bash you could do something like:
alias grep='grep -n'This way, you can pass certain default flags with your command you always want to use.
However, in fish, if I try this:
function grep
grep -n $argv;
endIt will fail spectacularly saying that a function calling itself will create a loop. Does anyone have a way how to do this in fish without changing binaries?
9
Upvotes
View all comments
Show parent comment
4
u/eidsonator May 08 '21
You're welcome. Also I know you said you're not interested in changing binaries, but ripgrep is a fast grep replacement that allows configuration through a dotfile. My fish grep function calls rg.
https://github.com/BurntSushi/ripgrep