Tag Archive for git

oh-my-zsh p10k git branch name shortened

I use this and I experiened like this:

The branch name is shortened and can’t read.

So I have to change this line in `~/.p10k.zs` The line is AROUND at line 400 :

from: (( $#branch > 32 )) && branch[13,-13]="…" # <-- this line

to: (( $#branch > 40 )) && branch[20,-20]="…" # <-- this line.
It the branch name is over 40 char, It wil be cut from the 20th chat til the last 20 char.

src: https://stackoverflow.com/questions/61667666/keep-git-branch-name-untruncated-in-shell-using-p10k-oh-my-zsh-theme

Ubuntu WSL add git brach name to promt

you have to mofify ~/.basrc from that:

 

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt

to

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;31m\]$(parse_git_branch)\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(parse_git_branch)\$ '
fi
#unset color_prompt force_color_prompt

Modification details:

  • add $(parse_git_branch)\[\033[00m\] 
  • and COMMENT the unset color_prompt force_color_prompt line

src: https://askubuntu.com/questions/730754/how-do-i-show-the-git-branch-with-colours-in-bash-prompt