From 3b330aa2f8202180a62e1f29a9ba37cfae168358 Mon Sep 17 00:00:00 2001 From: Aaron Bull Schaefer Date: Sat, 18 Jul 2026 10:47:45 -0700 Subject: [PATCH 1/3] Make Enter act on the cursor row, not marked rows With --multi, fzf's accept returns the marked rows whenever any exist, so marking a repo for a later kill and then hitting Enter on a session silently created a numbered session from the forgotten mark instead. Marks only drive the ctrl-x kill flow, so Enter now clears them before accepting and always follows the cursor. --- tests/run.sh | 5 +++++ zp | 1 + 2 files changed, 6 insertions(+) diff --git a/tests/run.sh b/tests/run.sh index 5c723e9..37d13fe 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -89,6 +89,11 @@ run '' 'zzz-new' "$enter" >/dev/null || true assert_log 'enter on an unmatched query creates a session' \ 'ATTACH:\[zzz-new] PWD:*' +reset_log +run '' "$tab" "$enter" >/dev/null || true +assert_log 'enter follows the cursor even with other rows marked' \ + 'ATTACH:\[alpha.2] PWD:*' + reset_log run '' "$tab$tab" "$ctrl_x" "$esc" >/dev/null || true assert_log 'ctrl-x kills all marked sessions in one call' \ diff --git a/zp b/zp index c42719c..e22c482 100755 --- a/zp +++ b/zp @@ -277,6 +277,7 @@ select_session() { --ellipsis='…' \ --prompt='zmx> ' \ --header=$'Enter: select/create | Tab: mark\n^N: new from query | ^X: kill' \ + --bind='enter:clear-selection+accept' \ --bind="ctrl-x:execute-silent(printf '%s\n' {+} | $kill_cmd)+reload($reload_cmd)" \ --bind="focus:transform:test {1} = session && echo 'change-preview-window(follow)' || echo 'change-preview-window(nofollow)'" \ --preview="$preview_cmd" \ From 056e430a0ae5535ec585ae65f7f4dc16307f8f96 Mon Sep 17 00:00:00 2001 From: Aaron Bull Schaefer Date: Sat, 18 Jul 2026 10:54:06 -0700 Subject: [PATCH 2/3] Never let ctrl-n fall through to marked rows Ctrl-N with an empty query used to reuse the enter path's selection handling, so a forgotten mark could hijack it the same way. It now acts only on the query, and with nothing typed it reports there is nothing to create and exits 1, unlike a deliberate esc cancel. --- tests/run.sh | 10 ++++++++++ zp | 13 +++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/tests/run.sh b/tests/run.sh index 37d13fe..5aa82b0 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -84,6 +84,16 @@ run '' 'bet' "$ctrl_n" >/dev/null || true assert_log 'ctrl-n creates from the query even with a match highlighted' \ 'ATTACH:\[bet] PWD:*' +reset_log +rc=0 +run '' "$tab" "$ctrl_n" >/dev/null || rc=$? +if [[ $rc -eq 1 && -z $(log) ]]; then + ok 'ctrl-n with an empty query errors out, ignoring marks' +else + not_ok 'ctrl-n with an empty query errors out, ignoring marks' \ + "rc=$rc log=$(log)" +fi + reset_log run '' 'zzz-new' "$enter" >/dev/null || true assert_log 'enter on an unmatched query creates a session' \ diff --git a/zp b/zp index e22c482..2c4243d 100755 --- a/zp +++ b/zp @@ -297,11 +297,16 @@ select_session() { key=$(sed -n '2p' <<<"$output") selected=$(sed -n '3p' <<<"$output") - if [[ $key == ctrl-n && -n $query ]]; then - # Force a new session named after the query, even when a - # fuzzy match is highlighted. + if [[ $key == ctrl-n ]]; then + # Ctrl-N means "new from the query": force a session named + # after it even when a fuzzy match is highlighted, and never + # fall through to marked rows. + if [[ -z $query ]]; then + printf 'ctrl-n needs a typed query to name the new session\n' >&2 + return 1 + fi zmx attach "$query" - return + return 0 fi if [[ -n $selected ]]; then From 4907bd830dc4a60d2755c702eaea4f9ce3ea77c3 Mon Sep 17 00:00:00 2001 From: Aaron Bull Schaefer Date: Sat, 18 Jul 2026 10:56:43 -0700 Subject: [PATCH 3/3] Release v0.2.2 --- zp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zp b/zp index 2c4243d..6bd142c 100755 --- a/zp +++ b/zp @@ -6,7 +6,7 @@ # shellcheck disable=SC2016 # literal $VARs in single quotes are deliberate set -euo pipefail -version=0.2.1 +version=0.2.2 # Absolute path to this script, for fzf reload bindings. self=$(cd "$(dirname "$0")" && pwd)/${0##*/}