blob: 7dde93231f454da86dc39ca09043de2614c8d8af (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#!/bin/sh
fmt_esc() {
printf "%s$1%s" "$eo" "$ec"
}
fmt_segment() {
content="$1"
[ -z "$content" ] && return
printf '%s%s%s -> %s' "$(fmt_esc '\e[90m')" "${content}" "$(fmt_esc '\e[30m')" "$(fmt_esc '\e[0m')"
}
fmt_environment() {
content="$1"
[ -z "$content" ] && return
printf '%s(%s%s%s)%s ' "$(fmt_esc '\e[30;40m')" "$(fmt_esc '\e[97m')" "$content" "$(fmt_esc '\e[30;40m')" "$(fmt_esc '\e[0m')"
}
[ -n "$1" ] && fmt_environment "$1"
fmt_environment "$VIRTUAL_ENV_PROMPT"
# only display hostname in prompt if connected over SSH
[ -n "$SSH_CLIENT" ] && fmt_segment "$(hostname)"
# current working directory
here="$PWD"
[ "$here" = "$HOME" ] && here="~"
fmt_segment "$(basename "$here")"
# git status
git rev-parse --is-inside-work-tree 1> /dev/null 2> /dev/null && fmt_segment "git $(git rev-parse --abbrev-ref HEAD 2> /dev/null)"
# exit happily
exit 0
|