Skip to content

Instantly share code, notes, and snippets.

@yzdann
Last active November 29, 2020 19:00
Show Gist options
  • Save yzdann/a76ea51a269d748813f587d80dfa299c to your computer and use it in GitHub Desktop.
Save yzdann/a76ea51a269d748813f587d80dfa299c to your computer and use it in GitHub Desktop.
TMUX_WINDOW_ID=$(wmctrl -l | grep -i tmux | grep -i konsole | awk "/$rx/"'{print $1}' | head -1 )
TMUX_CURRENT_FIRST_SESSION=$(tmux list-session | cut -d':' -f1 | head -1)
echo $TMUX_WINDOW_ID
# activate the window terminal with tmux if existed
if [[ ! -z "$TMUX_WINDOW_ID" ]]; then
wmctrl -i -a $TMUX_WINDOW_ID
else
# attach to current session
if [[ ! -z "$TMUX_CURRENT_FIRST_SESSION" ]]; then
konsole -e "tmux attach -t $TMUX_CURRENT_FIRST_SESSION"
else
konsole -e tmux
fi
fi
tmux new-window
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment