Is there a command like switch-session [-np] that switches based on the order appearing in choose-session? #4811
Replies: 4 comments 1 reply
-
|
There is nothing builtin... I'd like it if You could make If you want S=$(tmux display -p '#{session_id}')
N=$(tmux ls -F '#{session_id}'|sort -nk2 -t'$'|sed -n "/^$S$/{n;p}")
if [ x$N = x ]; then
N=$(tmux ls -F '#{session_id}'|sort -nk2 -t'$'|head -1)
fi
tmux switchc -t$NAnd for previous: S=$(tmux display -p '#{session_id}')
N=$(tmux ls -F '#{session_id}'|sort -nk2 -t'$'|sed -n "1!{/^$S$/{x;p}}; h")
if [ x$N = x ]; then
N=$(tmux ls -F '#{session_id}'|sort -nk2 -t'$'|tail -1)
fi
tmux switchc -t$NThere may be a tidier way to do this using the |
Beta Was this translation helpful? Give feedback.
-
|
I see, so the ids are in the order I want. Thanks for the script, this is what I ended up using: bind -n M-S-Down run-shell "~/.dotfiles/scripts/switch-session.sh n"
bind -n M-S-Up run-shell "~/.dotfiles/scripts/switch-session.sh p"#!/usr/bin/env bash
SESSIONS=$(tmux ls -F "#{session_id}" | sort -nk2 -t"$")
CURRENT_SESSION=$(tmux display -p "#{session_id}")
if [[ $1 == p ]]; then
TARGET=$(echo "$SESSIONS" | sed -n "/^$CURRENT_SESSION$/{x;p}; h")
[[ -z $TARGET ]] && TARGET=$(echo "$SESSIONS" | tail -1)
else
TARGET=$(echo "$SESSIONS" | sed -n "/^$CURRENT_SESSION$/{n;p}")
[[ -z $TARGET ]] && TARGET=$(echo "$SESSIONS" | head -1)
fi
tmux switchc -t "$TARGET" |
Beta Was this translation helpful? Give feedback.
-
|
This feature has been implemented as of #4813. |
Beta Was this translation helpful? Give feedback.
-
|
This discussion has been automatically locked since there has not been any recent activity after it was closed. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I used these bindings assuming that they followed the same order order from choose-session and kept getting confused at where they would take me. I looked at the man page and found out about how they actually work but I cant find anything on choose-session or how to get the numbers it uses. I just want to go up and down this menu without actually opening it. Is there some way to output the sessions sorted by age?
Beta Was this translation helpful? Give feedback.
All reactions