feat(tmux): add tmx function for attaching or creating a session

This commit is contained in:
Victor Westerlund 2025-10-03 12:18:17 +02:00
parent e0c4151ed9
commit a6bb5ab1f9
Signed by: vlw
GPG key ID: D0AD730E1057DFC6

View file

@ -5,10 +5,6 @@ alias phpa="sudo update-alternatives --config php"
# Kill all code-server processes. Sometimes it hangs on startup # Kill all code-server processes. Sometimes it hangs on startup
alias kvscode="ps uxa | grep .vscode-server | awk '{print $2}' | xargs kill -9" alias kvscode="ps uxa | grep .vscode-server | awk '{print $2}' | xargs kill -9"
# Tmux split commands, "q" for fast access, "w" for horizontal (right of q), "a" for vertical (below q)
alias qw="tmux split-window -h"
alias qa="tmux split-window -v"
# +-------------------+ # +-------------------+
# | Directory & Files | # | Directory & Files |
# +-------------------+ # +-------------------+
@ -197,3 +193,23 @@ sshl () {
ssh -p 2222 "$user"@local.vlw.se ssh -p 2222 "$user"@local.vlw.se
} }
# +------+
# | Tmux |
# +------+
# Tmux split commands, "q" for fast access, "w" for horizontal (right of q), "a" for vertical (below q)
alias qw="tmux split-window -h"
alias qa="tmux split-window -v"
tmx() {
# Check if any tmux sessions exist
if tmux has-session 2>/dev/null; then
# Attach to the first existing session
tmux attach-session -d -t $(tmux ls | head -n 1 | awk '{print $1}' | tr -d :)
return 0
fi
tmux new-session -s default
}