diff options
| author | Stefan Weigl-Bosker <stefan@s00.xyz> | 2025-03-06 13:13:13 -0500 |
|---|---|---|
| committer | Stefan Weigl-Bosker <stefan@s00.xyz> | 2025-03-06 13:13:13 -0500 |
| commit | 6c1001c4dcbe7393fdead33d1c33f0fecf0da88d (patch) | |
| tree | d49834114e11319c53eff9cb32ed3b7d1e8ae9b5 | |
| parent | 8a0ea10b75a465025ba5430d586ae6589f0ea36f (diff) | |
| download | home-6c1001c4dcbe7393fdead33d1c33f0fecf0da88d.tar.gz | |
zsh stuff
| -rw-r--r-- | modules/zsh/default.nix | 20 | ||||
| -rw-r--r-- | modules/zsh/themes/stefan.zsh-theme | 24 |
2 files changed, 42 insertions, 2 deletions
diff --git a/modules/zsh/default.nix b/modules/zsh/default.nix index 0c7adeb..0a66a20 100644 --- a/modules/zsh/default.nix +++ b/modules/zsh/default.nix @@ -31,6 +31,7 @@ in enable = true; autocd = true; enableCompletion = true; + defaultKeymap = "viins"; dirHashes = { home = "~/home"; dl = "~/dl"; @@ -39,6 +40,25 @@ in autosuggestion.enable = true; initExtra = '' source ~/.oh-my-zsh/themes/${cfg.theme}.zsh-theme + setopt nobeep + export KEYTIMEOUT=1 # note, set higher if you want to use surround mode + + bindkey -M vicmd m vi-backward-char + bindkey -M vicmd n vi-down-line-or-history + bindkey -M vicmd e vi-up-line-or-history + bindkey -M vicmd i vi-forward-char + + bindkey -M vicmd N vi-join + + bindkey -M vicmd h vi-set-mark + bindkey -M vicmd j vi-repeat-search + bindkey -M vicmd k vi-forward-word-end + bindkey -M vicmd l vi-insert + + bindkey -M vicmd J vi-rev-repeat-search + + # vim style backspace (im a young soul) + bindkey -v '^?' backward-delete-char ''; }; }; diff --git a/modules/zsh/themes/stefan.zsh-theme b/modules/zsh/themes/stefan.zsh-theme index 788f49b..dc9a201 100644 --- a/modules/zsh/themes/stefan.zsh-theme +++ b/modules/zsh/themes/stefan.zsh-theme @@ -55,6 +55,26 @@ function gitstatus_prompt_update() { GITSTATUS_PROMPT="%f${p}%f" } +INS_MODE='%{%F{reset}%}[%{%F{green}%}i%{%F{reset}%}]' +NORMAL_MODE='%{%F{reset}%}[%{%F{yellow}%}n%{%F{reset}%}]' +VI_MODE=$INS_MODE + +function zle-keymap-select() { + VI_MODE="${${KEYMAP/vicmd/${NORMAL_MODE}}/(main|viins)/${INS_MODE}}" + zle reset-prompt +# zle -R +} + +zle -N zle-keymap-select # hook readline so we can determine mode + +# normally, SIGINT (<C-c>) will put you in ins, but indictator wont update. +# fix: hook TRAPINT, update mode and repropagate the SIGINT +# im too lazy to figure out if its possible to keep normal mode and send a sigint +TRAPINT() { + export VI_MODE=$INS_MODE + return $((128+$1)) +} + source "$(gitstatus-share)/gitstatus.plugin.zsh" || return gitstatus_stop 'MY' && gitstatus_start -s -1 -u -1 -c -1 -d -1 'MY' @@ -66,7 +86,7 @@ setopt prompt_subst prompt_percent no_prompt_bang NEWLINE=$'\n' GIT_PROMPT_INFO=${GITSTATUS_PROMPT:+ $GITSTATUS_PROMPT} -PROMPT="%F{magenta}%~% %f% %F{yellow}% ${NEWLINE}λ %b%f%" -RPROMPT='$(virtualenv_info)% ${GITSTATUS_PROMPT:+ $GITSTATUS_PROMPT}' +PROMPT='%F{magenta}%~% %f% ${VI_MODE}${NEWLINE}%{%F{yellow}%}λ %b%f% ' +RPROMPT='$(virtualenv_info)% ${GITSTATUS_PROMPT:+ $GITSTATUS_PROMPT} ' ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[green]%}" ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" |