You are not logged in.
Pages: 1
Hello,
I want to make a simple alias for find. I want it to print me a message before find is ran. This the alias (function) I have currently in my .zsrhc:
find() {
echo -e "[${red}+${normal}] ${green}locate${normal} is a much faster alternative to find."
find $@
}
When I run find I get:
apg:~/ $ find -name "python" [10:58:36]
[+] locate is a much faster alternative to find.
[+] locate is a much faster alternative to find.
[+] locate is a much faster alternative to find.
.......
......
[+] locate is a much faster alternative to find.
find:2: maximum nested function level reached
Any ideas how to implement it? I want the output to be
[+] locate is a much faster alternative to find.
FIND RUNS HERE AS NORMAL
Thansk a lot!
Last edited by arch_apo (2017-04-13 10:09:34)
Offline
Ok I fixed it... Just in case someone has a similar problem...
Instead of find $@ do, /usr/bin/find $@ to avoid running the function recursively.
Offline
Your problem is that the function is calling itself over and over.
Either get it to call find directly instead of itself...
find() {
echo -e "[${red}+${normal}] ${green}locate${normal} is a much faster alternative to find."
/usr/bin/find $@
}
Or just use an alias...
alias find='echo -e "[${red}+${normal}] ${green}locate${normal} is a much faster alternative to find."; find'
Offline
Pages: 1