forked from anishathalye/dotfiles_template
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdigitalraven.zsh-theme
More file actions
136 lines (115 loc) · 3.17 KB
/
digitalraven.zsh-theme
File metadata and controls
136 lines (115 loc) · 3.17 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# Not sure if this can properly be called a "theme"; it's more a series of helper functions.
# First, set the prompt
precmd() { myprompt; }
# Use terminal-notifier for alerts. iTerm has a built in 'watch' but this function works
# for background processes, and can run multiple times in the same session.
alert() {
if [[ ! -e /usr/local/bin/terminal-notifier ]]; then
echo "Terminal notifier not found"
fi
start=$(date +%s)
command $@
dur=$(echo "$(date +%s) - $start" | bc)
terminal-notifier -title "iTerm" -message "Finished: $1 took $dur seconds to run"
}
# Use pygmentize to add syntax highlighting in less
cless() {
if [[ $# -eq 0 ]]; then
pygmentize -g -O style=solarized-dark |less -R
else
pygmentize -g -O style=solarized-dark "$1" |less -R
fi
}
get_python_version() {
local version=$(python -V 2>&1 | grep -Po '(?<=Python )(.+)')
if [[ -z "$version" ]]
then
version=''
fi
echo $version
}
get_venv_name(){
local venv_name=""
# If we're in a venv, get a good name forit
if (( ${+VIRTUAL_ENV} )); then
starter="🐍$(get_python_version)"
venv_id="$(basename "$VIRTUAL_ENV")"
venv_name="%F{green}(${venv_id%-*} $starter)%f "
fi
echo $venv_name
}
krb_ticket_prompt() {
local ticket=""
# Highlight when we don't have a Kerberos ticket
if klist -s 2>/dev/null; then
ticket=""
else
ticket="%B%F{magenta}✨KRB %f%b"
fi
echo $ticket
}
seasonal_chevrons() {
local date=$(date)
local chevrons="❯❯❯"
case $date in
# spring
*Mar*|*Apr*|*May*)
chevrons="%F{cyan}❯%F{green}❯%F{yellow}❯%f"
;;
# summer
*Jun*|*Jul*|*Aug*)
chevrons="%F{green}❯%F{yellow}❯%F{red}❯%f"
;;
# fall
*Sep*|*Oct*|*Nov*)
chevrons="%F{yellow}❯%F{red}❯%F{magenta}❯%f"
;;
# winter
*Dec*|*Jan*|*Feb*)
chevrons="%F{magenta}❯%F{cyan}❯%F{green}❯%f"
;;
*)
;;
esac
echo -en $chevrons
}
# Prompt, with conditions.
myprompt() {
local EXIT="$?"
PS1="$(krb_ticket_prompt) $(get_venv_name)"
# Indicate last command status with colour and a simple unicode indicator
if [[ $EXIT != 0 ]]; then
PS1+="%F{red}✘ $EXIT "
else
PS1+="%F{cyan}✔ "
fi
# Additional indicators for working as root or other user.
if [[ $UID -eq 0 ]]; then
# Add lightning bolt and coloured username
PS1+="⚡️ %F{magenta}%B"
elif [[ "$(id -un)" != "$(basename $HOME)" ]]; then
# Add coloured username
PS1+="✨ %F{magenta}"
fi
PS1+="%n%b%f@"
# If we're remote, add the next higher level domain name to the machine name
if [[ -n "$SSH_CLIENT" ]]; then
PS1+="%2m"
else
PS1+="%m"
fi
# Use ~ to indicate home directory in path
PS1+=":%~"
# Add chevrons in place of typical terminator
PS1+="$(seasonal_chevrons) "
}
# Use zsh on remote hosts where it's available but not default
ssh() {
command ssh -t $@ "zsh -l"
}
# Use VLC's stream-ripper to take a stream of a radio programme from BOB and render to an MP3.
bobrip() {
VLCCMD="/Applications/VLC.app/Contents/MacOS/VLC -I rc -v $1 --sout "#transcode{vcodec=none,acodec=mp3,ab=128,channels=2,samplerate=44100}:file{dst=$2}""
echo VLC Command: $VLCCMD
$VLCCMD
}