git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 3/3] help: respect aliases

From
Jay Soffian <jaysoffian@gmail.com>
Date
Feb 26, 2008, 14:56 UTC
Message-ID
<76718490802260656s459e9241ie2a2d6b255c77fa4@mail.gmail.com>
In-Reply-To
<alpine.LSU.1.00.0802261222570.17164@racer.site>

On Tue, Feb 26, 2008 at 7:43 AM, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:

Show 16 quoted lines
>
>  On Sun, 24 Feb 2008, Jay Soffian wrote:
>
>  > This too would be less ugly as a built-in:
>  >
>  >  [elided so as not to burn anyone's eyes out again :-) -- jay]
>
>  Wow.  This would look less ugly as an alias like this, too:
>
>  alias = "!sh -c 'case $# in \
>         0) git config --get-regexp \"^alias\\.\" | sed \"s/^alias\\.//\";; \
>         *) git config \"alias.$0\" ;; \
>         esac'"
>
>  which incidentally fixes a bug in your alias: you ignore $0 which is the
>  first parameter when using the sh -c '' idiom.
Test mine. Test yours. See which works. :-)
At least on my system, I had to use:
  sh -c '...' -
And then refer to $1.
>  Of course, you can change the sed call to your liking...

Most of the ugliness in mine is that I crammed the whitespace down and that I'm using a quite involved pipeline to reformat all my aliases so they fit into my terminal window.

But the --get-regexp is a good tip.
j.
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 9 of 12 in “help: use parseopt”
  1. 1/3 help: use parseoptJeff King, Feb 24, 2008
  2. Christian CouderFeb 25, 2008
  3. Jeff KingFeb 25, 2008
  4. Junio C HamanoFeb 25, 2008
  5. 2/3 make alias lookup a public, procedural functionJeff King, Feb 24, 2008
  6. 3/3 help: respect aliasesJeff King, Feb 24, 2008
  7. Jay SoffianFeb 25, 2008
  8. Johannes SchindelinFeb 26, 2008
  9. Jay SoffianFeb 26, 2008
  10. Johannes SchindelinFeb 26, 2008
  11. Junio C HamanoFeb 26, 2008
  12. Jay SoffianFeb 26, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.