mirror of
https://github.com/prdlk/dotfiles.git
synced 2026-11-02 19:32:43 +00:00
docs(docs): clarify inline TV picker behavior and update widget/keybinding documentation
This commit is contained in:
1 parent
a5bf3e9194
commit
f6e979fa8c
4 files changed
+56
-29
No files matched your search
+25
-16
@@ -55,16 +55,24 @@ Interactive shells only (`[[ $- != *i* ]] && return`). In order:
|
||||
|
||||
`keybinds.zsh` ports `fish_user_key_bindings.fish` to zle. Unlike fish, zsh uses the **emacs** keymap: `bindkey -e` pins it so that `$EDITOR=nvim` does not switch zsh into vi mode. `unsetopt flow_control` frees <kbd>ctrl-q</kbd> and <kbd>ctrl-s</kbd> from the terminal.
|
||||
|
||||
A generic widget `_zle-run` is registered as `run-<cmd>` for `purple`, `clip-last`, `gho`, `pj`, `omp`, `yy`, and `lazygit`. It clears the pending display (`zle -I`), runs the command with the tty on stdin, then `zle reset-prompt`. Widgets run in the shell process, so directory changes made by `gho` and `yy` persist. `tv-git-files` runs `tv git-files` the same way, and `pj-down` handles <kbd>down</kbd>.
|
||||
A generic widget `_zle-run` is registered as `run-<cmd>` for `purple`, `clip-last`, `omp`, `yy`, and `lazygit`. It clears the pending display (`zle -I`), runs the command with the tty on stdin, then `zle reset-prompt`. Widgets run in the shell process, so directory changes made by `gho` and `yy` persist.
|
||||
|
||||
The tv pickers have their own widgets, because `tv --inline` opens on the line below the prompt and leaves the cursor there on exit. `zle -I` followed by `zle reset-prompt` redraws the prompt where zle last drew it, wiping anything printed below; `zle -I` alone draws a fresh prompt under the output.
|
||||
|
||||
| Widget | Runs | Then |
|
||||
| --- | --- | --- |
|
||||
| `tv-git-files` | `tv git-files --inline` | `\033[A`, `reset-prompt` |
|
||||
| `gho-inline` | `gho` | cwd unchanged: `\033[A`, `reset-prompt`. After a cd: nothing, so the new prompt lands below onefetch |
|
||||
| `pj-inline`, `pj-down` | `_zle-pj`: `pj` with `PJ_STATE` set to a temp file (`PJ_QUIET=1` for `pj-down`) | `open` (cancelled): `\033[A`, `reset-prompt`. `ran`: nothing, so the task output stays. Empty (no task sources): `reset-prompt` |
|
||||
|
||||
| Key | Action |
|
||||
| --- | --- |
|
||||
| <kbd>ctrl-e</kbd> | `tv git-files` (pick a file, open it in nvim) |
|
||||
| <kbd>ctrl-e</kbd> | `tv-git-files` (pick a file, open it in nvim) |
|
||||
| <kbd>ctrl-f</kbd> | `yy` |
|
||||
| <kbd>ctrl-b</kbd> | `purple` (an external command; this repo does not provide it) |
|
||||
| <kbd>ctrl-y</kbd> | `clip-last` |
|
||||
| <kbd>ctrl-o</kbd> | `gho` (`ghq-repos` cable, cd) |
|
||||
| <kbd>ctrl-p</kbd> | `pj` (`pj` cable) |
|
||||
| <kbd>ctrl-o</kbd> | `gho-inline` (`ghq-repos` cable, cd) |
|
||||
| <kbd>ctrl-p</kbd> | `pj-inline` (`pj` cable) |
|
||||
| <kbd>ctrl-t</kbd> | tv smart autocomplete (from `tv init zsh`) |
|
||||
| <kbd>down</kbd> | `pj-down`: `PJ_QUIET=1 pj` on an empty prompt, otherwise `down-line-or-history` (bound to `^[[B` and `^[OB`) |
|
||||
| <kbd>ctrl-a</kbd> | `omp` |
|
||||
@@ -78,23 +86,24 @@ The fish-only binds <kbd>ctrl-w</kbd> (atuin AI) and <kbd>?</kbd> have no zsh eq
|
||||
|
||||
## bash key bindings
|
||||
|
||||
`keybinds.bash` gives bash the same picker keys as fish and zsh. bash keeps readline's default emacs keymap.
|
||||
`keybinds.bash` gives bash the same picker keys as fish and zsh. bash keeps readline's default emacs keymap. Every picker runs `tv --inline`; when nothing was printed below the prompt, `_kb_up` (`\033[A` on `/dev/tty`) steps back so readline redraws the prompt in place after `bind -x`.
|
||||
|
||||
| Key | Action |
|
||||
| --- | --- |
|
||||
| <kbd>ctrl-o</kbd> | `gho` (`ghq-repos` cable, cd) |
|
||||
| <kbd>ctrl-e</kbd> | `tv git-files` |
|
||||
| <kbd>ctrl-p</kbd> | `pj` (`pj` cable) |
|
||||
| <kbd>down</kbd> | `pj` cable on an empty prompt (`PJ_QUIET=1`), otherwise `history-search-forward` |
|
||||
| <kbd>ctrl-t</kbd> | `_kb_tv_autocomplete`: runs `tv --autocomplete-prompt` on the text left of the cursor and inserts the picks there, each `printf %q`-quoted |
|
||||
| <kbd>ctrl-o</kbd> | Macro `\C-x1\C-x2\C-x3\C-x0` (below): pick from the `ghq-repos` cable and cd |
|
||||
| <kbd>ctrl-e</kbd> | `_kb_git_files`: `tv git-files --inline`, then `_kb_up` |
|
||||
| <kbd>ctrl-p</kbd> | `_kb_pj`: `pj` with `PJ_STATE` set to a temp file; `_kb_up` only when the state is `open` (cancelled) |
|
||||
| <kbd>down</kbd> | `PJ_QUIET=1 _kb_pj` on an empty prompt, otherwise `history-search-forward` |
|
||||
| <kbd>ctrl-t</kbd> | `_kb_tv_autocomplete`: runs `tv --autocomplete-prompt … --inline` on the text left of the cursor, `_kb_up`, and inserts the picks there, each `printf %q`-quoted |
|
||||
|
||||
Each picker key is a readline macro `\C-xN \C-m \C-x0` built by `_kb_bind KEY SLOT COMMAND…`:
|
||||
`bind -x` runs in the shell process, so a `cd` persists, but readline keeps drawing the prompt it started with. <kbd>ctrl-o</kbd> is therefore a macro:
|
||||
|
||||
1. `\C-xN` is a `bind -x` for `_kb_run`, which stashes `READLINE_LINE` and runs the command in the shell process, so the `cd` done by `gho` persists.
|
||||
2. `\C-m` accepts the now-empty line, so bash prints a fresh prompt for the new cwd. Nothing reaches history.
|
||||
3. `\C-x0` runs `_kb_restore`, which puts the typed text back.
|
||||
1. `\C-x1` runs `_kb_gho`: stashes `READLINE_LINE`, runs `tv ghq-repos --inline`, `_kb_up`, and cds into the pick. It does not call the `gho` function. After a cd it empties the line and rebinds `\C-x2` to `accept-line` and `\C-x3` to `bind -x _kb_gho_show`; when cancelled it rebinds both to `redraw-current-line`.
|
||||
2. `\C-x2` accepts the empty line, so bash prints a fresh prompt for the new cwd. Nothing reaches history.
|
||||
3. `\C-x3` runs `_kb_gho_show` (`clear`, then `onefetch` in git repos); readline redraws the prompt below the output.
|
||||
4. `\C-x0` runs `_kb_restore`, which puts the typed text back.
|
||||
|
||||
<kbd>down</kbd> (`\e[B` and `\eOB`) is the macro `\C-x4\C-x5`. `bind -x` cannot call readline functions, so `_kb_down` (`\C-x4`) rebinds `\C-x5` to `history-search-forward` when the line is non-empty, or runs `pj` and rebinds `\C-x5` to `redraw-current-line`. The slots used are `\C-x0` through `\C-x5`.
|
||||
<kbd>down</kbd> (`\e[B` and `\eOB`) is the macro `\C-x4\C-x5`. `bind -x` cannot call readline functions, so `_kb_down` (`\C-x4`) rebinds `\C-x5` to `history-search-forward` when the line is non-empty, or runs `PJ_QUIET=1 _kb_pj` and rebinds `\C-x5` to `redraw-current-line`.
|
||||
|
||||
## Shared aliases: aliases.sh
|
||||
|
||||
@@ -141,7 +150,7 @@ Each directory holds one function per file. bash and zsh source every file at st
|
||||
| `clip-last` | Re-runs the previous history entry (`fc -ln -1 -1`, skipping itself if the line editor already recorded `clip-last`), pipes the output to `wl-copy` or `pbcopy`, and sends a `notify-send -a shell` notification if available |
|
||||
| `ghg <repo>` | `ghg-clone "$@"`, cd into the printed path, `clear && onefetch` |
|
||||
| `ghn <name>` | `command ghn "$@"`, cd into the printed path |
|
||||
| `gho` | `dir=$(tv ghq-repos)`, return if empty, cd into it, `clear`, and `onefetch` if it is a git repo |
|
||||
| `gho` | `dir=$(tv ghq-repos --inline)`, return if empty, cd into it, `clear`, and `onefetch` if it is a git repo. No cursor handling; bash <kbd>ctrl-o</kbd> does not call it |
|
||||
| `yy [args]` | `yazi --cwd-file=<tmp>`, then cd to the directory written there if it changed |
|
||||
|
||||
The `ghg` helper script is named `ghg-clone` because an unrelated cargo binary already uses the name `ghg`. The [Scripts](/shell/scripts#why-some-helpers-are-shell-functions) page explains why these helpers are shell functions and not scripts.
|
||||
Reference in new issue
Block a user