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.

Revisions

  1. yzdann revised this gist Nov 29, 2020. 1 changed file with 9 additions and 1 deletion.
    10 changes: 9 additions & 1 deletion open-tmux-insted-of-terminal.sh
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,18 @@
    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
    konsole -e tmux
    # 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
  2. yzdann created this gist Nov 29, 2020.
    10 changes: 10 additions & 0 deletions open-tmux-insted-of-terminal.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    TMUX_WINDOW_ID=$(wmctrl -l | grep -i tmux | grep -i konsole | awk "/$rx/"'{print $1}' | head -1 )

    # activate the window terminal with tmux if existed
    if [[ ! -z "$TMUX_WINDOW_ID" ]]; then
    wmctrl -i -a $TMUX_WINDOW_ID
    else
    konsole -e tmux
    fi

    tmux new-window