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 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 5ef9f08..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"; @@ -94,6 +97,27 @@ 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 + # 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) + + # Zoxide configuration - replace cd with z for smart directory jumping + eval "$(zoxide init zsh --cmd cd)" ''; }; @@ -112,6 +136,11 @@ in enableZshIntegration = true; }; + programs.zoxide = { + enable = true; + enableZshIntegration = true; + }; + # Manage Powerlevel10k configuration home.file.".p10k.zsh".source = ../config/p10k.zsh;