├── .gitignore ├── LICENSE ├── README.md ├── images └── unicorn.png ├── iterm └── Unicorn.itermcolors └── zsh └── unicorn.zsh-theme /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Caesar Nuzzolo 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Unicorn # 2 | 3 | My zsh theme inspired by [wild cherry](https://github.com/mashaal/wild-cherry) which I use with a very slightly modified [Dracula iTerm theme](https://draculatheme.com/iterm/). 4 | 5 | ![Unicorn](https://github.com/juliuscaesar/unicorn/blob/master/images/unicorn.png) 6 | 7 | ## Git Emoji key ## 8 | 🍕 dirty 9 | 10 | 🍺 clean 11 | 12 | 🐣 added/ready to commit 13 | 14 | ✏️ modified 15 | 16 | 💀 deleted 17 | 18 | 👻 untracked 19 | 20 | 🤖 renamed 21 | 22 | ⛄️ unmerged 23 | 24 | ☀️ ahead 25 | 26 | 🌩 behind 27 | 28 | ✈️ diverged 29 | -------------------------------------------------------------------------------- /images/unicorn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juliuscaesar/unicorn/fb2296c3a1c014746ecf4258bfedfcb12d819238/images/unicorn.png -------------------------------------------------------------------------------- /iterm/Unicorn.itermcolors: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Ansi 0 Color 6 | 7 | Alpha Component 8 | 1 9 | Blue Component 10 | 0.2814936637878418 11 | Color Space 12 | Calibrated 13 | Green Component 14 | 0.21291407942771912 15 | Red Component 16 | 0.20530563592910767 17 | 18 | Ansi 1 Color 19 | 20 | Alpha Component 21 | 1 22 | Blue Component 23 | 0.3333333432674408 24 | Color Space 25 | Calibrated 26 | Green Component 27 | 0.3333333432674408 28 | Red Component 29 | 1 30 | 31 | Ansi 10 Color 32 | 33 | Alpha Component 34 | 1 35 | Blue Component 36 | 0.48235294222831726 37 | Color Space 38 | Calibrated 39 | Green Component 40 | 0.98039215803146362 41 | Red Component 42 | 0.31372550129890442 43 | 44 | Ansi 11 Color 45 | 46 | Alpha Component 47 | 1 48 | Blue Component 49 | 0.54901963472366333 50 | Color Space 51 | Calibrated 52 | Green Component 53 | 0.98039215803146362 54 | Red Component 55 | 0.94509804248809814 56 | 57 | Ansi 12 Color 58 | 59 | Alpha Component 60 | 1 61 | Blue Component 62 | 0.97647058963775635 63 | Color Space 64 | Calibrated 65 | Green Component 66 | 0.57647061347961426 67 | Red Component 68 | 0.74117648601531982 69 | 70 | Ansi 13 Color 71 | 72 | Alpha Component 73 | 1 74 | Blue Component 75 | 0.7764706015586853 76 | Color Space 77 | Calibrated 78 | Green Component 79 | 0.47450980544090271 80 | Red Component 81 | 1 82 | 83 | Ansi 14 Color 84 | 85 | Alpha Component 86 | 1 87 | Blue Component 88 | 0.99215686321258545 89 | Color Space 90 | Calibrated 91 | Green Component 92 | 0.91372549533843994 93 | Red Component 94 | 0.54509806632995605 95 | 96 | Ansi 15 Color 97 | 98 | Alpha Component 99 | 1 100 | Blue Component 101 | 1 102 | Color Space 103 | Calibrated 104 | Green Component 105 | 1 106 | Red Component 107 | 1 108 | 109 | Ansi 2 Color 110 | 111 | Alpha Component 112 | 1 113 | Blue Component 114 | 0.48235294222831726 115 | Color Space 116 | Calibrated 117 | Green Component 118 | 0.98039215803146362 119 | Red Component 120 | 0.31372550129890442 121 | 122 | Ansi 3 Color 123 | 124 | Alpha Component 125 | 1 126 | Blue Component 127 | 0.54901963472366333 128 | Color Space 129 | Calibrated 130 | Green Component 131 | 0.98039215803146362 132 | Red Component 133 | 0.94509804248809814 134 | 135 | Ansi 4 Color 136 | 137 | Alpha Component 138 | 1 139 | Blue Component 140 | 0.97647058963775635 141 | Color Space 142 | Calibrated 143 | Green Component 144 | 0.57647061347961426 145 | Red Component 146 | 0.74117648601531982 147 | 148 | Ansi 5 Color 149 | 150 | Alpha Component 151 | 1 152 | Blue Component 153 | 0.7764706015586853 154 | Color Space 155 | Calibrated 156 | Green Component 157 | 0.47450980544090271 158 | Red Component 159 | 1 160 | 161 | Ansi 6 Color 162 | 163 | Alpha Component 164 | 1 165 | Blue Component 166 | 0.99215686321258545 167 | Color Space 168 | Calibrated 169 | Green Component 170 | 0.91372549533843994 171 | Red Component 172 | 0.54509806632995605 173 | 174 | Ansi 7 Color 175 | 176 | Alpha Component 177 | 1 178 | Blue Component 179 | 0.73333334922790527 180 | Color Space 181 | Calibrated 182 | Green Component 183 | 0.73333334922790527 184 | Red Component 185 | 0.73333334922790527 186 | 187 | Ansi 8 Color 188 | 189 | Alpha Component 190 | 1 191 | Blue Component 192 | 0.33333333333333331 193 | Color Space 194 | Calibrated 195 | Green Component 196 | 0.33333333333333331 197 | Red Component 198 | 0.33333333333333331 199 | 200 | Ansi 9 Color 201 | 202 | Alpha Component 203 | 1 204 | Blue Component 205 | 0.3333333432674408 206 | Color Space 207 | Calibrated 208 | Green Component 209 | 0.3333333432674408 210 | Red Component 211 | 1 212 | 213 | Background Color 214 | 215 | Alpha Component 216 | 1 217 | Blue Component 218 | 0.15977837145328522 219 | Color Space 220 | Calibrated 221 | Green Component 222 | 0.12215272337198257 223 | Red Component 224 | 0.11765811592340469 225 | 226 | Badge Color 227 | 228 | Alpha Component 229 | 0.5 230 | Blue Component 231 | 0.0 232 | Color Space 233 | Calibrated 234 | Green Component 235 | 0.0 236 | Red Component 237 | 1 238 | 239 | Bold Color 240 | 241 | Alpha Component 242 | 1 243 | Blue Component 244 | 0.90237069129943848 245 | Color Space 246 | Calibrated 247 | Green Component 248 | 0.90237069129943848 249 | Red Component 250 | 0.90237069129943848 251 | 252 | Cursor Color 253 | 254 | Alpha Component 255 | 1 256 | Blue Component 257 | 0.73333334922790527 258 | Color Space 259 | Calibrated 260 | Green Component 261 | 0.73333334922790527 262 | Red Component 263 | 0.73333334922790527 264 | 265 | Cursor Guide Color 266 | 267 | Alpha Component 268 | 0.25 269 | Blue Component 270 | 1 271 | Color Space 272 | Calibrated 273 | Green Component 274 | 0.9100000262260437 275 | Red Component 276 | 0.64999997615814209 277 | 278 | Cursor Text Color 279 | 280 | Alpha Component 281 | 1 282 | Blue Component 283 | 1 284 | Color Space 285 | Calibrated 286 | Green Component 287 | 1 288 | Red Component 289 | 1 290 | 291 | Foreground Color 292 | 293 | Alpha Component 294 | 1 295 | Blue Component 296 | 0.90032327175140381 297 | Color Space 298 | Calibrated 299 | Green Component 300 | 0.90032327175140381 301 | Red Component 302 | 0.90032327175140381 303 | 304 | Link Color 305 | 306 | Alpha Component 307 | 1 308 | Blue Component 309 | 0.67799997329711914 310 | Color Space 311 | Calibrated 312 | Green Component 313 | 0.27000001072883606 314 | Red Component 315 | 0.023000000044703484 316 | 317 | Selected Text Color 318 | 319 | Alpha Component 320 | 1 321 | Blue Component 322 | 1 323 | Color Space 324 | Calibrated 325 | Green Component 326 | 1 327 | Red Component 328 | 1 329 | 330 | Selection Color 331 | 332 | Alpha Component 333 | 1 334 | Blue Component 335 | 0.35294118523597717 336 | Color Space 337 | Calibrated 338 | Green Component 339 | 0.27843138575553894 340 | Red Component 341 | 0.26666668057441711 342 | 343 | 344 | 345 | -------------------------------------------------------------------------------- /zsh/unicorn.zsh-theme: -------------------------------------------------------------------------------- 1 | VIRTUAL_ENV_DISABLE_PROMPT=true 2 | 3 | # PROMPT 4 | if [ ! -n "${UNICORN_PROMPT_CHAR+1}" ]; then 5 | UNICORN_PROMPT_CHAR="\$" 6 | fi 7 | if [ ! -n "${UNICORN_PROMPT_ROOT+1}" ]; then 8 | UNICORN_PROMPT_ROOT=true 9 | fi 10 | 11 | 12 | # STATUS 13 | if [ ! -n "${UNICORN_STATUS_SHOW+1}" ]; then 14 | UNICORN_STATUS_SHOW=true 15 | fi 16 | if [ ! -n "${UNICORN_STATUS_EXIT_SHOW+1}" ]; then 17 | UNICORN_STATUS_EXIT_SHOW=false 18 | fi 19 | if [ ! -n "${UNICORN_STATUS_BG+1}" ]; then 20 | UNICORN_STATUS_BG=green 21 | fi 22 | if [ ! -n "${UNICORN_STATUS_ERROR_BG+1}" ]; then 23 | UNICORN_STATUS_ERROR_BG=red 24 | fi 25 | if [ ! -n "${UNICORN_STATUS_FG+1}" ]; then 26 | UNICORN_STATUS_FG=white 27 | fi 28 | 29 | # TIME 30 | if [ ! -n "${UNICORN_TIME_SHOW+1}" ]; then 31 | UNICORN_TIME_SHOW=true 32 | fi 33 | if [ ! -n "${UNICORN_TIME_BG+1}" ]; then 34 | UNICORN_TIME_BG=black 35 | fi 36 | if [ ! -n "${UNICORN_TIME_FG+1}" ]; then 37 | UNICORN_TIME_FG=magenta 38 | fi 39 | 40 | # VIRTUALENV 41 | if [ ! -n "${UNICORN_VIRTUALENV_SHOW+1}" ]; then 42 | UNICORN_VIRTUALENV_SHOW=true 43 | fi 44 | if [ ! -n "${UNICORN_VIRTUALENV_BG+1}" ]; then 45 | UNICORN_VIRTUALENV_BG=yellow 46 | fi 47 | if [ ! -n "${UNICORN_VIRTUALENV_FG+1}" ]; then 48 | UNICORN_VIRTUALENV_FG=white 49 | fi 50 | if [ ! -n "${UNICORN_VIRTUALENV_PREFIX+1}" ]; then 51 | UNICORN_VIRTUALENV_PREFIX=🐍 52 | fi 53 | 54 | # NVM 55 | if [ ! -n "${UNICORN_NVM_SHOW+1}" ]; then 56 | UNICORN_NVM_SHOW=false 57 | fi 58 | if [ ! -n "${UNICORN_NVM_BG+1}" ]; then 59 | UNICORN_NVM_BG=green 60 | fi 61 | if [ ! -n "${UNICORN_NVM_FG+1}" ]; then 62 | UNICORN_NVM_FG=white 63 | fi 64 | if [ ! -n "${UNICORN_NVM_PREFIX+1}" ]; then 65 | UNICORN_NVM_PREFIX="⬡ " 66 | fi 67 | 68 | # RVM 69 | if [ ! -n "${UNICORN_RVM_SHOW+1}" ]; then 70 | UNICORN_RVM_SHOW=true 71 | fi 72 | if [ ! -n "${UNICORN_RVM_BG+1}" ]; then 73 | UNICORN_RVM_BG=magenta 74 | fi 75 | if [ ! -n "${UNICORN_RVM_FG+1}" ]; then 76 | UNICORN_RVM_FG=white 77 | fi 78 | if [ ! -n "${UNICORN_RVM_PREFIX+1}" ]; then 79 | UNICORN_RVM_PREFIX=🐍 80 | fi 81 | 82 | # DIR 83 | if [ ! -n "${UNICORN_DIR_SHOW+1}" ]; then 84 | UNICORN_DIR_SHOW=true 85 | fi 86 | if [ ! -n "${UNICORN_DIR_BG+1}" ]; then 87 | UNICORN_DIR_BG=black 88 | fi 89 | if [ ! -n "${UNICORN_DIR_FG+1}" ]; then 90 | UNICORN_DIR_FG=blue 91 | fi 92 | if [ ! -n "${UNICORN_DIR_CONTEXT_SHOW+1}" ]; then 93 | UNICORN_DIR_CONTEXT_SHOW=false 94 | fi 95 | if [ ! -n "${UNICORN_DIR_EXTENDED+1}" ]; then 96 | UNICORN_DIR_EXTENDED=true 97 | fi 98 | 99 | # GIT 100 | if [ ! -n "${UNICORN_GIT_SHOW+1}" ]; then 101 | UNICORN_GIT_SHOW=true 102 | fi 103 | if [ ! -n "${UNICORN_GIT_BG+1}" ]; then 104 | UNICORN_GIT_BG=black 105 | fi 106 | if [ ! -n "${UNICORN_GIT_FG+1}" ]; then 107 | UNICORN_GIT_FG=yellow 108 | fi 109 | if [ ! -n "${UNICORN_GIT_EXTENDED+1}" ]; then 110 | UNICORN_GIT_EXTENDED=true 111 | fi 112 | 113 | # CONTEXT 114 | if [ ! -n "${UNICORN_CONTEXT_SHOW+1}" ]; then 115 | UNICORN_CONTEXT_SHOW=false 116 | fi 117 | if [ ! -n "${UNICORN_CONTEXT_BG+1}" ]; then 118 | UNICORN_CONTEXT_BG=black 119 | fi 120 | if [ ! -n "${UNICORN_CONTEXT_FG+1}" ]; then 121 | UNICORN_CONTEXT_FG=default 122 | fi 123 | 124 | # GIT PROMPT 125 | if [ ! -n "${UNICORN_GIT_PREFIX+1}" ]; then 126 | ZSH_THEME_GIT_PROMPT_PREFIX="[ " 127 | else 128 | ZSH_THEME_GIT_PROMPT_PREFIX=$UNICORN_GIT_PREFIX 129 | fi 130 | if [ ! -n "${UNICORN_GIT_SUFFIX+1}" ]; then 131 | ZSH_THEME_GIT_PROMPT_SUFFIX=" ]" 132 | else 133 | #ZSH_THEME_GIT_PROMPT_SUFFIX=$UNICORN_GIT_SUFFIX 134 | fi 135 | if [ ! -n "${UNICORN_GIT_DIRTY+1}" ]; then 136 | ZSH_THEME_GIT_PROMPT_DIRTY=" 🍕 " 137 | else 138 | ZSH_THEME_GIT_PROMPT_DIRTY=$UNICORN_GIT_DIRTY 139 | fi 140 | if [ ! -n "${UNICORN_GIT_CLEAN+1}" ]; then 141 | ZSH_THEME_GIT_PROMPT_CLEAN=" 🍺 " 142 | else 143 | ZSH_THEME_GIT_PROMPT_CLEAN=$UNICORN_GIT_CLEAN 144 | fi 145 | if [ ! -n "${UNICORN_GIT_ADDED+1}" ]; then 146 | ZSH_THEME_GIT_PROMPT_ADDED=" 🐣 " 147 | else 148 | ZSH_THEME_GIT_PROMPT_ADDED=$UNICORN_GIT_ADDED 149 | fi 150 | if [ ! -n "${UNICORN_GIT_MODIFIED+1}" ]; then 151 | ZSH_THEME_GIT_PROMPT_MODIFIED=" ✏️ " 152 | else 153 | ZSH_THEME_GIT_PROMPT_MODIFIED=$UNICORN_GIT_MODIFIED 154 | fi 155 | if [ ! -n "${UNICORN_GIT_DELETED+1}" ]; then 156 | ZSH_THEME_GIT_PROMPT_DELETED=" 💀 " 157 | else 158 | ZSH_THEME_GIT_PROMPT_DELETED=$UNICORN_GIT_DELETED 159 | fi 160 | if [ ! -n "${UNICORN_GIT_UNTRACKED+1}" ]; then 161 | ZSH_THEME_GIT_PROMPT_UNTRACKED=" 👻 " 162 | else 163 | ZSH_THEME_GIT_PROMPT_UNTRACKED=$UNICORN_GIT_UNTRACKED 164 | fi 165 | if [ ! -n "${UNICORN_GIT_RENAMED+1}" ]; then 166 | ZSH_THEME_GIT_PROMPT_RENAMED=" 🤖 " 167 | else 168 | ZSH_THEME_GIT_PROMPT_RENAMED=$UNICORN_GIT_RENAMED 169 | fi 170 | if [ ! -n "${UNICORN_GIT_UNMERGED+1}" ]; then 171 | ZSH_THEME_GIT_PROMPT_UNMERGED=" ⛄️ " 172 | else 173 | ZSH_THEME_GIT_PROMPT_UNMERGED=$UNICORN_GIT_UNMERGED 174 | fi 175 | if [ ! -n "${UNICORN_GIT_AHEAD+1}" ]; then 176 | ZSH_THEME_GIT_PROMPT_AHEAD=" ☀️ " 177 | else 178 | ZSH_THEME_GIT_PROMPT_AHEAD=$UNICORN_GIT_AHEAD 179 | fi 180 | if [ ! -n "${UNICORN_GIT_BEHIND+1}" ]; then 181 | ZSH_THEME_GIT_PROMPT_BEHIND=" 🌩 " 182 | else 183 | ZSH_THEME_GIT_PROMPT_BEHIND=$UNICORN_GIT_BEHIND 184 | fi 185 | if [ ! -n "${UNICORN_GIT_DIVERGED+1}" ]; then 186 | ZSH_THEME_GIT_PROMPT_DIVERGED=" ✈️ " 187 | else 188 | ZSH_THEME_GIT_PROMPT_DIVERGED=$UNICORN_GIT_PROMPT_DIVERGED 189 | fi 190 | 191 | # ------------------------------------------------------------------------------ 192 | # SEGMENT DRAWING 193 | # A few functions to make it easy and re-usable to draw segmented prompts 194 | # ------------------------------------------------------------------------------ 195 | 196 | CURRENT_BG='NONE' 197 | SEGMENT_SEPARATOR='' 198 | 199 | # Begin a segment 200 | # Takes two arguments, background and foreground. Both can be omitted, 201 | # rendering default background/foreground. 202 | prompt_segment() { 203 | local bg fg 204 | [[ -n $1 ]] && bg="%K{$1}" || bg="%k" 205 | [[ -n $2 ]] && fg="%F{$2}" || fg="%f" 206 | if [[ $CURRENT_BG != 'NONE' && $1 != $CURRENT_BG ]]; then 207 | echo -n " %{$bg%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR%{$fg%} " 208 | else 209 | echo -n "%{$bg%}%{$fg%} " 210 | fi 211 | CURRENT_BG=$1 212 | [[ -n $3 ]] && echo -n $3 213 | } 214 | 215 | # End the prompt, closing any open segments 216 | prompt_end() { 217 | if [[ -n $CURRENT_BG ]]; then 218 | echo -n " %{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR" 219 | else 220 | echo -n "%{%k%}" 221 | fi 222 | echo -n "%{%f%}" 223 | CURRENT_BG='' 224 | } 225 | 226 | # ------------------------------------------------------------------------------ 227 | # PROMPT COMPONENTS 228 | # Each component will draw itself, and hide itself if no information needs 229 | # to be shown 230 | # ------------------------------------------------------------------------------ 231 | 232 | # Context: user@hostname (who am I and where am I) 233 | context() { 234 | local user="$(whoami)" 235 | [[ "$user" != "$UNICORN_CONTEXT_DEFAULT_USER" || -n "$UNICORN_IS_SSH_CLIENT" ]] && echo -n "${user}@%m" 236 | } 237 | prompt_context() { 238 | [[ $UNICORN_CONTEXT_SHOW == false ]] && return 239 | 240 | local _context="$(context)" 241 | [[ -n "$_context" ]] && prompt_segment $UNICORN_CONTEXT_BG $UNICORN_CONTEXT_FG "$_context" 242 | } 243 | 244 | # Git 245 | prompt_git() { 246 | if [[ $UNICORN_GIT_SHOW == false ]] then 247 | return 248 | fi 249 | 250 | local ref dirty mode repo_path 251 | repo_path=$(git rev-parse --git-dir 2>/dev/null) 252 | 253 | if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then 254 | prompt_segment $UNICORN_GIT_BG $UNICORN_GIT_FG 255 | 256 | if [[ $UNICORN_GIT_EXTENDED == true ]] then 257 | echo -n $(git_prompt_info)$(git_prompt_status) 258 | else 259 | echo -n $(git_prompt_info) 260 | fi 261 | fi 262 | } 263 | 264 | prompt_hg() { 265 | local rev status 266 | if $(hg id >/dev/null 2>&1); then 267 | if $(hg prompt >/dev/null 2>&1); then 268 | if [[ $(hg prompt "{status|unknown}") = "?" ]]; then 269 | # if files are not added 270 | prompt_segment red white 271 | st='±' 272 | elif [[ -n $(hg prompt "{status|modified}") ]]; then 273 | # if any modification 274 | prompt_segment yellow black 275 | st='±' 276 | else 277 | # if working copy is clean 278 | prompt_segment green black 279 | fi 280 | echo -n $(hg prompt "☿ {rev}@{branch}") $st 281 | else 282 | st="" 283 | rev=$(hg id -n 2>/dev/null | sed 's/[^-0-9]//g') 284 | branch=$(hg id -b 2>/dev/null) 285 | if $(hg st | grep -Eq "^\?"); then 286 | prompt_segment red black 287 | st='±' 288 | elif $(hg st | grep -Eq "^(M|A)"); then 289 | prompt_segment yellow black 290 | st='±' 291 | else 292 | prompt_segment green black 293 | fi 294 | echo -n "☿ $rev@$branch" $st 295 | fi 296 | fi 297 | } 298 | 299 | # Dir: current working directory 300 | prompt_dir() { 301 | if [[ $UNICORN_DIR_SHOW == false ]] then 302 | return 303 | fi 304 | 305 | local dir='✨ ' 306 | local _context="$(context)" 307 | [[ $UNICORN_DIR_CONTEXT_SHOW == true && -n "$_context" ]] && dir="${dir}${_context}:" 308 | [[ $UNICORN_DIR_EXTENDED == true ]] && dir="${dir}%4(c:...:)%3c" || dir="${dir}%1~" 309 | prompt_segment $UNICORN_DIR_BG $UNICORN_DIR_FG $dir 310 | } 311 | 312 | # RVM: only shows RVM info if on a gemset that is not the default one 313 | prompt_rvm() { 314 | if [[ $UNICORN_RVM_SHOW == false ]] then 315 | return 316 | fi 317 | 318 | if which rvm-prompt &> /dev/null; then 319 | if [[ ! -n $(rvm gemset list | grep "=> (default)") ]] 320 | then 321 | prompt_segment $UNICORN_RVM_BG $UNICORN_RVM_FG $UNICORN_RVM_PREFIX" $(rvm-prompt i v g)" 322 | fi 323 | fi 324 | } 325 | 326 | # Virtualenv: current working virtualenv 327 | prompt_virtualenv() { 328 | if [[ $UNICORN_VIRTUALENV_SHOW == false ]] then 329 | return 330 | fi 331 | 332 | local virtualenv_path="$VIRTUAL_ENV" 333 | if [[ -n $virtualenv_path && -n $VIRTUAL_ENV_DISABLE_PROMPT ]]; then 334 | prompt_segment $UNICORN_VIRTUALENV_BG $UNICORN_VIRTUALENV_FG $UNICORN_VIRTUALENV_PREFIX" $(basename $virtualenv_path)" 335 | fi 336 | } 337 | 338 | # NVM: Node version manager 339 | prompt_nvm() { 340 | if [[ $UNICORN_NVM_SHOW == false ]] then 341 | return 342 | fi 343 | 344 | $(type nvm >/dev/null 2>&1) || return 345 | 346 | local nvm_prompt 347 | nvm_prompt=$(node -v 2>/dev/null) 348 | [[ "${nvm_prompt}x" == "x" ]] && return 349 | nvm_prompt=${nvm_prompt:1} 350 | prompt_segment $UNICORN_NVM_BG $UNICORN_NVM_FG $UNICORN_NVM_PREFIX$nvm_prompt 351 | } 352 | 353 | prompt_time() { 354 | if [[ $UNICORN_TIME_SHOW == false ]] then 355 | return 356 | fi 357 | 358 | prompt_segment $UNICORN_TIME_BG $UNICORN_TIME_FG '🦄 ✨ %D{%H:%M:%S}' 359 | } 360 | 361 | # Status: 362 | # - was there an error 363 | # - am I root 364 | # - are there background jobs? 365 | prompt_status() { 366 | if [[ $UNICORN_STATUS_SHOW == false ]] then 367 | return 368 | fi 369 | 370 | local symbols 371 | symbols=() 372 | [[ $RETVAL -ne 0 && $UNICORN_STATUS_EXIT_SHOW != true ]] && symbols+="💣 " 373 | [[ $RETVAL -ne 0 && $UNICORN_STATUS_EXIT_SHOW == true ]] && symbols+="💣 $RETVAL" 374 | [[ $UID -eq 0 ]] && symbols+="%{%F{yellow}%}⚡%f" 375 | [[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="⚙" 376 | 377 | if [[ -n "$symbols" && $RETVAL -ne 0 ]] then 378 | prompt_segment $UNICORN_STATUS_ERROR_BG $UNICORN_STATUS_FG "$symbols" 379 | elif [[ -n "$symbols" ]] then 380 | prompt_segment $UNICORN_STATUS_BG $UNICORN_STATUS_FG "$symbols" 381 | fi 382 | 383 | } 384 | 385 | # Prompt Character 386 | prompt_char() { 387 | local bt_prompt_char 388 | 389 | if [[ ${#UNICORN_PROMPT_CHAR} -eq 1 ]] then 390 | bt_prompt_char=" 👉 " 391 | fi 392 | 393 | if [[ $UNICORN_PROMPT_ROOT == true ]] then 394 | bt_prompt_char="%(!.%F{red}#.%F{green}${bt_prompt_char}%f)" 395 | fi 396 | 397 | echo -n $bt_prompt_char 398 | } 399 | 400 | # ------------------------------------------------------------------------------ 401 | # MAIN 402 | # Entry point 403 | # ------------------------------------------------------------------------------ 404 | 405 | build_prompt() { 406 | RETVAL=$? 407 | prompt_time 408 | prompt_status 409 | prompt_rvm 410 | prompt_virtualenv 411 | prompt_nvm 412 | prompt_context 413 | prompt_dir 414 | prompt_git 415 | # prompt_hg 416 | prompt_end 417 | } 418 | 419 | PROMPT=' 420 | %{%f%b%k%}$(build_prompt) 421 | %{${fg_bold[default]}%}$(prompt_char) %{$reset_color%}' 422 | --------------------------------------------------------------------------------