bash: update git prompt
Prithu Goswami pg@prithu.dev
Fri, 01 Nov 2024 13:31:25 +0530
1 files changed,
18 insertions(+),
1 deletions(-)
jump to
M
home/.bashrc
→
home/.bashrc
@@ -123,7 +123,24 @@ # š (Right arrow shorter)
# š”² (Right arrow shorter) # āÆ (angle bracket) # āŗ (angle bracket) -PS1="\e[01;34m[\[\e[1;00m\]\w\[\e[01;34m\]]\[\e[01;00m\]\[\e[01;32m\]\$(git branch 2>/dev/null | grep '^*' | colrm 1 2 | sed 's/^/ (/' | sed 's/$/)/') \[\e[01;00m\]\nš " +_branch() { + git rev-parse --abbrev-ref HEAD 2>/dev/null +} +_repo(){ + basename `git rev-parse --show-toplevel 2>/dev/null` 2>/dev/null +} + +_repbra() { + r=$(_repo) + b=$(_branch) + if [ "$r" -a "$b" ] + then + echo `_repo` ā¢ `_branch` + fi +} + + +PS1="\e[01;34m[\[\e[1;00m\]\w\[\e[01;34m\]]\[\e[01;00m\]\[\e[01;32m\] \$(_repbra) \[\e[01;00m\]\nš " # PS1="\w\[\033[01;34m\]\[\033[01;00m\]\[\033[01;32m\]\$(git branch 2>/dev/null | grep '^*' | colrm 1 2 | sed 's/^/ (/' | sed 's/$/)/') \[\033[01;00m\]āŗ " # PS1='\[\033[01;32m\]ą„ [\[\033[37m\]\w\[\033[32m\]]\[\033[00m\] '