* [OT] git branches and command prompts
@ 2010-08-26 20:12 Jason
2010-08-26 20:16 ` Jason
2010-08-27 0:46 ` Michał Nazarewicz
0 siblings, 2 replies; 4+ messages in thread
From: Jason @ 2010-08-26 20:12 UTC (permalink / raw)
To: linux-c-programming
All,
if you're like me, you play with a lot of open source code. A lot of it is now in git repositories. I frequently forget which branch I'm on in each project, particularly with Android/Cyanogen. Here's a hack I figured out that helps me out, place it in ~/.bashrc :
### begin ####
PROMPT_COMMAND="echo -n \${PWD};
if git branch >/dev/null 2>&1; then
echo -n \" (\$(git branch | grep ^* | cut -d ' ' -f 2-))\"
fi"
PS1="\n[\[\033[01;34m\]\u\[\033[00m\]@\h] $ "
export PROMPT_COMMAND PS1
### end ######
Here's the result:
/home/jason
[jason@phantom] $ cd src/foss/git.git
/home/jason/src/foss/git.git (master)
[jason@phantom] $ git checkout git_shell_dir_opt
Switched to branch 'git_shell_dir_opt'
/home/jason/src/foss/git.git (git_shell_dir_opt)
[jason@phantom] $
Obviously you can tweak it to just one line, or a simpler PS1, or whatever. Thought it might help some folks.
Jason.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [OT] git branches and command prompts
2010-08-26 20:12 [OT] git branches and command prompts Jason
@ 2010-08-26 20:16 ` Jason
2010-08-27 0:46 ` Michał Nazarewicz
1 sibling, 0 replies; 4+ messages in thread
From: Jason @ 2010-08-26 20:16 UTC (permalink / raw)
To: linux-c-programming
Sorry, TB mangled the formatting. Hopefully quoting helps. :-(
Jason wrote:
> All,
>
> if you're like me, you play with a lot of open source code. A lot of it
> is now in git repositories. I frequently forget which branch I'm on in
> each project, particularly with Android/Cyanogen. Here's a hack I
> figured out that helps me out, place it in ~/.bashrc :
>
> ### begin ####
> PROMPT_COMMAND="echo -n \${PWD};
> if git branch >/dev/null 2>&1; then
> echo -n \"(\$(git branch | grep ^* | cut -d ' ' -f 2-))\"
> fi"
> PS1="\n[\[\033[01;34m\]\u\[\033[00m\]@\h] $ "
> export PROMPT_COMMAND PS1
> ### end ######
>
> Here's the result:
>
> /home/jason
> [jason@phantom] $ cd src/foss/git.git
> /home/jason/src/foss/git.git (master)
> [jason@phantom] $ git checkout git_shell_dir_opt
> Switched to branch 'git_shell_dir_opt'
> /home/jason/src/foss/git.git (git_shell_dir_opt)
> [jason@phantom] $
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [OT] git branches and command prompts
2010-08-26 20:12 [OT] git branches and command prompts Jason
2010-08-26 20:16 ` Jason
@ 2010-08-27 0:46 ` Michał Nazarewicz
2010-08-27 3:45 ` Jason
1 sibling, 1 reply; 4+ messages in thread
From: Michał Nazarewicz @ 2010-08-27 0:46 UTC (permalink / raw)
To: linux-c-programming, Jason
Since we are sharing, mine is at
<http://github.com/mina86/dot-files/blob/master/bashrc>. Also, from what
I know, bash-completion package has some funky command meant to be used
in prompt.
--
Best regards, _ _
| Humble Liege of Serenely Enlightened Majesty of o' \,=./ `o
| Computer Science, Michał "mina86" Nazarewicz (o o)
+----[mina86*mina86.com]---[mina86*jabber.org]----ooO--(_)--Ooo--
--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [OT] git branches and command prompts
2010-08-27 0:46 ` Michał Nazarewicz
@ 2010-08-27 3:45 ` Jason
0 siblings, 0 replies; 4+ messages in thread
From: Jason @ 2010-08-27 3:45 UTC (permalink / raw)
To: Michał Nazarewicz; +Cc: linux-c-programming
On 08/26/2010 08:46 PM, Michał Nazarewicz wrote:
> Since we are sharing, mine is at
> <http://github.com/mina86/dot-files/blob/master/bashrc>. Also, from what
> I know, bash-completion package has some funky command meant to be used
> in prompt.
>
wow. That rocks. There are so many neat tricks in there it's not even funny.
Thanks for sharing.
Jason.
--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-08-27 3:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-26 20:12 [OT] git branches and command prompts Jason
2010-08-26 20:16 ` Jason
2010-08-27 0:46 ` Michał Nazarewicz
2010-08-27 3:45 ` Jason
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).