Skip to content

Commit 928a284

Browse files
authored
feat: add lf and fzf navigation keybindings to zshrc (#66)
Add Ctrl+O for lf file manager integration and Ctrl+F for fzf-based directory navigation. Update help text to document new shortcuts. Exclude zsh files from shellcheck (zsh not supported by shellcheck).
1 parent 247abd9 commit 928a284

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ repos:
7373
description: Lint bash scripts for common issues
7474
args: ['--severity=warning']
7575
types: [shell]
76+
exclude: '\.zshrc$|\.zsh$'
7677

7778
# =============================================================================
7879
# MARKDOWN LINTING (for documentation)

.zshrc

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,21 @@ autoload edit-command-line; zle -N edit-command-line
161161
bindkey '^e' edit-command-line
162162
bindkey -M vicmd '^e' edit-command-line
163163

164+
# lf file manager integration - Ctrl+O to browse and cd
165+
lfcd () {
166+
tmp="$(mktemp -uq)"
167+
trap 'rm -f $tmp >/dev/null 2>&1 && trap - HUP INT QUIT TERM PWR EXIT' HUP INT QUIT TERM PWR EXIT
168+
lf -last-dir-path="$tmp" "$@"
169+
if [ -f "$tmp" ]; then
170+
dir="$(cat "$tmp")"
171+
[ -d "$dir" ] && [ "$dir" != "$(pwd)" ] && cd "$dir"
172+
fi
173+
}
174+
bindkey -s '^o' '^ulfcd\n'
175+
176+
# fzf-based cd to directory containing selected file - Ctrl+F
177+
bindkey -s '^f' '^ucd "$(dirname "$(fzf)")"\n'
178+
164179
# FZF integration (if installed)
165180
if [ -f /usr/share/fzf/key-bindings.zsh ]; then
166181
safe_source /usr/share/fzf/key-bindings.zsh
@@ -228,8 +243,9 @@ ZSH KEYBOARD SHORTCUTS:
228243
Ctrl+R - Search backward through history
229244
Ctrl+S - Search forward through history
230245
Ctrl+A - Jump to beginning of line
231-
Ctrl+E - Jump to end of line
232-
Ctrl+E - Edit command in vim (normal mode)
246+
Ctrl+E - Jump to end of line (or edit in vim in normal mode)
247+
Ctrl+O - Open lf file manager and cd to selected directory
248+
Ctrl+F - Use fzf to select file and cd to its directory
233249
Delete - Delete character under cursor
234250
235251
VI MODE INDICATORS:

0 commit comments

Comments
 (0)