Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions demo/bin/zmx
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ list)
fi
printf 'zmx-picker.1\nscratch\n'
else
printf ' name=whatchord.1\tpid=52341\tclients=0\tcreated=1\tstart_dir=%s/src/whatchord\n' "$HOME"
printf ' name=whatchord.1\tpid=52341\tclients=0\tcreated=1\tcwd=%s/src/whatchord\n' "$HOME"
if [ -n "${ZMX_SESSION:-}" ]; then
printf '\342\206\222 name=%s\tpid=53347\tclients=1\tcreated=4\tstart_dir=%s/src/whatchord\n' "$ZMX_SESSION" "$HOME"
printf '\342\206\222 name=%s\tpid=53347\tclients=1\tcreated=4\tcwd=%s/src/whatchord\n' "$ZMX_SESSION" "$HOME"
fi
printf ' name=zmx-picker.1\tpid=52502\tclients=0\tcreated=2\tstart_dir=%s/src/zmx-picker\n' "$HOME"
printf ' name=scratch\tpid=53113\tclients=0\tcreated=3\tstart_dir=%s\n' "$HOME"
printf ' name=zmx-picker.1\tpid=52502\tclients=0\tcreated=2\tcwd=%s/src/zmx-picker\n' "$HOME"
printf ' name=scratch\tpid=53113\tclients=0\tcreated=3\tcwd=%s\n' "$HOME"
fi
;;
history)
Expand Down
12 changes: 6 additions & 6 deletions tests/bin/zmx
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ sessions() {
if [ -e "$ZP_TEST_DIR/no-sessions" ]; then
return 0
fi
printf '\342\206\222 name=alpha.1\tpid=11\tclients=1\tcreated=1\tstart_dir=/tmp\n'
printf ' name=alpha.2\tpid=12\tclients=0\tcreated=2\tstart_dir=/tmp\n'
printf '\342\206\222 name=alpha.1\tpid=11\tclients=1\tcreated=1\tcwd=/tmp\n'
printf ' name=alpha.2\tpid=12\tclients=0\tcreated=2\tcwd=/tmp\n'
# beta carries labels (trailing tab-separated key=value fields)
# and lives in a repo, so it also guards against those fields
# leaking into start_dir and breaking the repo-association count.
printf ' name=beta\tpid=13\tclients=0\tcreated=3\tstart_dir=%s\tproject=zp\tenv=work\n' \
# leaking into cwd and breaking the repo-association count.
printf ' name=beta\tpid=13\tclients=0\tcreated=3\tcwd=%s\tproject=zp\tenv=work\n' \
"$ZP_TEST_DIR/root/plain"
printf ' name=d.gamma\tpid=14\tclients=0\tcreated=4\tstart_dir=/tmp\n'
printf ' name=d.omega.9\tpid=15\tclients=0\tcreated=5\tstart_dir=/tmp\n'
printf ' name=d.gamma\tpid=14\tclients=0\tcreated=4\tcwd=/tmp\n'
printf ' name=d.omega.9\tpid=15\tclients=0\tcreated=5\tcwd=/tmp\n'
}

alive() {
Expand Down
14 changes: 10 additions & 4 deletions zp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# shellcheck disable=SC2016 # literal $VARs in single quotes are deliberate
set -euo pipefail

version=0.3.0
version=0.4.0

# Absolute path to this script, for fzf reload bindings.
self=$(cd "$(dirname "$0")" && pwd)/${0##*/}
Expand Down Expand Up @@ -71,11 +71,17 @@ candidates() {
while IFS=$'\t' read -r name _ clients _ dir labels; do
name=${name#*name=}
clients=${clients#*clients=}
# zmx >= 0.8.0 reports the live working directory as cwd=
# (tracked via OSC 7); older versions reported the directory
# the session was created in as start_dir=. Accept either so
# the path column and repo session counts keep working.
dir=${dir#*cwd=}
dir=${dir#*start_dir=}
# Any session labels arrive as extra tab-separated key=value
# fields after start_dir; slurping them into their own field
# keeps a stray tab out of $dir, which would corrupt the path
# and the start_dir match behind repo session counts. Join
# fields after the directory; slurping them into their own
# field keeps a stray tab out of $dir, which would corrupt
# the path and the cwd match behind repo session counts. Join
# them with spaces for display; absent labels leave it empty.
# them with spaces for display; absent labels leave it empty.
labels=${labels//$'\t'/ }

Expand Down
Loading