I want to add to my .zshrc function that will perform operations with file that has “.c” suffix. For example,
*.c () {
gcc $0 -o ${0%.*}
}
must perform “gcc foo.c -o foo” when I am entering “foo.c”
But when I added this function to “.zshrc”, my shell begins prints “no matches found: *.c” on login.
Can I do this other way or make this function “lazy”?
You’ll want
alias -sbehaviour. From the manpages:Combine your written function to a suffix alias and you should be set to go!
First, write your function in this form:
And then the suffix alias
will work as intended.