add new zsh theme
authorAndrew Lorimer <andrew@lorimer.id.au>
Wed, 15 May 2019 09:21:26 +0000 (19:21 +1000)
committerAndrew Lorimer <andrew@lorimer.id.au>
Wed, 15 May 2019 09:26:06 +0000 (19:26 +1000)
zsh/.oh-my-zsh/custom/themes/custom.zsh-theme [new file with mode: 0644]
zsh/.zshrc
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 (file)
index 0000000..e5d4869
--- /dev/null
@@ -0,0 +1,71 @@
+# zsh theme by Andrew Lorimer <https://lorimer.id.au>
+
+# 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%} '
index c98102f4bca3474171f963af2b94987d961930e7..d4df296c1817ff53572bb8ccbf53d7dc8f47d586 100755 (executable)
@@ -39,7 +39,7 @@ DISABLE_UNTRACKED_FILES_DIRTY="true"
 # ---
 # Appearance
 # ---
-ZSH_THEME="agnoster-custom"
+ZSH_THEME="custom"
 COMPLETION_WAITING_DOTS="true"
 
 # plugins can be found in ~/.oh-my-zsh/plugins/*