From 7c78873708b5e939ca947188dd9abe6187d31be5 Mon Sep 17 00:00:00 2001 From: Frederik Vanrenterghem Date: Fri, 16 Jun 2023 10:10:45 +0800 Subject: [PATCH] Show git branch in command prompt. --- bash/.bashrc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 -- 2.39.2