mirror of
https://github.com/prdlk/dotfiles.git
synced 2026-11-02 11:32:42 +00:00
feat(config): add television cable integration and related keybindings across shells
This commit is contained in:
1 parent
f033b29a7d
commit
3c4af515fa
12 files changed
+137
-21
No files matched your search
@@ -1,7 +1,8 @@
|
||||
# Pick a ghq repo / Obsidian vault + cd; picker lives in ~/.local/bin/gho.
|
||||
# Pick a ghq repo / Obsidian vault with tv (ghq-repos cable) + cd.
|
||||
gho() {
|
||||
local dir
|
||||
dir=$(command gho) || return
|
||||
dir=$(tv ghq-repos) || return
|
||||
[ -n "$dir" ] || return
|
||||
cd "$dir" || return
|
||||
clear
|
||||
if [ -d .git ]; then
|
||||
|
||||
@@ -8,6 +8,8 @@ unsetopt flow_control # free ^Q/^S in zle so the ctrl-q exit bind fires
|
||||
# Generic runner: widget `run-<cmd>` executes <cmd> (function or binary) with
|
||||
# the tty as stdin, then repaints — fish's `commandline -f repaint`.
|
||||
# cwd changes from gho/yy persist: widgets run in the shell process.
|
||||
# gho, pj and `tv git-files` open television cables (~/.config/television/
|
||||
# cable) — the same keys do the same in fish and bash.
|
||||
_zle-run() {
|
||||
local cmd=${WIDGET#run-}
|
||||
zle -I
|
||||
@@ -19,17 +21,39 @@ for _cmd in purple clip-last gho pj omp yy lazygit; do
|
||||
done
|
||||
unset _cmd
|
||||
|
||||
# ctrl-e: yazi, same as ctrl-f (cd's to yazi's exit dir on quit).
|
||||
bindkey '^E' run-yy
|
||||
# ctrl-e: tv git-files (bat preview, enter opens nvim).
|
||||
_zle-tv-git-files() {
|
||||
zle -I
|
||||
tv git-files </dev/tty
|
||||
zle reset-prompt
|
||||
}
|
||||
zle -N tv-git-files _zle-tv-git-files
|
||||
bindkey '^E' tv-git-files
|
||||
bindkey '^B' run-purple
|
||||
bindkey '^Y' run-clip-last
|
||||
bindkey '^O' run-gho
|
||||
bindkey '^P' run-pj
|
||||
bindkey '^A' run-omp
|
||||
# ctrl-f: pick file(s) and open in nvim; yy also cd's to yazi's exit dir.
|
||||
# ctrl-f: yazi; yy cd's to yazi's exit dir on quit.
|
||||
bindkey '^F' run-yy
|
||||
bindkey '^G' run-lazygit
|
||||
|
||||
# down: the pj cable on an idle, empty prompt; otherwise normal history /
|
||||
# multiline movement (fish's _pj_bind_down). PJ_QUIET makes it a silent no-op
|
||||
# outside projects.
|
||||
_zle-pj-down() {
|
||||
if [[ -n $BUFFER ]]; then
|
||||
zle down-line-or-history
|
||||
return
|
||||
fi
|
||||
zle -I
|
||||
PJ_QUIET=1 pj </dev/tty
|
||||
zle reset-prompt
|
||||
}
|
||||
zle -N pj-down _zle-pj-down
|
||||
bindkey '^[[B' pj-down
|
||||
bindkey '^[OB' pj-down
|
||||
|
||||
# ctrl-q mirrors ctrl-d's preset (`exit`) — quit the shell.
|
||||
_zle-exit() { exit }
|
||||
zle -N _zle-exit
|
||||
|
||||
Reference in new issue
Block a user