Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

zsh alias -> function?

Tags:

arguments

zsh

Suppose I have:

alias gg="git grep" 

then stuff like:

gg "int x" 

works, but

gg int x 

gets complaints. Is there a way to rewrite gg as a function in zsh so that it takes all the arguments after gg, and stuffs them into a string?

Thanks!

like image 725
anon Avatar asked Feb 01 '10 02:02

anon


People also ask

How do I do an alias in ZSH?

To set up a simple alias, edit the ~/. zshrc file using your text editor and add an alias at the bottom. It is good to keep all your aliases in a single section of the file to avoid confusion and ease of edit. alias ginit="git init ."

Is ZSH better than bash?

Zsh is more interactive and customizable than Bash. Zsh has floating-point support that Bash does not possess. Hash data structures are supported in Zsh that are not present in Bash. The invocation features in Bash is better when comparing with Zsh.

What is Fpath ZSH?

The Korn shell( ksh ) searches FPATH for a file defining a shell function to load and execute in the current process. The Z shell ( zsh ) searches fpath for a file defining a shell function to load and execute in the current process.


1 Answers

gg() { git grep "$*"; } 
like image 108
Dennis Williamson Avatar answered Sep 17 '22 14:09

Dennis Williamson