]> git.vanrenterghem.biz Git - Dotty.git/commitdiff
Show git branch in command prompt.
authorFrederik Vanrenterghem <frederik@vanrenterghem.biz>
Fri, 16 Jun 2023 02:10:45 +0000 (10:10 +0800)
committerFrederik Vanrenterghem <frederik@vanrenterghem.biz>
Fri, 16 Jun 2023 02:10:45 +0000 (10:10 +0800)
bash/.bashrc

index 84ee2e478907d829fe2d82f340971c5c64008a3c..3b7c8b6c22ac69926318bb62db040bbf6f51fba8 100644 (file)
@@ -6,7 +6,12 @@
 [[ $- != *i* ]] && return
 
 alias ls='ls --color=auto'
 [[ $- != *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
 
 unset SSH_AGENT_PID
 if [ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]; then