<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Lukasz Piotrak</title>
    <description>The latest articles on DEV Community by Lukasz Piotrak (@techspresso).</description>
    <link>https://dev.to/techspresso</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1130203%2F5a3ba413-cac3-4358-a0b4-c57ddcae7a6b.png</url>
      <title>DEV Community: Lukasz Piotrak</title>
      <link>https://dev.to/techspresso</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/techspresso"/>
    <language>en</language>
    <item>
      <title>Tmux and VSCode - Persist Terminals for Productivity and Profit</title>
      <dc:creator>Lukasz Piotrak</dc:creator>
      <pubDate>Thu, 03 Aug 2023 17:41:56 +0000</pubDate>
      <link>https://dev.to/techspresso/tmux-and-vscode-persist-terminals-for-productivity-and-profit-2nd1</link>
      <guid>https://dev.to/techspresso/tmux-and-vscode-persist-terminals-for-productivity-and-profit-2nd1</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Originally published at &lt;a href="https://techspresso.dev/posts/tmux-and-vscode-persist-terminals-for-productivity-and-profit/" rel="noopener noreferrer"&gt;techspresso.dev&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Tired of reopening terminal windows every time you come back to a VSCode project? You can pick up right where you left off without having to re-run setup commands and reopen programs by using Tmux sessions. Read on to find out how.&lt;/p&gt;

&lt;p&gt;We'll cover:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What is Tmux&lt;/li&gt;
&lt;li&gt;Step-by-step setup for using Tmux in VSCode&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3lrrzulw7vmwk5jryvrk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3lrrzulw7vmwk5jryvrk.png" alt="Image description" width="800" height="557"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Introducing Tmux
&lt;/h2&gt;

&lt;p&gt;Tmux (Terminal Multiplexer) is basically a window manager for your terminal. It has two main functionalities:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Splitting the terminal into multiple windows and panes.&lt;/li&gt;
&lt;li&gt;Storing your terminal sessions in a server process, allowing you to reattach to the session even after closing your terminal instance.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Tmux is super powerful and has many use cases. For example, you can protecting your remote ssh terminal sessions from being nuked when dealing with a flaky connection.&lt;/p&gt;

&lt;p&gt;If you're not already familiar with this tool, I recommend &lt;a href="https://www.hamvocke.com/blog/a-quick-and-easy-guide-to-tmux/" rel="noopener noreferrer"&gt;Ham Vocke's "Quick and Easy Guide to tmux"&lt;/a&gt; to get started.&lt;/p&gt;

&lt;h2&gt;
  
  
  Instructions for setting up Tmux in VSCode
&lt;/h2&gt;

&lt;p&gt;To start persisting your terminal sessions using Tmux in VSCode:&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Make sure you have Tmux installed
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;If you're using macOS, you can use Homebrew by running the following command in your terminal:&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

  brew &lt;span class="nb"&gt;install &lt;/span&gt;tmux


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;For Ubuntu or WSL users, you can install it by executing:&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

  &lt;span class="nb"&gt;sudo &lt;/span&gt;apt-get &lt;span class="nb"&gt;install &lt;/span&gt;tmux


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;If you're using any other linux distro I'm sure you probably already know what you're doing&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 2: Add a new terminal profile
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Open VSCode settings with Cmd+Shift+P (macOS) or Ctrl+Shift+P (Windows/Linux)&lt;/li&gt;
&lt;li&gt;Search for &lt;code&gt;Open User Settings (JSON)&lt;/code&gt;. This will open the &lt;code&gt;settings.json&lt;/code&gt; file.&lt;/li&gt;
&lt;li&gt;Under &lt;code&gt;terminal.integrated.profiles.osx&lt;/code&gt; or &lt;code&gt;terminal.integrated.profiles.linux&lt;/code&gt;, add:&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="nl"&gt;"terminal.integrated.profiles.osx"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="err"&gt;//...existing&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;profiles...&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"tmux-shell"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"path"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"tmux"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"args"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"new-session"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"-A"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"-s"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"vscode:${workspaceFolder}"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;


&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This runs &lt;code&gt;tmux new-session&lt;/code&gt; on terminal startup, connecting to existing sessions named after the workspace folder. This way, if you've already created a terminal for this project, you'll connect back to it automatically!&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Set Tmux as the Default Terminal Profile
&lt;/h3&gt;

&lt;p&gt;Finally, to make the newly created Tmux profile the default for your system, add or modify the following line in the &lt;code&gt;settings.json&lt;/code&gt; file:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="nl"&gt;"terminal.integrated.defaultProfile.osx"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"tmux-shell"&lt;/span&gt;&lt;span class="w"&gt;


&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Now, every time you open VSCode terminal, Tmux will startup automatically, allowing you to pick up exactly where you left off last time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;We've gone over how to integrate Tmux into VSCode's integrated terminal. You can now use Tmux's powerful session and window management easily inside VSCode!&lt;/p&gt;

</description>
      <category>programming</category>
      <category>productivity</category>
      <category>linux</category>
      <category>vscode</category>
    </item>
  </channel>
</rss>
