Re: Useful tip about !aliases

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Tue, 15 Jul 2008, Kevin Ballard wrote:

> Here's something I discovered recently about !aliases that other folks might
> find useful. The canonical form for a shell alias is something like
> 
>  git config alias.foo '!echo bar'
> 
> where any args given to foo, as in `git foo blah` are passed along to the
> shell, so in this case `echo bar blah` would be invoked.
> 
> Something that I find very useful is the ability to interpolate arguments into
> the middle of a command. This doesn't seem possible at first glance, not
> without a helper script. But it certainly is possible, with the help of shell
> functions:
> 
>  git config alias.reverse '!foo () { args=''; while [[ -n "$*" ]]; do args="$1
> $args"; shift; done; echo $args; }; foo'

On the gitwiki, you will find a more elegant solution using "sh -c".

Ciao,
Dscho
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux