{"thread":{"id":"23049","subject":"git branch --current?","startedAt":"2010-03-17T14:43:30Z","lastAt":"2010-03-18T02:00:45Z","messageCount":6,"participants":["Nguyen Thai Ngoc Duy","Jay Soffian","David Aguilar"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"137017","messageId":"fcaeb9bf1003170743kc347d53jefe41039e3b9a69a@mail.gmail.com","threadId":"23049","inReplyTo":null,"subject":"git branch --current?","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-03-17T14:43:30Z","receivedAt":"2010-03-17T14:43:30Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"I use \"git branch\" when I need to know the current branch. But I have\nmany branches, looking for the star is \"time consuming\". I'd rather\nhave something like pwd, just print the current branch name and that's\nall. A bit more information about current branch wouldn't hurt, as\nlong as the branch name is printed at a fixed location.\n\nWhat command do you use to know what branch you are on?\n-- \nDuy\n"},{"id":"137018","messageId":"76718491003170748h349c5ed0u7649864cc824f549@mail.gmail.com","threadId":"23049","inReplyTo":"fcaeb9bf1003170743kc347d53jefe41039e3b9a69a@mail.gmail.com","subject":"Re: git branch --current?","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2010-03-17T14:48:43Z","receivedAt":"2010-03-17T14:48:43Z","isPatch":false,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Wed, Mar 17, 2010 at 10:43 AM, Nguyen Thai Ngoc Duy\n<pclouds@gmail.com> wrote:\n> I use \"git branch\" when I need to know the current branch. But I have\n> many branches, looking for the star is \"time consuming\". I'd rather\n> have something like pwd, just print the current branch name and that's\n> all. A bit more information about current branch wouldn't hurt, as\n> long as the branch name is printed at a fixed location.\n>\n> What command do you use to know what branch you are on?\n\nDoesn't everyone who's anyone put it in their prompt with the bash\ncompletion script? :-)\n\nWell, if not, how about a simple alias:\n\npwb = rev-parse --abbrev-ref HEAD\n\n?\n\nj.\n"},{"id":"137019","messageId":"fcaeb9bf1003170804s4c9fdbb6id2c045bdb90f8c6f@mail.gmail.com","threadId":"23049","inReplyTo":"76718491003170748h349c5ed0u7649864cc824f549@mail.gmail.com","subject":"Re: git branch --current?","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-03-17T15:04:50Z","receivedAt":"2010-03-17T15:04:50Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On 3/17/10, Jay Soffian <jaysoffian@gmail.com> wrote:\n> On Wed, Mar 17, 2010 at 10:43 AM, Nguyen Thai Ngoc Duy\n>  <pclouds@gmail.com> wrote:\n>  > I use \"git branch\" when I need to know the current branch. But I have\n>  > many branches, looking for the star is \"time consuming\". I'd rather\n>  > have something like pwd, just print the current branch name and that's\n>  > all. A bit more information about current branch wouldn't hurt, as\n>  > long as the branch name is printed at a fixed location.\n>  >\n>  > What command do you use to know what branch you are on?\n>\n>\n> Doesn't everyone who's anyone put it in their prompt with the bash\n>  completion script? :-)\n\nMe obviously :-) But bash is not the one true shell. I need to use csh\nsometimes.\n\n>  Well, if not, how about a simple alias:\n>\n>  pwb = rev-parse --abbrev-ref HEAD\n\nHmm.. I have alias.pwb = symbolic-ref HEAD. Both solutions are not as\ngood as \"git branch\", say detached HEAD case.\n-- \nDuy\n"},{"id":"137021","messageId":"76718491003170814v71e31e91q994daee849da4caf@mail.gmail.com","threadId":"23049","inReplyTo":"fcaeb9bf1003170804s4c9fdbb6id2c045bdb90f8c6f@mail.gmail.com","subject":"Re: git branch --current?","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2010-03-17T15:14:44Z","receivedAt":"2010-03-17T15:14:44Z","isPatch":false,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Wed, Mar 17, 2010 at 11:04 AM, Nguyen Thai Ngoc Duy\n<pclouds@gmail.com> wrote:\n> Hmm.. I have alias.pwb = symbolic-ref HEAD. Both solutions are not as\n> good as \"git branch\", say detached HEAD case.\n\nHow about naming something like this git-pwb and copying it to\nsomewhere in PATH:\n\n#!/bin/sh\n. /opt/git/share/git-core/git-completion.bash\necho $(__git_ps1)\n\n\nPerhaps you are inspired to contribute git-completion.csh?\n\n:-)\n\nj.\n"},{"id":"137053","messageId":"20100317190645.GA8304@gmail.com","threadId":"23049","inReplyTo":"76718491003170814v71e31e91q994daee849da4caf@mail.gmail.com","subject":"Re: git branch --current?","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2010-03-17T19:06:47Z","receivedAt":"2010-03-17T19:06:47Z","isPatch":false,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"\nHi,\n\nOn Wed, Mar 17, 2010 at 11:14:44AM -0400, Jay Soffian wrote:\n> On Wed, Mar 17, 2010 at 11:04 AM, Nguyen Thai Ngoc Duy\n> <pclouds@gmail.com> wrote:\n> > Hmm.. I have alias.pwb = symbolic-ref HEAD. Both solutions are not as\n> > good as \"git branch\", say detached HEAD case.\n> \n> How about naming something like this git-pwb and copying it to\n> somewhere in PATH:\n> \n> #!/bin/sh\n> . /opt/git/share/git-core/git-completion.bash\n> echo $(__git_ps1)\n> \n> \n> Perhaps you are inspired to contribute git-completion.csh?\n> \n> :-)\n> \n> j.\n\n\nYou caught my attention.  I don't personally like csh.  In fact,\nI'm actively working on a way to get us off of csh here at\n$dayjob.  Hence, I usually shy away from anything that\nencourages csh usage.\n\nThat said, I'm a practical person.  We've written a\ngit-completion.tcsh here so I figured I'd share.\n\nCaveats -- it sucks!  I'm pretty sure that this is due\nto either a) csh's poor completion facilities, or b) my\ninability to use it to its best ability.  The thing that really\nkills me is that I can't figure out how to get both path\ncompletion and --option completion at the same time.\nFor a while I had 'echo *' in there to handle that but\nthat breaks down once you start completing down a subdirectory\n(the \"/\" breaks it).  Hence, we always use the '--' separator\nwhen specifying pathspecs.\n\nWhat I learned from this exercise?\nBash completion is effin amazing!  (typed from a bash terminal)\n\nI'm sure there's plenty of ways to improve this.  Aside from\nthrowing it in contrib/ and hoping others find it useful enough\nto improve it, I've probably hit my tcsh completion-foo limit.\n\n\n-- >8 -- git-completion.tcsh -- >8 --\n\n#   Source this script in tcsh to setup shell completions\n#   for git.  Completions are activated by typing <tab> or Control-D\n#   in the shell after entering a partial command.\n#\n# Usage:\n#   source git-completion.tcsh     (e.g. in ~/.cshrc)\n#\n# Supported completions:\n#   git <tab>            (lists git commands)\n#   git help <tab>       (lists git commands)\n#   git branch <tab>     (lists branch names)\n#   git checkout <tab>   (lists branch names)\n#   git log <tab>        (lists the most commonly used flags)\n#   git remote <tab>     (lists git remote commands)\n#   git remote add|prune|rm|show|update <tab>\n#                        (lists git remote names)\n# In addition to entering <tab> where shown, you can enter it after\n# typing part of the word, e.g. git branch bug<tab> to auto-complete\n# branches starting with \"bug\".\n#\n# Author: David Adler, David Aguilar\n\nif ( -x /usr/bin/git) then\n    # Git is installed so define tcsh completions for it.\n\n    # List of known git subcommands\n    # This is a hard-coded list to avoid calling 'git help' at startup.\n    set __git_cmd_names = (add bisect blame branch checkout clone commit config \\\n                           diff difftool fetch grep gui init log merge mv pull push \\\n                           rebase reset rm show shortlog stash status tag)\n\n    alias __git_aliases 'git config --get-regex \"alias.*\" | sed -n \"s,alias\\.\\([^ ]*\\).*,\\1,p\"'\n    alias __git_branches 'git for-each-ref --format=\"%(refname)\" refs/heads refs/remotes | sed -e s,refs/remotes/,, | sed -e s,refs/heads/,,'\n    alias __git_origin_branches 'git for-each-ref --format=\"%(refname)\" refs/remotes/origin | grep -v HEAD | sed -e s,refs/remotes/origin/,,'\n\n    # Define the completions (see the tcsh man page).\n    complete git \\\n             'p/1/`__git_aliases | xargs echo $__git_cmd_names`/' \\\n             \"n/help/($__git_cmd_names)/\" \\\n             'n/branch/`__git_branches | xargs echo -m -d`/' \\\n             'n/config/(--global --get-regexp --list)/' \\\n             'n/diff/`__git_branches | xargs echo --check --staged --stat -- *`/' \\\n             'n/difftool/`__git_branches | xargs echo --no-prompt --staged -- *`/' \\\n             'n/fetch/`git remote`/' \\\n             'n/merge/`__git_branches`/' \\\n             '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             'n/stash/(apply list save pop clear)/' \\\n             'n/push/`git remote`/' \\\n             'N/push/`__git_origin_branches`/' \\\n             'n/pull/`git remote | xargs echo --rebase`/' \\\n             'n/--rebase/`git remote`/' \\\n             'N/--rebase/`__git_origin_branches`/' \\\n             'N/pull/`__git_origin_branches`/' \\\n             'n/rebase/`__git_branches | xargs echo --continue --abort --onto --skip --interactive`/' \\\n             'N/rebase/`__git_branches`/' \\\n             'n/remote/(show add rm prune update)/' \\\n             'N/remote/`git remote`/' \\\n             'n/checkout/`__git_branches | xargs echo -b --`/' \\\n             'N/-b/`__git_branches`/'\nendif\n\n-- \n\t\tDavid\n"},{"id":"137068","messageId":"fcaeb9bf1003171900i261068d2m954cbc22499b1b07@mail.gmail.com","threadId":"23049","inReplyTo":"20100317190645.GA8304@gmail.com","subject":"Re: git branch --current?","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-03-18T02:00:45Z","receivedAt":"2010-03-18T02:00:45Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Thu, Mar 18, 2010 at 2:06 AM, David Aguilar <davvid@gmail.com> wrote:\n> You caught my attention.  I don't personally like csh.  In fact,\n> I'm actively working on a way to get us off of csh here at\n> $dayjob.  Hence, I usually shy away from anything that\n> encourages csh usage.\n>\n> That said, I'm a practical person.  We've written a\n> git-completion.tcsh here so I figured I'd share.\n>\n> Caveats -- it sucks!  I'm pretty sure that this is due\n> to either a) csh's poor completion facilities, or b) my\n> inability to use it to its best ability.  The thing that really\n> kills me is that I can't figure out how to get both path\n> completion and --option completion at the same time.\n> For a while I had 'echo *' in there to handle that but\n> that breaks down once you start completing down a subdirectory\n> (the \"/\" breaks it).  Hence, we always use the '--' separator\n> when specifying pathspecs.\n\nBut it works, from a user point of view.\n\n> What I learned from this exercise?\n> Bash completion is effin amazing!  (typed from a bash terminal)\n>\n> I'm sure there's plenty of ways to improve this.  Aside from\n> throwing it in contrib/ and hoping others find it useful enough\n> to improve it, I've probably hit my tcsh completion-foo limit.\n\nI'll put it in my ~/.tcsh and see how it goes. Thanks.\n-- \nDuy\n"}]}