git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* git branch --current?
@ 2010-03-17 14:43 Nguyen Thai Ngoc Duy
  2010-03-17 14:48 ` Jay Soffian
  0 siblings, 1 reply; 6+ messages in thread
From: Nguyen Thai Ngoc Duy @ 2010-03-17 14:43 UTC (permalink / raw)
  To: Git Mailing List

I use "git branch" when I need to know the current branch. But I have
many branches, looking for the star is "time consuming". I'd rather
have something like pwd, just print the current branch name and that's
all. A bit more information about current branch wouldn't hurt, as
long as the branch name is printed at a fixed location.

What command do you use to know what branch you are on?
-- 
Duy

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: git branch --current?
  2010-03-17 14:43 git branch --current? Nguyen Thai Ngoc Duy
@ 2010-03-17 14:48 ` Jay Soffian
  2010-03-17 15:04   ` Nguyen Thai Ngoc Duy
  0 siblings, 1 reply; 6+ messages in thread
From: Jay Soffian @ 2010-03-17 14:48 UTC (permalink / raw)
  To: Nguyen Thai Ngoc Duy; +Cc: Git Mailing List

On Wed, Mar 17, 2010 at 10:43 AM, Nguyen Thai Ngoc Duy
<pclouds@gmail.com> wrote:
> I use "git branch" when I need to know the current branch. But I have
> many branches, looking for the star is "time consuming". I'd rather
> have something like pwd, just print the current branch name and that's
> all. A bit more information about current branch wouldn't hurt, as
> long as the branch name is printed at a fixed location.
>
> What command do you use to know what branch you are on?

Doesn't everyone who's anyone put it in their prompt with the bash
completion script? :-)

Well, if not, how about a simple alias:

pwb = rev-parse --abbrev-ref HEAD

?

j.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: git branch --current?
  2010-03-17 14:48 ` Jay Soffian
@ 2010-03-17 15:04   ` Nguyen Thai Ngoc Duy
  2010-03-17 15:14     ` Jay Soffian
  0 siblings, 1 reply; 6+ messages in thread
From: Nguyen Thai Ngoc Duy @ 2010-03-17 15:04 UTC (permalink / raw)
  To: Jay Soffian; +Cc: Git Mailing List

On 3/17/10, Jay Soffian <jaysoffian@gmail.com> wrote:
> On Wed, Mar 17, 2010 at 10:43 AM, Nguyen Thai Ngoc Duy
>  <pclouds@gmail.com> wrote:
>  > I use "git branch" when I need to know the current branch. But I have
>  > many branches, looking for the star is "time consuming". I'd rather
>  > have something like pwd, just print the current branch name and that's
>  > all. A bit more information about current branch wouldn't hurt, as
>  > long as the branch name is printed at a fixed location.
>  >
>  > What command do you use to know what branch you are on?
>
>
> Doesn't everyone who's anyone put it in their prompt with the bash
>  completion script? :-)

Me obviously :-) But bash is not the one true shell. I need to use csh
sometimes.

>  Well, if not, how about a simple alias:
>
>  pwb = rev-parse --abbrev-ref HEAD

Hmm.. I have alias.pwb = symbolic-ref HEAD. Both solutions are not as
good as "git branch", say detached HEAD case.
-- 
Duy

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: git branch --current?
  2010-03-17 15:04   ` Nguyen Thai Ngoc Duy
@ 2010-03-17 15:14     ` Jay Soffian
  2010-03-17 19:06       ` David Aguilar
  0 siblings, 1 reply; 6+ messages in thread
From: Jay Soffian @ 2010-03-17 15:14 UTC (permalink / raw)
  To: Nguyen Thai Ngoc Duy; +Cc: Git Mailing List

On Wed, Mar 17, 2010 at 11:04 AM, Nguyen Thai Ngoc Duy
<pclouds@gmail.com> wrote:
> Hmm.. I have alias.pwb = symbolic-ref HEAD. Both solutions are not as
> good as "git branch", say detached HEAD case.

How about naming something like this git-pwb and copying it to
somewhere in PATH:

#!/bin/sh
. /opt/git/share/git-core/git-completion.bash
echo $(__git_ps1)


Perhaps you are inspired to contribute git-completion.csh?

:-)

j.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: git branch --current?
  2010-03-17 15:14     ` Jay Soffian
