Created
February 11, 2020 00:30
-
-
Save Mimickal/24ca964ba1e6b0d9bffdf4e915f44d51 to your computer and use it in GitHub Desktop.
Bash prompt that shows git branch, if in a git directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Shows the git branch we're currently on, if in a git directory | |
function gitbranch() { | |
perl -e ' | |
my $output = `git branch 2> /dev/null`; | |
my ($branch) = $output =~ /\* ([\S]+)/; | |
if ($branch) { | |
print "[$branch]"; | |
} | |
'; | |
} | |
export PS1='[\t] ${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[01;34m\] \w `gitbranch`\$\[\033[00m\] ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment