Last active
August 29, 2015 14:25
-
-
Save dhuynh/7ecb585872d65f0ade68 to your computer and use it in GitHub Desktop.
Table Flip
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add-zsh-hook precmd mtmdd_precmd | |
add-zsh-hook preexec mtmdd_preexec | |
# Table flip | |
typeset -A table; | |
table=( | |
flip "%{$fg[yellow]%}%? %{$fg[red]%}(╯°□°)╯︵ ┻━┻%{$reset_color%}" | |
upright "%{$fg[yellow]%}┳━┳ ~ ◞(◦_◦◞)%{$reset_color%}" | |
caine "%{$fg[green]%}(⌐•_•)%{$reset_color%}" | |
) | |
mtmdd_precmd() { | |
if [[ $? -ne 0 ]]; then | |
export table_status="flip" | |
fi | |
vcs_info | |
} | |
mtmdd_preexec() { | |
if [[ $table_status = "flip" ]]; then | |
export table_status="upright" | |
elif [[ $table_status = "upright" ]]; then | |
export table_status="caine" | |
fi | |
} | |
right_prompt() { | |
printf '%s' "${table[${table_status:-caine}]}" | |
} | |
PROMPT='$(left_prompt)' | |
PROMPT2="${cur_cmd}> " | |
RPROMPT='$(right_prompt)' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment