zsh: show git branch in prompt
This commit is contained in:
parent
7dca2eb32b
commit
690d76a57b
|
@ -1,6 +1,16 @@
|
|||
# Enable colors and change prompt:
|
||||
git_prompt() {
|
||||
local branch="$(git symbolic-ref HEAD 2> /dev/null | cut -d'/' -f3-)"
|
||||
local branch_truncated="${branch:0:30}"
|
||||
if (( ${#branch} > ${#branch_truncated} )); then
|
||||
branch="${branch_truncated}..."
|
||||
fi
|
||||
|
||||
[ -n "${branch}" ] && echo " (${branch})"
|
||||
}
|
||||
|
||||
setopt PROMPT_SUBST
|
||||
autoload -U colors && colors # Load colors
|
||||
PROMPT='%1~%f%b $ '
|
||||
PROMPT='%1~%f%b%F{blue}$(git_prompt)%f $ '
|
||||
|
||||
# gpg key for ssh authentication
|
||||
export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"
|
||||
|
|
Loading…
Reference in New Issue