mirror of
https://github.com/prdlk/dotfiles.git
synced 2026-11-02 11:32:42 +00:00
feat(cli): add PJ_STATE env handling for task state communication
This commit is contained in:
1 parent
e9a7fd1fde
commit
19aeed21ac
1 file changed
+8
-1
@@ -16,6 +16,10 @@
|
|||||||
# Env:
|
# Env:
|
||||||
# PJ_QUIET=1 suppress the "no task sources" error — the down-arrow
|
# PJ_QUIET=1 suppress the "no task sources" error — the down-arrow
|
||||||
# bindings use this, where an empty tree is the normal case.
|
# bindings use this, where an empty tree is the normal case.
|
||||||
|
# PJ_STATE=FILE key bindings pass a path; pj writes `open` to it when the
|
||||||
|
# picker opens and `pj --run` writes `ran`, so the binding
|
||||||
|
# can tell "no tasks" / "cancelled" / "task printed output"
|
||||||
|
# apart and redraw the prompt accordingly (tv --inline).
|
||||||
#
|
#
|
||||||
# Cable entry points (tab-separated record fields, see `--list`):
|
# Cable entry points (tab-separated record fields, see `--list`):
|
||||||
# pj --list print one record per task
|
# pj --list print one record per task
|
||||||
@@ -150,6 +154,8 @@ fi
|
|||||||
if [ "${1-}" = --run ]; then
|
if [ "${1-}" = --run ]; then
|
||||||
kind=${2-} target=${3-} root=${4-} runner=${5-}
|
kind=${2-} target=${3-} root=${4-} runner=${5-}
|
||||||
cd "$root" || exit 1
|
cd "$root" || exit 1
|
||||||
|
# Tell the key binding a task ran (its output now sits below the prompt).
|
||||||
|
[ -n "${PJ_STATE-}" ] && echo ran >"$PJ_STATE"
|
||||||
|
|
||||||
# Extra args from `pj a b …`, shell-quoted into $PJ_EXTRA by the picker.
|
# Extra args from `pj a b …`, shell-quoted into $PJ_EXTRA by the picker.
|
||||||
extra=()
|
extra=()
|
||||||
@@ -440,4 +446,5 @@ if [ $# -gt 0 ]; then
|
|||||||
PJ_EXTRA=$(printf '%q ' "$@")
|
PJ_EXTRA=$(printf '%q ' "$@")
|
||||||
export PJ_EXTRA
|
export PJ_EXTRA
|
||||||
fi
|
fi
|
||||||
tv pj --source-command "cat '$tmp'" --input-header "$primary"
|
[ -n "${PJ_STATE-}" ] && echo open >"$PJ_STATE"
|
||||||
|
tv pj --inline --source-command "cat '$tmp'" --input-header "$primary"
|
||||||
Reference in new issue
Block a user