@ 2010-03-17 19:06       ` David Aguilar
  2010-03-18  2:00         ` Nguyen Thai Ngoc Duy
  0 siblings, 1 reply; 6+ messages in thread
From: David Aguilar @ 2010-03-17 19:06 UTC (permalink / raw)
  To: Jay Soffian; +Cc: Nguyen Thai Ngoc Duy, Git Mailing List


Hi,

On Wed, Mar 17, 2010 at 11:14:44AM -0400, Jay Soffian wrote:
> On Wed, Mar 17, 2010 at 11:04 AM, Nguyen Thai Ngoc Duy
> <pclouds@gmail.com> wrote:
> > Hmm.. I have alias.pwb = symbolic-ref HEAD. Both solutions are not as
> > good as "git branch", say detached HEAD case.
> 
> How about naming something like this git-pwb and copying it to
> somewhere in PATH:
> 
> #!/bin/sh
> . /opt/git/share/git-core/git-completion.bash
> echo $(__git_ps1)
> 
> 
> Perhaps you are inspired to contribute git-completion.csh?
> 
> :-)
> 
> j.


You caught my attention.  I don't personally like csh.  In fact,
I'm actively working on a way to get us off of csh here at
$dayjob.  Hence, I usually shy away from anything that
encourages csh usage.

That said, I'm a practical person.  We've written a
git-completion.tcsh here so I figured I'd share.

Caveats -- it sucks!  I'm pretty sure that this is due
to either a) csh's poor completion facilities, or b) my
inability to use it to its best ability.  The thing that really
kills me is that I can't figure out how to get both path
completion and --option completion at the same time.
For a while I had 'echo *' in there to handle that but
that breaks down once you start completing down a subdirectory
(the "/" breaks it).  Hence, we always use the '--' separator
when specifying pathspecs.

What I learned from this exercise?
Bash completion is effin amazing!  (typed from a bash terminal)

I'm sure there's plenty of ways to improve this.  Aside from
throwing it in contrib/ and hoping others find it useful enough
to improve it, I've probably hit my tcsh completion-foo limit.


-- >8 -- git-completion.tcsh -- >8 --

#   Source this script in tcsh to setup shell completions
#   for git.  Completions are activated by typing <tab> or Control-D
#   in the shell after entering a partial command.
#
# Usage:
#   source git-completion.tcsh     (e.g. in ~/.cshrc)
#
# Supported completions:
#   git <tab>            (lists git commands)
#   git help <tab>       (lists git commands)
#   git branch <tab>     (lists branch names)
#   git checkout <tab>   (lists branch names)
#   git log <tab>        (lists the most commonly used flags)
#   git remote <tab>     (lists git remote commands)
#   git remote add|prune|rm|show|update <tab>
#                        (lists git remote names)
# In addition to entering <tab> where shown, you can enter it after
# typing part of the word, e.g. git branch bug<tab> to auto-complete
# branches starting with "bug".
#
# Author: David Adler, David Aguilar

