Last active
April 9, 2025 08:11
tmux.sh tmux layer to easy use
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# command | |
c="/usr/bin/tmux" | |
# type | |
t="start" | |
if [ -n "$1" ]; then | |
t=$1 | |
fi | |
# session | |
s="default" | |
if [ -n "$2" ]; then | |
s=$2 | |
fi | |
if [ "$t" == "start" ]; then | |
if ${c} has-session -t ${s} 2>/dev/null; then | |
echo "Session: ${s} is running, attaching..." | |
${c} attach-session -t ${s} | |
else | |
echo "Session ${s} is not running, creating..." | |
${c} new -s ${s} | |
fi | |
elif [ "$t" == "close" ]; then | |
if ${c} has-session -t ${s} 2>/dev/null; then | |
echo "Session: ${s} is running, closing..." | |
${c} detach-client | |
fi | |
elif [ "$t" == "exit" ]; then | |
if ${c} has-session -t ${s} 2>/dev/null; then | |
echo "Session: ${s} is running, exiting..." | |
${c} kill-session -t ${s} | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
start
tmux.sh
tmux.sh start
tmux.sh start session-name
close
tmux.sh close
exit
tmux.sh exit
tmux.sh exit session-name