forked from acornejo/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sh.prompt
67 lines (61 loc) · 1.89 KB
/
sh.prompt
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/sh
__ssh_prompt() {
if [ -n "$SSH_CONNECTION" ] && [ -z "$STY" ]; then
echo -n "ssh@"
fi
}
__git_prompt() {
if type __git_ps1 | grep function >/dev/null 2>&1; then
local branch
branch=$(__git_ps1 %s)
if [ -n "$branch" ]; then
echo -n "$1 on $2$branch"
fi
fi
}
sh_prompt() {
if [ -z "$ZSH_VERSION" ]; then
local CS="\["
local CE="\]"
local userString="\u"
local hostString="\h"
local pathString="\w"
else
local CS="%{"
local CE="%}"
local userString="%n"
local hostString="%m"
local pathString="%~"
fi
if [ "$TERM" != "dumb" ]; then
if hash tput 2>/dev/null && tput setaf 1 > /dev/null 2>&1; then
# Solarized colors, taken from http://git.io/solarized-colors.
local reset="$CS$(tput sgr0)$CE"
local black="$CS$(tput setaf 0)$CE"
local blue="$CS$(tput setaf 33)$CE"
local cyan="$CS$(tput setaf 37)$CE"
local green="$CS$(tput setaf 64)$CE"
local orange="$CS$(tput setaf 166)$CE"
local purple="$CS$(tput setaf 125)$CE"
local red="$CS$(tput setaf 124)$CE"
local violet="$CS$(tput setaf 61)$CE"
local white="$CS$(tput setaf 15)$CE"
local yellow="$CS$(tput setaf 136)$CE"
else
local reset="$CS\033[0;0m$CE"
local black="$CS\033[0;30m$CE"
local red="$CS\033[0;31m$CE"
local green="$CS\033[0;32m$CE"
local orange="$CS\033[0;33m$CE"
local yellow="$CS\033[1;33m$CE"
local blue="$CS\033[0;34m$CE"
local purple="$CS\033[0;35m$CE"
local violet="$CS\033[1;35m$CE"
local cyan="$CS\033[0;36m$CE"
local white="$CS\033[0;37m$CE"
fi
fi
local sshString="\$(__ssh_prompt)"
local gitString="\$(__git_prompt '$white' '$yellow')"
echo "${cyan}[${orange}${userString}${white} at ${white}${sshString}${blue}${hostString}${white} in ${green}${pathString}${gitString}${cyan}]\n${reset}"
}