Skip to content

Commit 780dd53

Browse files
committed
feat: zsh: vicmd counterparts for custom line expansions
1 parent a660e93 commit 780dd53

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

zsh/inc.hotkey-insertions.zsh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,23 +61,45 @@ bindkey -s '^Xgs' 'git status^M' # ^M = Enter (auto-execute)
6161
bindkey -s '^Xgd' 'git diff '
6262
bindkey -s '^Xgl' 'git log --oneline -10^M'
6363

64+
# Vi command mode: git shortcuts
65+
# The "x" prefix is a mnemonic for "expansion" (mirroring ^X in emacs mode).
66+
# Simple insertions use 'i' prefix to enter insert mode before the text.
67+
bindkey -M vicmd 'xgc' _hotkey_git_commit
68+
bindkey -M vicmd -s 'xga' 'igit add '
69+
bindkey -M vicmd -s 'xgp' 'igit push'
70+
bindkey -M vicmd -s 'xgP' 'igit push --force-with-lease'
71+
bindkey -M vicmd -s 'xgs' 'igit status^M'
72+
bindkey -M vicmd -s 'xgd' 'igit diff '
73+
bindkey -M vicmd -s 'xgl' 'igit log --oneline -10^M'
74+
6475
# Docker shortcuts
6576
bindkey -s '^Xdc' 'docker compose '
6677
bindkey -s '^Xdp' 'docker ps'
6778
_hotkey_docker_exec() { _insert_with_cursor 'docker exec -it {CURSOR} /bin/bash' }
6879
zle -N _hotkey_docker_exec
6980
bindkey '^Xde' _hotkey_docker_exec
7081

82+
# Vi command mode: docker shortcuts
83+
bindkey -M vicmd -s 'xdc' 'idocker compose '
84+
bindkey -M vicmd -s 'xdp' 'idocker ps'
85+
bindkey -M vicmd 'xde' _hotkey_docker_exec
86+
7187
# Common command patterns
7288
# bindkey -s '^Xll' 'ls -lah^M'
7389
# bindkey -s '^Xcd' 'cd ..^M'
7490
bindkey -s '^Xmk' 'mkdir -p '
7591

92+
# Vi command mode: common commands
93+
bindkey -M vicmd -s 'xmk' 'imkdir -p '
94+
7695
# Date insertion
7796
_hotkey_insert_date() { LBUFFER+=$(date '+%Y-%m-%d') }
7897
zle -N _hotkey_insert_date
7998
bindkey '^Xdd' _hotkey_insert_date
8099

100+
# Vi command mode: date insertion
101+
bindkey -M vicmd 'xdd' _hotkey_insert_date
102+
81103
# Search patterns
82104
_hotkey_find() { _insert_with_cursor 'find . -name "{CURSOR}"' }
83105
zle -N _hotkey_find
@@ -87,6 +109,10 @@ _hotkey_rg() { _insert_with_cursor 'rg "{CURSOR}" .' }
87109
zle -N _hotkey_rg
88110
bindkey '^Xrg' _hotkey_rg
89111

112+
# Vi command mode: search patterns
113+
bindkey -M vicmd 'xfg' _hotkey_find
114+
bindkey -M vicmd 'xrg' _hotkey_rg
115+
90116
# SSH shortcuts (customize with your common hosts)
91117
# bindkey -s '^Xsh' 'ssh user@hostname'
92118

0 commit comments

Comments
 (0)