This repository has been archived on 2024-03-04. You can view files and clone it, but cannot push or open issues or pull requests.
linux/.linux/bash/module/tmux.sh

58 lines
888 B
Bash
Raw Normal View History

2023-08-08 16:24:15 +03:00
# create/attach to named session.
ta()
{
local name="$1"
# set default name.
if [[ "$name" = "" ]]; then
name="main"
fi
# call tmux.
tmux new -s "$name" 2> /dev/null || tmux attach-session -t "$name"
}
# detach.
alias td="tmux detach-client"
# list.
alias tl="tmux list-sessions"
# rename.
alias tr="tmux rename-session"
# assign name (to window).
alias tn="tmux rename-window"
# kill specified session or default one.
tk()
{
local name="$1"
# set default name.
if [[ "$name" = "" ]]; then
name="main"
fi
# call tmux.
tmux kill-session -t "$name"
}
# kill all sessions.
tka()
{
local sessions=$(tmux list-sessions | sed -e 's/:.*//')
for session in $sessions; do
tmux kill-session -t "$session"
done
}
2023-10-23 00:24:36 +03:00
# autocompletes.
_ta()
{
_autocomplete_first "$(tmux list-sessions 2> /dev/null | sed -e 's/:.*//')"
2023-10-23 00:24:36 +03:00
}
2023-10-23 00:57:46 +03:00
complete -F _ta ta tk