Skip to content

Instantly share code, notes, and snippets.

@khalidx
Last active July 2, 2025 19:03
Show Gist options
  • Save khalidx/d1a7dbd8fb04111d6107042e127316af to your computer and use it in GitHub Desktop.
Save khalidx/d1a7dbd8fb04111d6107042e127316af to your computer and use it in GitHub Desktop.
How to use tmux when developing remotely with VSCode.

If you're using SSH with VSCode to develop on a remote server, this config will help you keep your terminal sessions around even if you are disconnected from the server.

This means you can log off and enjoy a coffee, and as long as your server is still up and running, you can connect back at any time and jump back into your terminal as you left it.

Start a session

tmux

Detach from a session, but keep it

Close your terminal in VSCode by clicking the trash icon beside your terminal name or type [CTRL]+[b] then [d]. This detaches the session but does not kill it.

Attach to a previous session

tmux list-sessions
tmux attach -t <session-number>

VSCode settings

If your remote server is Linux, set the following in your VSCode settings.json or .code-workspace file to make sure that you always open a new terminal with tmux instead of bash, so you don't forget typing tmux next time!

{
  "terminal.integrated.defaultProfile.linux": "tmux"
}

Now, clicking the plus icon in the VSCode terminal bar will automatically start a new tmux session for you.

If you need to attach a previous session, select the dropdown beside the plus icon in the VSCode terminal bar, and create a normal bash terminal. Then you can run tmux list-sessions to find the previous session you want to attach to.

tmux settings

These are some settings I personally use.

Add these to your ~/.tmux.conf file:

set -g mouse on
set -g history-limit 50000

Then, reload your tmux config with:

tmux source-file ~/.tmux.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment