diff options
author | Toby Vincent <tobyv13@gmail.com> | 2023-05-31 14:30:36 -0500 |
---|---|---|
committer | Toby Vincent <tobyv13@gmail.com> | 2023-05-31 14:30:36 -0500 |
commit | d4aaec6f29dc3d5c496df7d74035a3a33fa2b0fc (patch) | |
tree | 51d8c86f4d07d23070903ea8ad23df381f8a8713 /tmux | |
parent | 831eb21e3ead66be258e2c3aa678fd40d9163a80 (diff) |
refactor(tmux): make sessionizer more flexable
Diffstat (limited to 'tmux')
-rwxr-xr-x | tmux/.local/bin/tmux-sessionizer | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/tmux/.local/bin/tmux-sessionizer b/tmux/.local/bin/tmux-sessionizer index 5dd89a1..cf027a8 100755 --- a/tmux/.local/bin/tmux-sessionizer +++ b/tmux/.local/bin/tmux-sessionizer @@ -14,14 +14,18 @@ if [ "$#" -eq 0 ]; then ) fi -name=$(basename "$1" | tr . _) +if [ -z "$2" ]; then + if [ -z "$(tmux list-sessions -f "#{==:#{session_path},$1}" -F '#S' 2>/dev/null)" ]; then + tmux new-session -dc "$1" + fi -if ! tmux has-session -t="$name" 2>/dev/null; then - tmux new-session -ds "$name" -c "$1" + set -- "$1" "$(tmux list-sessions -f "#{==:#{session_path},$1}" -F '#S' 2>/dev/null)" +elif ! tmux has-session -t "$2" 2>/dev/null; then + tmux new-session -dc "$1" -s "$2" fi -if [ -z "$TMUX" ] && [ -z "$name" ]; then - tmux attach-session -t "$name" -elif tmux has-session -t="$name" 2>/dev/null; then - tmux switch-client -t "$name" +if [ -z "$TMUX" ] && [ -z "$2" ]; then + tmux attach-session -t "$2" +elif tmux has-session -t "$2" 2>/dev/null; then + tmux switch-client -t "$2" fi |