From: Frederik Vanrenterghem Date: Fri, 16 Jun 2023 02:10:45 +0000 (+0800) Subject: Show git branch in command prompt. X-Git-Url: http://git.vanrenterghem.biz/Dotty.git/commitdiff_plain/7c78873708b5e939ca947188dd9abe6187d31be5 Show git branch in command prompt. --- diff --git a/bash/.bashrc b/bash/.bashrc index 84ee2e4..3b7c8b6 100644 --- a/bash/.bashrc +++ b/bash/.bashrc @@ -6,7 +6,12 @@ [[ $- != *i* ]] && return alias ls='ls --color=auto' -PS1='[\u@\h \W]\$ ' + +git_branch() { + git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' +} + +PS1="[\u@\h \W]\[\033[00;32m\]\$(git_branch)\[\033[00m\]\$ " unset SSH_AGENT_PID if [ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]; then