[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] odd/zsh_vim 4518f22: Share a broken .zshrc
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] odd/zsh_vim 4518f22: Share a broken .zshrc |
Date: |
Thu, 24 Oct 2019 14:54:27 -0400 (EDT) |
branch: odd/zsh_vim
commit 4518f22bd8edae998c3057e0e8959bb83ea3ed37
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Share a broken .zshrc
The intention is just to color $PROMPT based on zle $KEYMAP.
That intention is accomplished, but with a distressing side effect:
the Home and End keys no longer work as desired.
With this commit's parent, everything works: Home and End move the
cursor to the beginning and end of the line, respectively.
With this commit, neither Home nor End moves the cursor as expected.
Instead, Home enters 'vicmd' mode, and End followed by right-arrow
deletes to end of line.
---
gwc/.zshrc | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/gwc/.zshrc b/gwc/.zshrc
index 94fd576..2059213 100644
--- a/gwc/.zshrc
+++ b/gwc/.zshrc
@@ -60,7 +60,22 @@ bindkey '^F' history-incremental-search-forward # emacs
Ctrl-S
bindkey '^G' send-break # emacs Ctrl-G
bindkey '^T' push-line # emacs Esc-Q
-prompt='%d[%?]%(!.#.$)'
+autoload colors && colors
+
+function zle-line-init zle-keymap-select {
+ local local_prompt='%d[%?]%(!.#.$)'"-${KEYMAP}-$"
+ if [[ ${KEYMAP} == vicmd ]]; then
+ prompt="%{$fg_bold[green]%}${local_prompt}%{$reset_color%}"
+ elif [[ ${KEYMAP} == isearch ]]; then
+ prompt="ISEARCH${local_prompt}"
+ else
+ prompt="${local_prompt}"
+ fi
+ zle reset-prompt
+}
+
+zle -N zle-line-init
+zle -N zle-keymap-select
HISTSIZE=1000
SAVEHIST=1000