mirror of
https://github.com/prdlk/dotfiles.git
synced 2026-11-02 19:32:43 +00:00
feat(cli): run commands in bottom split pane instead of new window
This commit is contained in:
1 parent
bdada99535
commit
4675841b88
1 file changed
+10
-10
@@ -10,9 +10,9 @@
|
|||||||
# pj-palette --cmd ROOT CMD…
|
# pj-palette --cmd ROOT CMD…
|
||||||
# run a quick-action command in ROOT
|
# run a quick-action command in ROOT
|
||||||
#
|
#
|
||||||
# Every item opens a new tmux window in the project root. The command runs in
|
# Every item opens a full-width split along the bottom of the window (25% of
|
||||||
# the foreground; when it exits the window keeps a shell (with the output
|
# its height) in the project root. The command runs in the foreground; when it
|
||||||
# above it) instead of closing.
|
# exits the pane keeps a shell (with the output above it) instead of closing.
|
||||||
|
|
||||||
set -uo pipefail
|
set -uo pipefail
|
||||||
self=$(readlink -f "$0")
|
self=$(readlink -f "$0")
|
||||||
@@ -56,15 +56,15 @@ icon_for() {
|
|||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
# tmux action that opens a new window in DIR running ARGV directly (no shell,
|
# tmux action that opens a full-width bottom split (25%) in DIR running ARGV
|
||||||
# so nothing is re-parsed by fish). The palette wrapper evals the string in
|
# directly (no shell, so nothing is re-parsed by fish). The palette wrapper
|
||||||
# bash, hence %q.
|
# evals the string in bash, hence %q.
|
||||||
window_action() {
|
split_action() {
|
||||||
local dir=$1
|
local dir=$1
|
||||||
shift
|
shift
|
||||||
local q
|
local q
|
||||||
q=$(printf '%q ' "$@")
|
q=$(printf '%q ' "$@")
|
||||||
printf 'new-window -c %q %s' "$dir" "$q"
|
printf 'split-window -v -f -l 25%% -c %q %s' "$dir" "$q"
|
||||||
}
|
}
|
||||||
|
|
||||||
items=()
|
items=()
|
||||||
@@ -76,7 +76,7 @@ item() { # category icon title description aliases(csv) tmux-action
|
|||||||
quick() { # icon title aliases dir argv…
|
quick() { # icon title aliases dir argv…
|
||||||
local icon=$1 title=$2 aliases=$3 dir=$4
|
local icon=$1 title=$2 aliases=$3 dir=$4
|
||||||
shift 4
|
shift 4
|
||||||
item Quick "$icon" "$title" "in ${dir/#$HOME/~}" "$aliases" "$(window_action "$dir" "$self" --cmd "$dir" "$@")"
|
item Quick "$icon" "$title" "in ${dir/#$HOME/~}" "$aliases" "$(split_action "$dir" "$self" --cmd "$dir" "$@")"
|
||||||
}
|
}
|
||||||
|
|
||||||
# ── Quick actions, from the files at the project root ─────────────────────
|
# ── Quick actions, from the files at the project root ─────────────────────
|
||||||
@@ -114,7 +114,7 @@ while IFS=$'\t' read -r display kind target troot runner _file; do
|
|||||||
desc="$runner $target"
|
desc="$runner $target"
|
||||||
[ "$troot" != "$root" ] && desc+=" (${troot#"$root"/})"
|
[ "$troot" != "$root" ] && desc+=" (${troot#"$root"/})"
|
||||||
item "Tasks: $tag" "$(icon_for "$tag")" "$target" "$desc" "" \
|
item "Tasks: $tag" "$(icon_for "$tag")" "$target" "$desc" "" \
|
||||||
"$(window_action "$troot" "$self" --run "$kind" "$target" "$troot" "$runner")"
|
"$(split_action "$troot" "$self" --run "$kind" "$target" "$troot" "$runner")"
|
||||||
done < <(PJ_QUIET=1 pj --list 2>/dev/null)
|
done < <(PJ_QUIET=1 pj --list 2>/dev/null)
|
||||||
|
|
||||||
if [ ${#items[@]} -eq 0 ]; then
|
if [ ${#items[@]} -eq 0 ]; then
|
||||||
|
|||||||
Reference in new issue
Block a user