blob: db66644d3a2a2bba510780e2ece77800c01e7d0e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#!/bin/zsh
unset PROMPT
setopt PROMPT_SUBST
prompt_segment() {
content="$1"
[ -z "$content" ] && return
echo "%{\e[90m%}${content}%{\e[30m%} -> %{\e[0m%}"
}
prompt_mod_git_info() {
git rev-parse --is-inside-work-tree 1> /dev/null 2> /dev/null || return
prompt_segment "git $(git rev-parse --abbrev-ref HEAD)"
}
# only display hostname in prompt if connected over SSH
[ -n "$SSH_CLIENT" ] && PROMPT+="$(prompt_segment '%m')"
# working directory
PROMPT+="$(prompt_segment '%c')"
# git info (if in repo)
PROMPT+="\$(prompt_mod_git_info)"
|