Skip to content

Instantly share code, notes, and snippets.

@Mimickal
Created February 11, 2020 00:30
Show Gist options
  • Save Mimickal/24ca964ba1e6b0d9bffdf4e915f44d51 to your computer and use it in GitHub Desktop.
Save Mimickal/24ca964ba1e6b0d9bffdf4e915f44d51 to your computer and use it in GitHub Desktop.
Bash prompt that shows git branch, if in a git directory
# 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