From 997dbb390789593869e563143fa5af4fb9b61844 Mon Sep 17 00:00:00 2001 From: Andrew Lorimer Date: Wed, 15 May 2019 19:21:26 +1000 Subject: [PATCH] add new zsh theme --- zsh/.oh-my-zsh/custom/themes/custom.zsh-theme | 71 +++++++++++++++++++ zsh/.zshrc | 3 +- 2 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 zsh/.oh-my-zsh/custom/themes/custom.zsh-theme diff --git a/zsh/.oh-my-zsh/custom/themes/custom.zsh-theme b/zsh/.oh-my-zsh/custom/themes/custom.zsh-theme new file mode 100644 index 0000000..e5d4869 --- /dev/null +++ b/zsh/.oh-my-zsh/custom/themes/custom.zsh-theme @@ -0,0 +1,71 @@ +# zsh theme by Andrew Lorimer + +# Prompt: +# %F => Color codes +# %f => Reset color +# %~ => Current path +# %(x.true.false) => Specifies a ternary expression +# ! => True if the shell is running with root privileges +# ? => True if the exit status of the last command was success +# +# Git: +# %a => Current action (rebase/merge) +# %b => Current branch (hide if master) +# %c => Staged changes +# %u => Unstaged changes +# +# Terminal: +# \n => Newline/Line Feed (LF) + +setopt PROMPT_SUBST + +autoload -U add-zsh-hook +autoload -Uz vcs_info + +# Use 256 colours if available +if [[ "${terminfo[colors]}" -ge 256 ]]; then + color0="%F{69}" # blue context/angle bracket + color1="%F{256}" # white pwd text + color2="%F{245}" # grey git branch text + color3="%F{167}" # red error/untracked + color4="%F{209}" # orange warning/unstaged/suspended + color5="%F{107}" # green success/staged +else # Fall back to standard ANSI names + color0="%F{blue}" + color1="%F{white}" + color2="%F{cyan}" + color3="%F{red}" + color4="%F{yellow}" + color5="%F{green}" +fi + +FMT_VCS_STATUS="%{$color2%}%b%u%c%{%f%} " + +zstyle ':vcs_info:*' enable git +zstyle ':vcs_info:*' check-for-changes true +zstyle ':vcs_info:*' unstagedstr "%{%f%} %{$color4%}●" +zstyle ':vcs_info:*' stagedstr "%{%f%} %{$color5%}✚" +zstyle ':vcs_info:*' actionformats "(%{$color5%}%a%{%f%})${FMT_VCS_STATUS}" +zstyle ':vcs_info:*' formats "${FMT_VCS_STATUS}" +zstyle ':vcs_info:*' nvcsformats "" # return nothing when no VCS in pwd +zstyle ':vcs_info:git*+set-message:*' hooks git-untracked + +# Check for untracked files ++vi-git-untracked() { + if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == 'true' ]] && \ + git status --porcelain | grep --max-count=1 '^??' &> /dev/null; then + hook_com[staged]+="%{%f%} %{$color3%}●" + fi +} + +add-zsh-hook precmd vcs_info + +# Context (user@host) +if [[ "$SSH_CLIENT" ]]; then + context="%{$color0%}%n@%m " +fi + +# Check for suspended processes +[[ $(jobs -l | wc -l) -gt 0 ]] && symbols="%{$color4%}● " + +PROMPT=$'$symbols$context%{%f%}%~%{%f%} ${vcs_info_msg_0_/master/} %(?.%{$color0%}.%{$color3%})%(!.#.❯)%{%f%} ' diff --git a/zsh/.zshrc b/zsh/.zshrc index c14be69..66b9b16 100755 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -14,6 +14,7 @@ bindkey '^H' backward-delete-word # Ctrl+Del deletes succeeding word bindkey '^[[3^' delete-word +<<<<<<< HEAD # Ctrl+left arrow moves cursor one word left bindkey '^[Od' backward-word @@ -42,7 +43,7 @@ alias cat=bat # --- # Appearance # --- -ZSH_THEME="agnoster" +ZSH_THEME="custom" COMPLETION_WAITING_DOTS="true" # plugins can be found in ~/.oh-my-zsh/plugins/* -- 2.49.0