if ( -x /usr/bin/git) then
    # Git is installed so define tcsh completions for it.

    # List of known git subcommands
    # This is a hard-coded list to avoid calling 'git help' at startup.
    set __git_cmd_names = (add bisect blame branch checkout clone commit config \
                           diff difftool fetch grep gui init log merge mv pull push \
                           rebase reset rm show shortlog stash status tag)

    alias __git_aliases 'git config --get-regex "alias.*" | sed -n "s,alias\.\([^ ]*\).*,\1,p"'
    alias __git_branches 'git for-each-ref --format="%(refname)" refs/heads refs/remotes | sed -e s,refs/remotes/,, | sed -e s,refs/heads/,,'
    alias __git_origin_branches 'git for-each-ref --format="%(refname)" refs/remotes/origin | grep -v HEAD | sed -e s,refs/remotes/origin/,,'

    # Define the completions (see the tcsh man page).
    complete git \
             'p/1/`__git_aliases | xargs echo $__git_cmd_names`/' \
             "n/help/($__git_cmd_names)/" \
             'n/branch/`__git_branches | xargs echo -m -d`/' \
             'n/config/(--global --get-regexp --list)/' \
             'n/diff/`__git_branches | xargs echo --check --staged --stat -- *`/' \
             'n/difftool/`__git_branches | xargs echo --no-prompt --staged -- *`/' \
             'n/fetch/`git remote`/' \
             'n/merge/`__git_branches`/' \
             'n/log/`__git_branches | xargs echo -- --name-only --name-status --reverse --committer= --no-color --relative --ignore-space-change --ignore-space-at-eol --format=medium --format=full --format=fuller`/' \
             'n/stash/(apply list save pop clear)/' \
             'n/push/`git remote`/' \
             'N/push/`__git_origin_branches`/' \
             'n/pull/`git remote | xargs echo --rebase`/' \
             'n/--rebase/`git remote`/' \
             'N/--rebase/`__git_origin_branches`/' \
             'N/pull/`__git_origin_branches`/' \
             'n/rebase/`__git_branches | xargs echo --continue --abort --onto --skip --interactive`/' \
             'N/rebase/`__git_branches`/' \
             'n/remote/(show add rm prune update)/' \
             'N/remote/`git remote`/' \
             'n/checkout/`__git_branches | xargs echo -b --`/' \
             'N/-b/`__git_branches`/'
endif

-- 
		David

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: git branch --current?
  2010-03-17 19:06       ` David Aguilar
@ 2010-03-18  2:00         ` Nguyen Thai Ngoc Duy
  0 siblings, 0 replies; 6+ messages in thread
From: Nguyen Thai Ngoc Duy @ 2010-03-18  2:00 UTC (permalink / raw)
  To: David Aguilar; +Cc: Jay Soffian, Git Mailing List

On Thu, Mar 18, 2010 at 2:06 AM, David Aguilar <davvid@gmail.com> wrote:
> You caught my attention.  I don't personally like csh.  In fact,
> I'm actively working on a way to get us off of csh here at
> $dayjob.  Hence, I usually shy away from anything that
> encourages csh usage.
>
> That said, I'm a practical person.  We've written a
> git-completion.tcsh here so I figured I'd share.
>
> Caveats -- it sucks!  I'm pretty sure that this is due
> to either a) csh's poor completion facilities, or b) my
> inability to use it to its best ability.  The thing that really
> kills me is that I can't figure out how to get both path
> completion and --option completion at the same time.
> For a while I had 'echo *' in there to handle that but
> that breaks down once you start completing down a subdirectory
> (the "/" breaks it).  Hence, we always use the '--' separator
> when specifying pathspecs.

But it works, from a user point of view.

> What I learned from this exercise?
> Bash completion is effin amazing!  (typed from a bash terminal)
>
> I'm sure there's plenty of ways to improve this.  Aside from
> throwing it in contrib/ and hoping others find it useful enough
> to improve it, I've probably hit my tcsh completion-foo limit.

I'll put it in my ~/.tcsh and see how it goes. Thanks.
-- 
Duy

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-03-18  2:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-17 14:43 git branch --current? Nguyen Thai Ngoc Duy
2010-03-17 14:48 ` Jay Soffian
2010-03-17 15:04   ` Nguyen Thai Ngoc Duy
2010-03-17 15:14     ` Jay Soffian
2010-03-17 19:06       ` David Aguilar
2010-03-18  2:00         ` Nguyen Thai Ngoc Duy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).