all repos — dotfiles @ b8a84fa92372c8601a973a253fdc95c4083f9bba

linux dotfiles

bash: update git prompt
Prithu Goswami pg@prithu.dev
Fri, 01 Nov 2024 13:31:25 +0530
commit

b8a84fa92372c8601a973a253fdc95c4083f9bba

parent

4fa5cb791c9ab7123240d51dd5f4dfd184789966

1 files changed, 18 insertions(+), 1 deletions(-)

jump to
M home/.bashrchome/.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\] '