mlh.zsh-theme
2233 bytes
1# The Official Theme of Major League Hacking
2
3## ## ## ## ##
4### ### ## ## ##
5#### #### ## ## ##
6## ### ## ## #########
7## ## ## ## ##
8## ## ## ## ##
9## ## ######## ## ##
10
11# # # # # # # # # # # # # # # # # #
12# # # Feel free to customize! # # #
13# # # # # # # # # # # # # # # # # #
14
15# To customize symbols (e.g MLH_AT_SYMBOL), simply set them as environment variables
16# for example in your ~/.zshrc file, like this:
17# MLH_AT_SYMBOL=" at "
18#
19# Settings *must* be set before sourcing oh-my-zsh.sh the .zshrc file.
20#
21# To easily discover colors and their codes, type `spectrum_ls` in the terminal
22
23# right prompt default settings
24if [ -z "$MLH_PRINT_EXIT_CODE" ]; then
25 MLH_PRINT_EXIT_CODE=true
26fi
27
28if [ -z "$MLH_PRINT_TIME" ]; then
29 MLH_PRINT_TIME=false
30fi
31
32# left prompt symbols default settings
33
34if [ -z "$MLH_AT_SYMBOL" ]; then
35 MLH_AT_SYMBOL="@"
36fi
37
38if [ -z "$MLH_IN_SYMBOL" ]; then
39 MLH_IN_SYMBOL=" in "
40fi
41
42if [ -z "$MLH_ON_SYMBOL" ]; then
43 MLH_ON_SYMBOL=" on "
44fi
45
46if [ -z "$MLH_SHELL_SYMBOL" ]; then
47 MLH_SHELL_SYMBOL="$ "
48fi
49
50if [ -z "$MLH_SHELL_SYMBOL_ROOT" ]; then
51 MLH_SHELL_SYMBOL_ROOT="# "
52fi
53
54# colors
55USER_COLOR="%F{001}"
56DEVICE_COLOR="%F{033}"
57DIR_COLOR="%F{220}"
58BRANCH_COLOR="%F{001}"
59TIME_COLOR="%F{033}"
60
61username() {
62 echo "$USER_COLOR%n%f"
63}
64
65# Prints device name
66device() {
67 echo "$DEVICE_COLOR%m%f"
68}
69
70# Prints the current directory
71directory() {
72 echo "$DIR_COLOR%1~%f"
73}
74
75# Prints current time
76current_time() {
77 if [ "$MLH_PRINT_TIME" = true ]; then
78 echo " $TIME_COLOR%*%f"
79 fi
80}
81
82# Prints exit code of the last executed command
83exit_code() {
84 if [ "$MLH_PRINT_EXIT_CODE" = true ]; then
85 echo "%(?..%F{001}exit %?)%f"
86 fi
87}
88
89prompt_end() {
90 if [ "$UID" -eq 0 ]; then
91 printf "\n$MLH_SHELL_SYMBOL_ROOT"
92 else
93 printf "\n$MLH_SHELL_SYMBOL"
94 fi
95}
96
97# Set git_prompt_info text
98ZSH_THEME_GIT_PROMPT_PREFIX="${MLH_ON_SYMBOL}${BRANCH_COLOR}"
99ZSH_THEME_GIT_PROMPT_SUFFIX="%f"
100ZSH_THEME_GIT_PROMPT_DIRTY=""
101ZSH_THEME_GIT_PROMPT_CLEAN=""
102
103# %B and %b make the text bold
104PROMPT='%b$(username)$MLH_AT_SYMBOL$(device)$MLH_IN_SYMBOL$(directory)$(git_prompt_info)%b$(prompt_end)'
105RPROMPT="$(exit_code)$(current_time)"