diff options
author | xero <x@xero.nu> | 2017-01-23 09:14:23 -0500 |
---|---|---|
committer | xero <x@xero.nu> | 2017-01-23 09:14:23 -0500 |
commit | 85107d22ed192d08dc0b0d5a6c505f3dbc57295f (patch) | |
tree | f1c583838cb0809857cb998d8224ec82eba005e6 /zsh | |
parent | ced6ed81c51519af239b67cf0d276796440aedd3 (diff) | |
download | dotfiles_ascii-85107d22ed192d08dc0b0d5a6c505f3dbc57295f.tar.xz dotfiles_ascii-85107d22ed192d08dc0b0d5a6c505f3dbc57295f.zip |
new multi-style zsh prompt
Diffstat (limited to '')
-rw-r--r-- | zsh/.zsh/prompt.zsh | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/zsh/.zsh/prompt.zsh b/zsh/.zsh/prompt.zsh new file mode 100644 index 0000000..8035914 --- /dev/null +++ b/zsh/.zsh/prompt.zsh @@ -0,0 +1,105 @@ +# ██ +# ░██ +# ██████ ██████░██ +# ░░░░██ ██░░░░ ░██████ +# ██ ░░█████ ░██░░░██ +# ██ ░░░░░██░██ ░██ +# ██████ ██████ ░██ ░██ +# ░░░░░░ ░░░░░░ ░░ ░░ +# +# ▓▓▓▓▓▓▓▓▓▓ +# ░▓ author ▓ xero <x@xero.nu> +# ░▓ code ▓ http://code.xero.nu/dotfiles +# ░▓ mirror ▓ http://git.io/.files +# ░▓▓▓▓▓▓▓▓▓▓ +# ░░░░░░░░░░ + +#ICO_DIRTY="⚡" +#ICO_DIRTY="↯" +ICO_DIRTY="*" +#ICO_AHEAD="↑" +ICO_AHEAD="🠙" +#ICO_AHEAD="▲" +#ICO_BEHIND="↓" +ICO_BEHIND="🠛" +#ICO_BEHIND="▼" +ICO_DIVERGED="⥮" +COLOR_ROOT="%F{red}" +COLOR_USER="%F{cyan}" +COLOR_NORMAL="%F{white}" +PROMPT_STYLE="classic" + +#█▓▒░ allow functions in the prompt +setopt PROMPT_SUBST +autoload -Uz colors && colors + +#█▓▒░ colors for permissions +if [[ "$EUID" -ne "0" ]] +then # if user is not root + USER_LEVEL="${COLOR_USER}" +else # root! + USER_LEVEL="${COLOR_ROOT}" +fi + +#█▓▒░ git prompt +GIT_PROMPT() { + test=$(git rev-parse --is-inside-work-tree 2> /dev/null) + if [ ! "$test" ] + then + [[ "$PROMPT_STYLE" == "ascii" ]] && echo "$reset_color%F{cyan}▒░" + return + fi + ref=$(git name-rev --name-only HEAD | sed 's!remotes/!!' 2> /dev/null) + dirty="" && [[ $(git diff --shortstat 2> /dev/null | tail -n1) != "" ]] && dirty=$ICO_DIRTY + stat=$(git status | sed -n 2p) + case "$stat" in + *ahead*) + stat=$ICO_AHEAD + ;; + *behind*) + stat=$ICO_BEHIND + ;; + *diverged*) + stat=$ICO_DIVERGED + ;; + *) + stat="" + ;; + esac + case "$PROMPT_STYLE" in + ninja) + echo "${COLOR_NORMAL}${ref}${dirty}${stat}" + ;; + ascii) + echo "%{$bg[magenta]%}%F{cyan}▓▒░ %F{black}${ref}${dirty}${stat} $reset_color%F{magenta}▒░" + ;; + *) + echo "${USER_LEVEL}─[${COLOR_NORMAL}"${ref}${dirty}${stat}"${USER_LEVEL}]" + ;; + esac +} +case "$PROMPT_STYLE" in +#█▓▒░ ascii +ascii) +PROMPT='%{$bg[cyan]%} %F{black}%~ $(GIT_PROMPT)$reset_color +%f' +;; +#█▓▒░ ninja +ninja) +PROMPT='%F{white} + ▟▙ ${USER_LEVEL}%~ %F{white}$(GIT_PROMPT) %F{white} +▟▒${USER_LEVEL}░░░░░░░%F{white}▜▙▜████████████████████████████████▛ +▜▒${USER_LEVEL}░░░░░░░%F{white}▟▛▟▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▛ + ▜▛ + %f' +;; +#█▓▒░ dual line +dual) +PROMPT='${USER_LEVEL}┌[${COLOR_NORMAL}%~${USER_LEVEL}]$(GIT_PROMPT) +${USER_LEVEL}└─ - %f' +;; +#█▓▒░ minimal +*) +PROMPT='${USER_LEVEL}[${COLOR_NORMAL}%~${USER_LEVEL}]$(GIT_PROMPT)── -%f ' +;; +esac |