-
-
Save tubaterry/d09c7bbd8000750fcce4e9f943e55eca to your computer and use it in GitHub Desktop.
# Don't forget to set COMPLETION_WAITING_DOTS=false in your .zshrc - it doesn't always play nice with multiline prompts | |
# Troubleshooting breadcrumbs: | |
# Prompt design: http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html#Prompt-Expansion | |
# Zsh Line Editor (zle): http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html | |
#Broken down into its component pieces because I was tired of looking at a nearly incomprehensible string | |
FG_USER_BADGE=$'%{$fg_bold[green]%}%n@%m%{$reset_color%}' | |
FG_TIMESTAMP=$'%{$fg[blue]%}%D{[%X]}%{$reset_color%}' | |
FG_CWD_DISPLAY=$'%{$fg[white]%}[%~]%{$reset_color%}' | |
FG_SHELL_DISPLAY=$'%{$fg_bold[blue]%}%#%{$reset_color%}' | |
#We use the %G to 'glitch' zsh into forcing the string to take up 3 character widths %{string%3G%} | |
FG_GUNS_WAITING=$'%(?.%{πππ%3G%}.%{ππ π%3G%})' | |
FG_GUNS_FIRED=$'%(?.%{πππ%3G%}.%{ππ π%3G%})' | |
FG_GUNS_DISPLAY=$FG_GUNS_WAITING | |
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[green]%}[" | |
ZSH_THEME_GIT_PROMPT_SUFFIX="]%{$reset_color%}" | |
ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg[red]%}*%{$fg[green]%}" | |
ZSH_THEME_GIT_PROMPT_CLEAN="" | |
#Setup prompt lol | |
function ββ¨οΈ () { | |
PROMPT=$''"$FG_USER_BADGE $FG_TIMESTAMP $FG_CWD_DISPLAY"' $(git_prompt_info) | |
'"$FG_GUNS_DISPLAY $FG_SHELL_DISPLAY " | |
} | |
function ππ«π₯π₯ () { | |
# Shoot them finger guns | |
FG_GUNS_DISPLAY=$FG_GUNS_FIRED | |
zle accept-line | |
ββ¨οΈ | |
# Reload em | |
zle reset-prompt | |
FG_GUNS_DISPLAY=$FG_GUNS_WAITING | |
ββ¨οΈ | |
# I've got some things in this file like a $TIMESTAMP and $SHORTRAND so i always have | |
# Easy access to make a unique filename or temp folder or whatevs. | |
if [ -f ~/.oh-my-zsh/custom/handy-vars.zsh ]; then | |
source ~/.oh-my-zsh/custom/handy-vars.zsh | |
fi | |
} | |
PROMPT="" | |
ββ¨οΈ | |
zle -N ππ«π₯π₯ | |
bindkey '^M' ππ«π₯π₯ |
handy-vars.zsh isn't necessary so let's If it. (I keep stuff in there like TODAY=(date +%Y%m%d)
to grease stuff like making temp files (touch tempfile-$TODAY.yaml
or whatever) or other vars I want to update more often than once-per-terminal-session)
Fuckin' around to make it more readable. Now also solely reliant on built-ins.
Trying this out on a High Sierra machine... is it supposed to do anything besides fingerguns-up on shell start, and fingerguns-right after that? That's all I'm seeing. No thumbs down or other special effects.
@ejheil i think I had something else interfering earlier cuz i had the same behavior once i switched to a new machine. got it updated so it behaves better now, sorry it took so long to get back to you!
un-executed prompt, $? is 0: guns up (let's do this)
executed prompt, $? is 0: cool guy finger guns
$? is non-zero: angry thumbs down (i decided i didn't want that one to change so i don't erase the visual cue for a previously-failed command)
Works great now, thanks!
Today's update: 'refactor' the variable names so I don't do dingus stuff like overwriting something as heavily used as $USER
.
All the internal variables are now prefixed with FG_
and USER
in particular is now FG_USER_BADGE
.
Hooray for scoping.
Finally took the time to figure out why shell completion was eating the end of the prompt: there's a bug in ZSH on mac that breaks COMPLETION_WAITING_DOTS.
ohmyzsh/ohmyzsh#6226