adcb5c5e07850c0b8c05f61ca5cb7534dc434c2b

Author
Bartek Pacia <barpac02@gmail.com>
Committer
GitHub <noreply@github.com>
Date

Message

style(mlh): update the official theme of Major League Hacking (#9971)

* allow for customization of RPROMPT (exit code and timestamp)

* improve code and comments

Diff

 1diff --git a/themes/mlh.zsh-theme b/themes/mlh.zsh-theme
 2index a21a546bc77d5e7b2b8273dfa21c2a5eadac3dde..33f238ed9349abb5043103ff6f8bee6ecc1009ad 100644
 3--- a/themes/mlh.zsh-theme
 4+++ b/themes/mlh.zsh-theme
 5@@ -1,11 +1,12 @@
 6-# The Official Theme of 
 7-##     ## ##       ##     ## 
 8-###   ### ##       ##     ## 
 9-#### #### ##       ##     ## 
10-## ### ## ##       ######### 
11-##     ## ##       ##     ## 
12-##     ## ##       ##     ## 
13-##     ## ######## ##     ## 
14+# The Official Theme of Major League Hacking
15+
16+##     ## ##       ##     ##
17+###   ### ##       ##     ##
18+#### #### ##       ##     ##
19+## ### ## ##       #########
20+##     ## ##       ##     ##
21+##     ## ##       ##     ##
22+##     ## ######## ##     ##
23 
24 # # # # # # # # # # # # # # # # # #
25 # # # Feel free to customize! # # #
26@@ -13,11 +14,17 @@
27 
28 # To easily discover colors and their codes, type `spectrum_ls` in the terminal
29 
30+# enable or disable particular elements
31+PRINT_EXIT_CODE=true
32+PRINT_TIME=true
33+
34+# symbols
35 AT_SYMBOL=" @ "
36 IN_SYMBOL=" in "
37 ON_SYMBOL=" on "
38-SYMBOL="$"
39+SHELL_SYMBOL="$"
40 
41+# colors
42 USER_COLOR="%F{001}"
43 DEVICE_COLOR="%F{033}"
44 DIR_COLOR="%F{220}"
45@@ -25,35 +32,39 @@ BRANCH_COLOR="%F{001}"
46 TIME_COLOR="%F{033}"
47 
48 username() {
49-    echo "$USER_COLOR%n%f"
50+  echo "$USER_COLOR%n%f"
51 }
52 
53-# Returns device name 
54+# Prints device name
55 device() {
56-    echo "$DEVICE_COLOR%m%f"
57+  echo "$DEVICE_COLOR%m%f"
58 }
59 
60-# The current directory
61+# Prints the current directory
62 directory() {
63-    echo "$DIR_COLOR%1~%f"
64+  echo "$DIR_COLOR%1~%f"
65 }
66 
67-# Current time with milliseconds
68+# Prints current time
69 current_time() {
70-    echo "$TIME_COLOR%*%f"
71+  if [ "$PRINT_TIME" = true ]; then
72+    echo " $TIME_COLOR%*%f"
73+  fi
74 }
75 
76-# Return status of the last command
77-return_status() {
78-    echo "%(?..%F{001}out %?)%f"
79+# Prints exit code of the last executed command
80+exit_code() {
81+  if [ "$PRINT_EXIT_CODE" = true ]; then
82+    echo "%(?..%F{001}exit %?)%f"
83+  fi
84 }
85 
86-# Set the git_prompt_info text
87+# Set git_prompt_info text
88 ZSH_THEME_GIT_PROMPT_PREFIX="${ON_SYMBOL}${BRANCH_COLOR}"
89 ZSH_THEME_GIT_PROMPT_SUFFIX="%f"
90 ZSH_THEME_GIT_PROMPT_DIRTY=""
91 ZSH_THEME_GIT_PROMPT_CLEAN=""
92 
93 # %B and %b make the text bold
94-PROMPT='%b$(username)$AT_SYMBOL$(device)$IN_SYMBOL$(directory)$(git_prompt_info)%b $SYMBOL '
95-RPROMPT="$(return_status) $(current_time)"
96+PROMPT='%b$(username)$AT_SYMBOL$(device)$IN_SYMBOL$(directory)$(git_prompt_info)%b $SHELL_SYMBOL '
97+RPROMPT="$(exit_code)$(current_time)"