From 107b668e3a5188886f6456ac9ca4ad729c3d0a8f Mon Sep 17 00:00:00 2001 From: Yan Lin Date: Tue, 29 Jul 2025 23:54:44 +0200 Subject: [PATCH 1/4] Fix zsh vim mode backspace and Shift+A autocomplete issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add explicit backspace bindings for ^? and ^H to fix backspace in vim insert mode - Add Shift+A binding to vi-add-eol to prevent autocomplete interference and enable proper vim append-insert behavior - These fixes ensure backspace works properly and Shift+A functions as vim append-insert instead of triggering autocompletion 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- modules/zsh.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/zsh.nix b/modules/zsh.nix index 5ef9f08..7611678 100644 --- a/modules/zsh.nix +++ b/modules/zsh.nix @@ -94,6 +94,13 @@ in # Better word movement in insert mode bindkey '^[[1;5C' forward-word # Ctrl+Right bindkey '^[[1;5D' backward-word # Ctrl+Left + + # Fix backspace in vim insert mode + bindkey '^?' backward-delete-char # Backspace + bindkey '^H' backward-delete-char # Ctrl+H (alternative backspace) + + # Prevent Shift+A from triggering autocomplete in vim insert mode + bindkey -M viins '^[[1;2A' vi-add-eol ''; }; From a7164a0ff385789512684581ced766957611b7d1 Mon Sep 17 00:00:00 2001 From: Yan Lin Date: Tue, 29 Jul 2025 23:58:40 +0200 Subject: [PATCH 2/4] Fix Shift+A autocomplete interference with refined approach MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Replace single key sequence binding with multiple potential Shift+A sequences - Add explicit self-insert bindings for 'A', '^[[1;2A', and '^[[65;2u' to cover different terminals - Configure ZSH_AUTOSUGGEST_CLEAR_WIDGETS to prevent autosuggestion interference with vim modes - Add vi-add-eol and vi-add-next to clear widgets to ensure proper vim behavior - Set ZSH_AUTOSUGGEST_ACCEPT_WIDGETS to handle vim end-of-line operations correctly This should prevent Shift+A from triggering autocomplete while preserving vim functionality. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- modules/zsh.nix | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/modules/zsh.nix b/modules/zsh.nix index 7611678..b24b0e7 100644 --- a/modules/zsh.nix +++ b/modules/zsh.nix @@ -100,7 +100,18 @@ in bindkey '^H' backward-delete-char # Ctrl+H (alternative backspace) # Prevent Shift+A from triggering autocomplete in vim insert mode - bindkey -M viins '^[[1;2A' vi-add-eol + # Try multiple potential key sequences for Shift+A across different terminals + bindkey -M viins 'A' self-insert + bindkey -M viins '^[[1;2A' self-insert + bindkey -M viins '^[[65;2u' self-insert + + # Disable expand-or-complete on potential problematic keys in vim insert mode + bindkey -M viins '^I' expand-or-complete # Keep tab completion but be explicit + + # Configure autosuggestions to not interfere with vim mode + ZSH_AUTOSUGGEST_CLEAR_WIDGETS+=(vi-add-eol) + ZSH_AUTOSUGGEST_CLEAR_WIDGETS+=(vi-add-next) + ZSH_AUTOSUGGEST_ACCEPT_WIDGETS=(end-of-line vi-end-of-line vi-add-eol) ''; }; From 73d425d2bf0f29245f5eb4dbc6b6aea802523e46 Mon Sep 17 00:00:00 2001 From: Yan Lin Date: Wed, 30 Jul 2025 00:07:48 +0200 Subject: [PATCH 3/4] Add zoxide integration for smart directory navigation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add zoxide package to flake.nix - Enable zoxide with zsh integration in modules/zsh.nix - Configure zoxide to replace cd command with smart frecency-based navigation - Add zi alias for interactive directory selection with fzf 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- flake.nix | 1 + modules/zsh.nix | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/flake.nix b/flake.nix index 5638007..838415c 100644 --- a/flake.nix +++ b/flake.nix @@ -74,6 +74,7 @@ git-credential-oauth rsync gnumake + zoxide ]; fonts.fontconfig.enable = true; diff --git a/modules/zsh.nix b/modules/zsh.nix index b24b0e7..e343214 100644 --- a/modules/zsh.nix +++ b/modules/zsh.nix @@ -36,6 +36,9 @@ in # Modern CLI tools ftp = "termscp"; + # Zoxide aliases + zi = "z -i"; # Interactive selection with fzf + # Nix helpers hm = "home-manager"; hms = "home-manager switch --flake ~/.config/nix#yanlin"; @@ -112,6 +115,9 @@ in ZSH_AUTOSUGGEST_CLEAR_WIDGETS+=(vi-add-eol) ZSH_AUTOSUGGEST_CLEAR_WIDGETS+=(vi-add-next) ZSH_AUTOSUGGEST_ACCEPT_WIDGETS=(end-of-line vi-end-of-line vi-add-eol) + + # Zoxide configuration - replace cd with z for smart directory jumping + eval "$(zoxide init zsh --cmd cd)" ''; }; @@ -130,6 +136,11 @@ in enableZshIntegration = true; }; + programs.zoxide = { + enable = true; + enableZshIntegration = true; + }; + # Manage Powerlevel10k configuration home.file.".p10k.zsh".source = ../config/p10k.zsh; From bf30e5ae8b4b6ff96f3332dec8b66ac7768d0a34 Mon Sep 17 00:00:00 2001 From: Yan Lin Date: Wed, 30 Jul 2025 00:08:42 +0200 Subject: [PATCH 4/4] Update README with zoxide integration documentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add zoxide to CLI Utilities section with comprehensive usage examples - Update navigation aliases section to reflect zoxide integration - Add zoxide examples to Powerful Tool Combinations section - Document zoxide features: frecency algorithm, fuzzy matching, fzf integration 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- README.md | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 828612c..88441d8 100644 --- a/README.md +++ b/README.md @@ -220,8 +220,8 @@ home-manager switch --flake .#yanlin ```bash l, ll, la # Enhanced ls commands .., ..., .... # Quick directory navigation -home, config # Jump to common directories -nix-config # Jump to nix configuration +cd [query] # Smart directory jumping with zoxide (replaces cd) +zi [query] # Interactive directory selection with fzf ``` **Git:** @@ -589,7 +589,7 @@ uv tool run ruff check . - **lftp**: Scriptable FTP client for automation - **termscp**: Comprehensive TUI file transfer client (FTP/SFTP/SCP/S3) - **rsync**: Fast file synchronization and backup with comprehensive configuration -- **zoxide**: Smart cd with frecency algorithm +- **zoxide**: Smart cd replacement with frecency algorithm #### fd Usage Examples ```bash @@ -662,6 +662,34 @@ lazysql --config ~/.config/lazysql/config.yml - **Export capabilities**: Save query results to files - **Connection management**: Save and reuse database connections +#### zoxide Usage Examples +```bash +# Smart directory navigation (replaces cd) +cd ~/Documents # Adds ~/Documents to zoxide database +cd ~/Projects/myproject # Adds ~/Projects/myproject to database +cd myproj # Jumps to ~/Projects/myproject (fuzzy match) +cd doc # Jumps to ~/Documents (fuzzy match) + +# Interactive directory selection with fzf +zi # Show interactive directory picker +zi proj # Show interactive picker filtered by "proj" + +# Query the database +zoxide query doc # Show paths containing "doc" +zoxide query -l # List all paths in database (sorted by frequency) + +# Remove paths from database +zoxide remove ~/old-project +``` + +**Key zoxide features:** +- **Frecency algorithm**: Combines frequency and recency for smart suggestions +- **Fuzzy matching**: Type partial directory names to jump quickly +- **fzf integration**: Interactive directory selection with zi command +- **Automatic learning**: Builds database of visited directories over time +- **Cross-session**: Remembers directories across terminal sessions +- **cd replacement**: Drop-in replacement for traditional cd command + #### sqlite3 Usage Examples ```bash # Connect to SQLite database @@ -743,6 +771,10 @@ nvim $(fd --type f | fzf --preview 'bat --color=always {}') # Find and edit files in specific directory nvim $(fd --type f . ~/.config | fzf) + +# Smart directory navigation with zoxide +cd proj && nvim . # Jump to project directory and edit +zi && fd "*.md" | fzf # Interactive directory select, then find markdown files ``` ### Fonts