From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Kevin Ballard <kevin@sb.org>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: Useful tip about !aliases
Date: Wed, 16 Jul 2008 02:50:48 +0200 (CEST) [thread overview]
Message-ID: <alpine.DEB.1.00.0807160250120.2841@eeepc-johanness> (raw)
In-Reply-To: <3BD7F543-7CB4-48B6-8D2C-DEA2ADC6EF5F@sb.org>
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
next prev parent reply other threads:[~2008-07-16 0:51 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-16 0:46 Useful tip about !aliases Kevin Ballard
2008-07-16 0:50 ` Johannes Schindelin [this message]
2008-07-16 0:58 ` Kevin Ballard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.DEB.1.00.0807160250120.2841@eeepc-johanness \
--to=johannes.schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=kevin@sb.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox