From 8009d27cbcab0300615be31b15fb4b6f10beb06a Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 5 Jan 2026 06:09:17 +0000 Subject: [PATCH] Add zsh productivity features: edit-command-line, magic space, zmv, suffix aliases - Edit command line in $EDITOR with Ctrl+X Ctrl+E - Magic space expands history expressions (!!, !$, etc.) - zmv for pattern-based batch file operations (plus zcp/zln aliases) - Suffix aliases: markdown with glow, json with jless, source files with $EDITOR --- .config/zsh/aliases.zsh | 32 ++++++++++++++++++++++++++++++++ .config/zsh/init.zsh | 11 +++++++++++ 2 files changed, 43 insertions(+) diff --git a/.config/zsh/aliases.zsh b/.config/zsh/aliases.zsh index e62a46c..5885529 100644 --- a/.config/zsh/aliases.zsh +++ b/.config/zsh/aliases.zsh @@ -62,3 +62,35 @@ alias sqlite='rlwrap -a -N -c -i -f ~/.rlwrap/sqlite3_completions sqlite3' if command -v uvx >/dev/null 2>&1; then alias docx2pdf='uvx docx2pdf' fi + +# zmv convenience aliases (zmv loaded in init.zsh) +alias zcp='zmv -C' # Copy with patterns +alias zln='zmv -L' # Link with patterns + +# Suffix aliases - open files by typing their name +# Markdown files with glow (pager mode) +if command -v glow >/dev/null 2>&1; then + alias -s md='glow -p' +fi + +# JSON with jless if available, otherwise bat +if command -v jless >/dev/null 2>&1; then + alias -s json=jless +elif command -v bat >/dev/null 2>&1; then + alias -s json=bat +fi + +# Text and log files with bat +if command -v bat >/dev/null 2>&1; then + alias -s txt=bat + alias -s log=bat +fi + +# Source files open in editor +alias -s go='$EDITOR' +alias -s rs='$EDITOR' +alias -s py='$EDITOR' +alias -s js='$EDITOR' +alias -s ts='$EDITOR' +alias -s tsx='$EDITOR' +alias -s jsx='$EDITOR' diff --git a/.config/zsh/init.zsh b/.config/zsh/init.zsh index ae02729..c6e707f 100644 --- a/.config/zsh/init.zsh +++ b/.config/zsh/init.zsh @@ -26,6 +26,17 @@ bindkey '^[[H' beginning-of-line # Home key: beginning of line bindkey '^[[F' end-of-line # End key: end of line bindkey '^[[3~' delete-char # Delete key +# Edit command line in $EDITOR (Ctrl+X Ctrl+E) +autoload -Uz edit-command-line +zle -N edit-command-line +bindkey '^X^E' edit-command-line + +# Magic space: expand history (!!, !$, etc.) when pressing space +bindkey ' ' magic-space + +# zmv for batch file renaming with pattern matching +autoload -Uz zmv + # Add useful zsh options setopt AUTO_CD # If a command is a directory name, cd to it setopt AUTO_PUSHD # Push dirs to the stack automatically