[Insight-developers] Bash shell prompt customization
Marcus D. Hanwell
marcus.hanwell at kitware.com
Mon Sep 27 15:31:01 EDT 2010
On Mon, Sep 27, 2010 at 2:43 PM, Bill Lorensen <bill.lorensen at gmail.com>wrote:
> Folks,
>
> I'm sure the experts already know this, but if you are using the bash
> shell, you can customize the prompt to show which git branch is
> active.
>
> Here is what I added to my ~/.bashrc file:
>
> parse_git_branch()
> {
> git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
> }
> export
> PS1="[\[\e[01;34m\]\W\[\e[31m\]\$(parse_git_branch)\[\e[00m\]]\[\e[00m\]
> "
>
> It shows up like this:
> [ITKPersonal(gdcmWarnings)] (with colors!)
>
> I use something very similar to get the user at host, path and (optionally)
the git branch. I couldn't live without it now. One other thing you might be
interested in is bash completion, it is very well developed for Git and even
completes on custom aliases. Installation depends on your distro, but typing
git <tab><tab> would give all common completions, and even options will be
expanded/completed.
We should possibly add something to the wiki for those wishing to use some
of the extras available such as custom prompts and bash completion.
Thanks,
Marcus
--
Marcus D. Hanwell, Ph.D.
R&D Engineer, Kitware Inc.
(518) 881-4937
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/mailman/private/insight-developers/attachments/20100927/3774aaaf/attachment.htm>
More information about the Insight-developers
mailing list