mirror of
https://codeberg.org/vlw/dotfiles.git
synced 2026-01-11 21:36:00 +01:00
feat(tmux): add create and attach named sessions to tmx() (#78)
Reviewed-on: https://codeberg.org/vlw/dotfiles/pulls/78
This commit is contained in:
parent
29b13a52f2
commit
6433f7a86c
1 changed files with 21 additions and 5 deletions
|
|
@ -222,7 +222,12 @@ sshl () {
|
||||||
alias qw="tmux split-window -h"
|
alias qw="tmux split-window -h"
|
||||||
alias qa="tmux split-window -v"
|
alias qa="tmux split-window -v"
|
||||||
|
|
||||||
|
# Create or attach tmux sessions
|
||||||
tmx() {
|
tmx() {
|
||||||
|
local session_name="$1"
|
||||||
|
|
||||||
|
# Attach to the first available tmux session
|
||||||
|
if [[ -z "$session_name" ]]; then
|
||||||
# Check if any tmux sessions exist
|
# Check if any tmux sessions exist
|
||||||
if tmux has-session 2>/dev/null; then
|
if tmux has-session 2>/dev/null; then
|
||||||
# Attach to the first existing session
|
# Attach to the first existing session
|
||||||
|
|
@ -231,5 +236,16 @@ tmx() {
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Create a new session if none exists
|
||||||
tmux new-session -s default
|
tmux new-session -s default
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create a new named tmux session
|
||||||
|
if ! tmux has-session -t "$session_name" 2>/dev/null; then
|
||||||
|
tmux new-session -s "$session_name" -d
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Attach to named tmux session
|
||||||
|
tmux attach -t "$session_name"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue