mirror of
https://codeberg.org/vlw/dotfiles.git
synced 2025-11-05 01:12:42 +01:00
feat(tmux): add tmx function for attaching or creating a session
This commit is contained in:
parent
e0c4151ed9
commit
a6bb5ab1f9
1 changed files with 20 additions and 4 deletions
|
|
@ -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
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue