-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Visual aid to determine the current keymap with Vi keybindings #2
Comments
Hi @antoineco. So good to know you like our lightweight prompt theme! :- D Not sure which indicator to pick for the vicmd keymap. We're already using If you want to experiment with it yourself, we have two themes that have vicmd keymap indicators implemented: It's quite a good amount of additional code. |
This is what I've come up with: changing the prompt indicator to standout when in vicmd. diff --git a/asciiship.zsh-theme b/asciiship.zsh-theme
index def650b..7641305 100644
--- a/asciiship.zsh-theme
+++ b/asciiship.zsh-theme
@@ -1,5 +1,23 @@
# vim:et sts=2 sw=2 ft=zsh
+_prompt_asciiship_vimode() {
+ case ${KEYMAP} in
+ vicmd) print -n '%S%#%s' ;;
+ *) print -n '%#' ;;
+ esac
+}
+
+_prompt_asciiship_keymap_select() {
+ zle reset-prompt
+ zle -R
+}
+if autoload -Uz is-at-least && is-at-least 5.3; then
+ autoload -Uz add-zle-hook-widget && \
+ add-zle-hook-widget -Uz keymap-select _prompt_asciiship_keymap_select
+else
+ zle -N zle-keymap-select _prompt_asciiship_keymap_select
+fi
+
typeset -g VIRTUAL_ENV_DISABLE_PROMPT=1
setopt nopromptbang prompt{cr,percent,sp,subst}
@@ -31,5 +49,5 @@ fi
PS1='
%(2L.%B%F{yellow}(%L)%f%b .)%(!.%B%F{red}%n%f%b in .${SSH_TTY:+"%B%F{yellow}%n%f%b in "})${SSH_TTY:+"%B%F{green}%m%f%b in "}%B%F{cyan}%~%f%b${(e)git_info[prompt]}${VIRTUAL_ENV:+" via %B%F{yellow}${VIRTUAL_ENV:t}%b%f"}${duration_info}
-%B%(1j.%F{blue}*%f .)%(?.%F{green}.%F{red}%? )%#%f%b '
+%B%(1j.%F{blue}*%f .)%(?.%F{green}.%F{red}%? )$(_prompt_asciiship_vimode)%f%b '
unset RPS1 |
I hadn't though about standout, that could be a good approach I think! Underline comes to mind too. I know that the
I'll try your patch today and report here. |
Contrary to what I remembered, standout does work perfectly fine in tmux on macOS, with the default tmux config ( tmux 3.3, screen-256color Terminal.app, xterm-256color Kitty, xterm-kitty Patch applied, I think it looks great: Underline wouldn't be very clear (and is probably not as widely supported as standout): |
First of all, excellent job with the prompt 👏 I discovered today that Zim had a "new" default prompt after reinstalling my machine, and it is so simple and functional that I want to use it instead of Pure.
Is your feature request related to a problem? Please describe.
When Vi keybindings are enabled (
bindkey -v
) there is no visual aid to determine whether zle's current keymap isviins
(insert mode, default) orvicmd
(command mode, when pressing ESC).I think making such visual aid part of the prompt would be sensible because:
Describe the solution you'd like
Option 1 (preferred)
Change the prompt symbol to another character of the ASCII table while the
vicmd
keymap is active. There aren't that many but, as an example, the extended ASCII table contains§
(char 167), which should be available in any font and is quite subtle.It looks like below (viins / vicmd):
Option 2
Change the color of the prompt symbol to something other than green or red while the
vicmd
keymap is active. I suggestcyan
because it is somewhat close to green, yet distinguishable.Potential issue: the
red
color coding — which indicates that the previous command failed — is lost while invicmd
mode, unless translated to yet another color like magenta. I'm not yet sure how I'd feel about that.It looks like below (viins / vicmd):
Describe alternatives you've considered
Spaceship includes a text indicator (
[I]
/[N]
) on the first line, which I find bloated.Starship allows configuring the shape and color of the prompt symbol in different states, which I find interesting and well designed. But considering the minimal nature of asciiship, I think a sane default that people can customize by forking the prompt's code would be enough.
Changing the terminal's cursor shape while changing mode e.g. from beam to block and back — like in Vim itself — would be controversial and error prone.
Additional context
-
The text was updated successfully, but these errors were encountered: