7 # Hide exit code after a blank line.
8 # Inspired from https://github.com/robbyrussell/oh-my-zsh/blob/66b7fe1b27637feba61a4b47e113b18b69432bf2/themes/dieter.zsh-theme
9 # The difference is that $get_exitcode is set to a command name which should be
10 # called. There's a layer of indirection.
14 function accept-line-or-clear-warning () {
15 if [[ -z $BUFFER ]]; then
18 get_exitcode=parse_exitcode
22 zle -N accept-line-or-clear-warning
23 bindkey '^M' accept-line-or-clear-warning
28 # This function sets the entire prompt.
29 # It requires that prompt_subst is set.
31 _username="${C_BYELLOW}%n${C_NO}"
32 _machine="${C_BRED}%m${C_NO}"
34 # Git status in the pwd, if applicable
35 if [[ -n $__ZSH_GIT_BASEDIR ]]; then
36 _basedir="${C_GREEN}%20<..<${__ZSH_GIT_BASEDIR}%<<${C_NO}"
37 _branch="${C_MAGENTA}@${__ZSH_GIT_BRANCH}${__ZSH_GIT_ACTION}${C_NO}"
38 _status="${__ZSH_GIT_STATUS}"
39 _subdir="${C_GREEN}/%15<..<${__ZSH_GIT_SUBDIR}%<<${C_NO}"
40 _path="${_basedir}${_branch}${_status}${_subdir}"
42 _path="${C_GREEN}%25<..<%~%<<${C_NO}"
46 echo ${_username}@${_machine}:${_path}
51 # Now, the prompt itself
53 PROMPT='$($get_exitcode)$(setprompt)$ '
54 RPROMPT='$(battery_level)'