mirror of
https://github.com/prdlk/dotfiles.git
synced 2026-11-02 11:32:42 +00:00
revert(shell): move iris integration to the iris branch
Reverts43dfe48,0692ae3,e0cdcd6and the cable-description half of098da70(the star-prompt stats stay). master returns to the pre-iris shell setup: atuin in fish/zsh/bash, the down -> pj binding with PJ_QUIET, and the fish/zsh key bindings as they were. The iris work lives on the `iris` branch.
This commit is contained in:
1 parent
098da702fc
commit
2049f580f0
27 files changed
+237
-408
No files matched your search
@@ -1,35 +0,0 @@
|
||||
# czs: chezmoi re-add drifted files, then commit + push the source repo.
|
||||
# Port of functions/czs.fish. Optional targets scope the status view and the
|
||||
# re-add (e.g. `czs ~/.config/fish`); no args = all managed files.
|
||||
czs() {
|
||||
local drift src ahead
|
||||
drift=$(chezmoi status "$@") || return
|
||||
|
||||
if [[ -n $drift ]]; then
|
||||
print -r -- $drift
|
||||
# re-add takes the local (destination) contents as truth for modified
|
||||
# files; templates are never overwritten, non-file entries are ignored.
|
||||
chezmoi re-add "$@" || return
|
||||
else
|
||||
echo "chs: in sync — nothing to re-add"
|
||||
fi
|
||||
|
||||
# Commit + sync the source repo (~/.local/share/chezmoi).
|
||||
src=$(chezmoi source-path)
|
||||
if [[ -n $(git -C $src status --porcelain) ]]; then
|
||||
git -C $src add -A &&
|
||||
git -C $src commit --quiet -m 'chs: re-add drifted files' || return
|
||||
echo "chs: committed $(git -C $src rev-parse --short HEAD)"
|
||||
fi
|
||||
|
||||
# Push anything unpushed: this commit and leftovers from a failed push.
|
||||
# --autostash tolerates post-commit hooks re-dirtying the tree mid-sync.
|
||||
ahead=$(git -C $src rev-list --count @{upstream}..HEAD 2>/dev/null || echo 0)
|
||||
if (( ahead > 0 )); then
|
||||
git -C $src pull --rebase --autostash --quiet &&
|
||||
git -C $src push --quiet &&
|
||||
echo "chs: pushed $ahead commit(s) to $(git -C $src remote get-url origin)"
|
||||
else
|
||||
echo "chs: remote up to date"
|
||||
fi
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
# y: same as yy (fish has both names) — yazi, then cd to its exit directory.
|
||||
y() { yy "$@"; }
|
||||
+16
-68
@@ -5,20 +5,6 @@
|
||||
bindkey -e # pin emacs keymap ($EDITOR containing "vi" would pick viins)
|
||||
unsetopt flow_control # free ^Q/^S in zle so the ctrl-q exit bind fires
|
||||
|
||||
# iris (~/.config/iris) learns a command is running from the preexec/precmd
|
||||
# hooks, which never fire for programs a widget starts. Without this, iris
|
||||
# keeps treating the screen as an idle prompt while tv, yazi or lazygit run:
|
||||
# it swallows up/down/tab and can draw its menu over them. Same messages as
|
||||
# iris's own hooks; a no-op outside iris. fish: functions/_iris_busy.fish.
|
||||
_iris_busy() {
|
||||
[[ -n $IRIS_FD ]] || return 0
|
||||
case $1 in
|
||||
start) print -u $IRIS_FD -N -r -- IRIS_CMD_START 2>/dev/null ;;
|
||||
stop) print -u $IRIS_FD -N -r -- IRIS_CMD_STOP:0 2>/dev/null ;;
|
||||
esac
|
||||
return 0
|
||||
}
|
||||
|
||||
# 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.
|
||||
@@ -27,9 +13,7 @@ _iris_busy() {
|
||||
_zle-run() {
|
||||
local cmd=${WIDGET#run-}
|
||||
zle -I
|
||||
_iris_busy start
|
||||
$cmd </dev/tty
|
||||
_iris_busy stop
|
||||
zle reset-prompt
|
||||
}
|
||||
for _cmd in purple clip-last omp-session yy lazygit; do
|
||||
@@ -47,9 +31,7 @@ unset _cmd
|
||||
# cursor to tv's line).
|
||||
_zle-tv-git-files() {
|
||||
zle -I
|
||||
_iris_busy start
|
||||
tv git-files --inline </dev/tty
|
||||
_iris_busy stop
|
||||
printf '\033[A' >/dev/tty
|
||||
zle reset-prompt
|
||||
}
|
||||
@@ -60,9 +42,7 @@ zle -N tv-git-files _zle-tv-git-files
|
||||
_zle-gho() {
|
||||
local before=$PWD
|
||||
zle -I
|
||||
_iris_busy start
|
||||
gho </dev/tty
|
||||
_iris_busy stop
|
||||
if [[ $PWD == "$before" ]]; then
|
||||
printf '\033[A' >/dev/tty
|
||||
zle reset-prompt
|
||||
@@ -70,15 +50,23 @@ _zle-gho() {
|
||||
}
|
||||
zle -N gho-inline _zle-gho
|
||||
|
||||
# ctrl-p: pj. pj reports through $PJ_STATE: `open` = cancelled, `ran` = a task
|
||||
# printed output, empty = no task sources.
|
||||
# ctrl-p, and down on an idle empty prompt (fish's _pj_bind_down; otherwise
|
||||
# normal history / multiline movement). pj reports through $PJ_STATE: `open`
|
||||
# = cancelled, `ran` = a task printed output, empty = no task sources
|
||||
# (PJ_QUIET keeps down silent outside projects).
|
||||
_zle-pj() {
|
||||
if [[ $WIDGET == pj-down && -n $BUFFER ]]; then
|
||||
zle down-line-or-history
|
||||
return
|
||||
fi
|
||||
local state
|
||||
state=$(mktemp) || return
|
||||
zle -I
|
||||
_iris_busy start
|
||||
PJ_STATE=$state pj </dev/tty
|
||||
_iris_busy stop
|
||||
if [[ $WIDGET == pj-down ]]; then
|
||||
PJ_STATE=$state PJ_QUIET=1 pj </dev/tty
|
||||
else
|
||||
PJ_STATE=$state pj </dev/tty
|
||||
fi
|
||||
case $(<$state) in
|
||||
open) printf '\033[A' >/dev/tty; zle reset-prompt ;;
|
||||
ran) ;;
|
||||
@@ -87,48 +75,7 @@ _zle-pj() {
|
||||
rm -f $state
|
||||
}
|
||||
zle -N pj-inline _zle-pj
|
||||
|
||||
# ctrl-z at the prompt (fish's _jobs_bind): fg the only job, or pick one from
|
||||
# the `jobs` tv cable, which reads the job table from $TV_JOBS (records:
|
||||
# "%<id> <state> <command>", id, process group). While a job holds the
|
||||
# terminal ctrl-z is still the tty's suspend, so the key toggles.
|
||||
# fg runs as a real command line (push-input keeps typed text for the next
|
||||
# prompt); __jobs_bind_fg erases that echoed line and fg's "[1] continued"
|
||||
# notice. The leading space keeps it out of history (HIST_IGNORE_SPACE).
|
||||
__jobs_bind_fg() {
|
||||
printf '\033[A\033[2K\r' >/dev/tty
|
||||
fg %$1 2>/dev/null
|
||||
}
|
||||
_zle-jobs() {
|
||||
local -a ids recs
|
||||
local id pick file
|
||||
ids=(${(On)${(k)jobstates}})
|
||||
(( $#ids )) || return 0
|
||||
for id in $ids; do
|
||||
recs+=("$(printf '%%%s %-9s %s\t%s\t%s' $id ${jobstates[$id]%%:*} \
|
||||
"${jobtexts[$id]}" $id ${${jobstates[$id]#*:*:}%%=*})")
|
||||
done
|
||||
if (( $#ids == 1 )); then
|
||||
pick=$ids[1]
|
||||
else
|
||||
file=$(mktemp) || return
|
||||
print -rl -- $recs >$file
|
||||
zle -I
|
||||
_iris_busy start
|
||||
pick=$(TV_JOBS=$file tv jobs --inline </dev/tty)
|
||||
_iris_busy stop
|
||||
printf '\033[A' >/dev/tty
|
||||
rm -f $file
|
||||
if [[ -z $pick ]]; then
|
||||
zle reset-prompt
|
||||
return
|
||||
fi
|
||||
fi
|
||||
zle push-input
|
||||
BUFFER=" __jobs_bind_fg $pick"
|
||||
zle accept-line
|
||||
}
|
||||
zle -N jobs-fg _zle-jobs
|
||||
zle -N pj-down _zle-pj
|
||||
|
||||
bindkey '^E' tv-git-files
|
||||
bindkey '^B' run-purple
|
||||
@@ -141,7 +88,8 @@ bindkey '^A' run-omp-session
|
||||
# ctrl-f: yazi; yy cd's to yazi's exit dir on quit.
|
||||
bindkey '^F' run-yy
|
||||
bindkey '^G' run-lazygit
|
||||
bindkey '^Z' jobs-fg
|
||||
bindkey '^[[B' pj-down
|
||||
bindkey '^[OB' pj-down
|
||||
|
||||
# ctrl-q mirrors ctrl-d's preset (`exit`) — quit the shell.
|
||||
_zle-exit() { exit }
|
||||
|
||||
Reference in new issue
Block a user