mskyaxl / wsl-terminal

Terminal emulator for Windows Subsystem for Linux (WSL)
MIT License
3.12k stars 158 forks source link

Open new window in tmux #114

Open abl0719 opened 6 years ago

abl0719 commented 6 years ago

Hi,

I set use_tmux=1 and added the following code in .bashrc. However, when I re-open wsl-terminal, it always opens a new window instead of attaching to the existing one. It seems that the $ATTACH_ONLY is always null in the session, thus, tmux new-window -c "$PWD" 2>/dev/null && exec tmux a is always called even if there is a exising window.

[[ -z "$TMUX" && -n "$USE_TMUX" ]] && {
    [[ -n "$ATTACH_ONLY" ]] && {
        tmux a 2>/dev/null || {
            cd && exec tmux
        }
        exit
    }
    tmux new-window -c "$PWD" 2>/dev/null && exec tmux a
    exec tmux
}