Add vim mode indicators and enhanced keybindings to zsh
- Enable vim keybindings with defaultKeymap = "viins" - Add cursor shape changes: line cursor for insert mode, block for normal mode - Reduce mode switching delay from 400ms to 10ms for faster response - Add vim-style history navigation with k/j in normal mode - Add history search with / and ? in normal mode - Add word movement with Ctrl+arrow keys in insert mode - Integrate with Powerlevel10k prompt symbols for mode indication Provides clear visual feedback for vim mode changes with multiple indicators. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
f121e81c8d
commit
4098771120
1 changed files with 35 additions and 0 deletions
35
zsh.nix
35
zsh.nix
|
|
@ -3,6 +3,7 @@
|
||||||
{
|
{
|
||||||
programs.zsh = {
|
programs.zsh = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
defaultKeymap = "viins";
|
||||||
enableVteIntegration = true;
|
enableVteIntegration = true;
|
||||||
enableCompletion = true;
|
enableCompletion = true;
|
||||||
autosuggestion.enable = true;
|
autosuggestion.enable = true;
|
||||||
|
|
@ -41,6 +42,40 @@
|
||||||
|
|
||||||
# Load Powerlevel10k configuration (managed by Nix)
|
# Load Powerlevel10k configuration (managed by Nix)
|
||||||
source ~/.p10k.zsh
|
source ~/.p10k.zsh
|
||||||
|
|
||||||
|
# Vim mode configuration
|
||||||
|
# Reduce delay when switching modes (10ms instead of 400ms)
|
||||||
|
export KEYTIMEOUT=1
|
||||||
|
|
||||||
|
# Cursor shape changes for vim modes
|
||||||
|
function zle-keymap-select {
|
||||||
|
case $KEYMAP in
|
||||||
|
vicmd) echo -ne '\e[1 q';; # block cursor for normal mode
|
||||||
|
viins|main) echo -ne '\e[5 q';; # line cursor for insert mode
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
zle -N zle-keymap-select
|
||||||
|
|
||||||
|
# Ensure we start with line cursor in insert mode
|
||||||
|
function zle-line-init {
|
||||||
|
echo -ne '\e[5 q'
|
||||||
|
}
|
||||||
|
zle -N zle-line-init
|
||||||
|
|
||||||
|
# Fix cursor after each command
|
||||||
|
function preexec {
|
||||||
|
echo -ne '\e[5 q'
|
||||||
|
}
|
||||||
|
|
||||||
|
# Additional vim-like bindings
|
||||||
|
bindkey -M vicmd 'k' history-search-backward
|
||||||
|
bindkey -M vicmd 'j' history-search-forward
|
||||||
|
bindkey -M vicmd '/' history-incremental-search-backward
|
||||||
|
bindkey -M vicmd '?' history-incremental-search-forward
|
||||||
|
|
||||||
|
# Better word movement in insert mode
|
||||||
|
bindkey '^[[1;5C' forward-word # Ctrl+Right
|
||||||
|
bindkey '^[[1;5D' backward-word # Ctrl+Left
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue