feat(config): switch tv pickers to --inline and improve prompt redraw handling

This commit is contained in:
Prad Nukala committed 2026-09-30 11:54:14 -04:00
1 parent 19aeed21ac
commit a5bf3e9194
10 files changed
+173 -57

No files matched your search

+13
View File
@@ -0,0 +1,13 @@
function _gho_bind --description 'ctrl-o: gho (tv --inline), then redraw the prompt in the right place'
set -l before $PWD
gho
if test "$PWD" = "$before"
# Cancelled (or the nvim action ran): tv --inline left the cursor on
# the line below the prompt; step back so repaint redraws in place.
printf '\033[A' >/dev/tty
else
# cd + clear + onefetch: put the prompt below onefetch's output.
printf '\n' >/dev/tty
end
commandline -f repaint
end
+21
View File
@@ -0,0 +1,21 @@
function _pj_bind --description 'ctrl-p / down: pj (tv --inline), then redraw the prompt in the right place'
# pj reports through $PJ_STATE: `open` = the picker was cancelled and
# left the cursor on the line below the prompt; empty = no task sources,
# nothing drawn — but fish's repaint after an external command still
# lands one line low, so both step back up. `ran` = a task printed
# output: new line, prompt below it.
set -lx PJ_STATE (mktemp)
if contains -- --quiet $argv
set -lx PJ_QUIET 1
end
pj
set -l state (cat $PJ_STATE)
switch "$state"
case open ''
printf '\033[A' >/dev/tty
case ran
printf '\n' >/dev/tty
end
rm -f $PJ_STATE
commandline -f repaint
end
+5 -5
View File
@@ -13,9 +13,9 @@ function _pj_bind_down --description "down arrow: pj tv cable on an idle empty p
return
end
# pj is ~/.local/bin/pj (also ctrl-p), which opens the `pj` tv cable.
# PJ_QUIET keeps it silent when the tree has no task source at all, so
# down is a no-op outside projects instead of printing an error per press.
PJ_QUIET=1 pj
commandline -f repaint
# _pj_bind runs ~/.local/bin/pj (also ctrl-p), which opens the `pj` tv
# cable. --quiet (PJ_QUIET) keeps it silent when the tree has no task
# source at all, so down is a no-op outside projects instead of printing
# an error per press.
_pj_bind --quiet
end
+10
View File
@@ -0,0 +1,10 @@
function _tv_inline --description 'tv --inline below the prompt, cursor back on the prompt line; stdout is the pick'
# tv --inline opens on the line below the prompt and leaves the cursor on
# its own first row when it exits; step back up so the following
# `commandline -f repaint` redraws the prompt in place instead of one line
# lower. /dev/tty keeps the move out of callers that capture stdout (gho).
tv $argv --inline
set -l st $status
printf '\033[A' >/dev/tty
return $st
end
@@ -11,13 +11,15 @@ function fish_user_key_bindings
# ctrl-g → lazygit overlay, ctrl-a → omp hsplit, ctrl-y → yazi vsplit,
# ctrl-h/j/k/l → vim-aware split nav (pass_keys.py).
# ctrl-e: tv git-files (bat preview, enter opens nvim). ctrl-o, ctrl-p
# and down also open tv cables — same keys in zsh and bash.
bind -M $mode ctrl-e 'tv git-files; commandline -f repaint'
# and down also open tv cables — same keys in zsh and bash. tv runs
# --inline below the prompt; _tv_inline/_gho_bind/_pj_bind put the
# prompt back in place (or below any output) afterwards.
bind -M $mode ctrl-e '_tv_inline git-files; commandline -f repaint'
bind -M $mode ctrl-b purple repaint
bind -M $mode ctrl-y clip-last
bind -M $mode ctrl-o 'gho; commandline -f repaint'
bind -M $mode ctrl-p 'pj; commandline -f repaint'
bind -M $mode ctrl-o _gho_bind
bind -M $mode ctrl-p _pj_bind
bind -M $mode ctrl-a 'omp; commandline -f repaint'
bind -M $mode ctrl-w 'atuin ai inline; commandline -f repaint'
+2 -2
View File
@@ -1,6 +1,6 @@
function gho --description 'pick a ghq repo / Obsidian vault (tv ghq-repos cable) + cd'
set -l dir (tv ghq-repos); or return
test -n "$dir"; or return
set -l dir (tv ghq-repos --inline); or return
test -n "$dir"; or return 1
cd $dir; or return
clear
if test -d .git