summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2015-12-16 16:04:29 -0500
committerJune McEnroe <june@causal.agency>2015-12-16 16:04:29 -0500
commit45a337f7ecdaadf106979f8206ab5dcf52292d39 (patch)
tree753b9760bd1bbb331e71115067341c1313626370
parentRemove colorcolumn at 120 (diff)
downloadsrc-45a337f7ecdaadf106979f8206ab5dcf52292d39.tar.gz
src-45a337f7ecdaadf106979f8206ab5dcf52292d39.zip
Color prompt yellow in vi normal mode
Diffstat (limited to '')
-rw-r--r--.zshrc24
1 files changed, 18 insertions, 6 deletions
diff --git a/.zshrc b/.zshrc
index 1f9d07b8..7fa8f3b4 100644
--- a/.zshrc
+++ b/.zshrc
@@ -15,14 +15,23 @@ unsetopt beep
 # Vim line editing.
 bindkey -v
 
-# Initialize completion.
+# Initialize completion and colors.
 autoload -Uz compinit && compinit
-
-# Prompt with single character on the left, normally green, magenta over SSH,
-# red after a failed command. Directory and git branch on the right.
-setopt prompt_subst
 autoload colors && colors
+
+# Color prompt magenta over SSH.
 [[ -n "$SSH_CLIENT" ]] && _prompt_ssh_color="$fg[magenta]"
+
+# Color prompt yellow in vi normal mode.
+function zle-line-init zle-keymap-select {
+  _prompt_vi_color=
+  [[ "$KEYMAP" == "vicmd" ]] && _prompt_vi_color="$fg[yellow]"
+  zle reset-prompt
+}
+zle -N zle-line-init
+zle -N zle-keymap-select
+
+# Show git branch or commit in right prompt.
 _prompt_git_branch() {
   [[ -f .git/HEAD ]] || return 0
   local head
@@ -36,7 +45,10 @@ _prompt_git_branch() {
       ;;
   esac
 }
-PROMPT='%{%(?.$fg[green]$_prompt_ssh_color.$fg[red])%}»%{$reset_color%} '
+
+# Single colored character prompt, directory and git branch in right prompt.
+setopt prompt_subst
+PROMPT='%{%(?.$fg[green]$_prompt_ssh_color.$fg[red])$_prompt_vi_color%}»%{$reset_color%} '
 RPROMPT='%{$fg[blue]%}%-50<…<%~%{$fg[yellow]%}$(_prompt_git_branch)%{$reset_color%}'
 
 # Print a newline before every prompt after the first one.
r>2019-09-16Use sensitivity aliases in TF2June McEnroe 2019-09-16Add The Just CityJune McEnroe 2019-09-12Only GET the final redirect locationJune McEnroe 2019-09-12Consume entire bodyJune McEnroe 2019-09-10Add title -v flagJune McEnroe 2019-09-10Use curl error bufferJune McEnroe 2019-09-10Set Accept-Encoding in titleJune McEnroe 2019-09-08Set title User-AgentJune McEnroe 2019-09-07Add -x flag to titleJune McEnroe 2019-09-07Ignore SIGPIPE in relayJune McEnroe 2019-09-07Add A Memory Called EmpireJune McEnroe 2019-09-05Handle lack of Content-TypeJune McEnroe 2019-09-05Use CURLINFO_CONTENT_TYPEJune McEnroe 2019-09-05Decode entities in titlesJune McEnroe 2019-09-05Print title as soon as it's availableJune McEnroe 2019-09-05Use CURL_PREFIX to set flagsJune McEnroe 2019-09-05Add titleJune McEnroe 2019-09-04Add Avorter n'est pas tuerJune McEnroe 2019-08-29Unset executable on shell scriptsJune McEnroe 2019-08-29Add long-missing setopt to bin.7June McEnroe 2019-08-29Add editJune McEnroe