<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Tmux on Haseeb Majid</title>
    <link>https://haseebmajid.dev/tags/tmux/</link>
    <description>Recent content in Tmux on Haseeb Majid</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en</language>
    <lastBuildDate>Sun, 10 Mar 2024 00:00:00 +0000</lastBuildDate><atom:link href="https://haseebmajid.dev/tags/tmux/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>TIL: Clean Up Tmux Service When Removed by Home Manager</title>
      <link>https://haseebmajid.dev/posts/2024-03-10-til-clean-up-tmux-service-when-removed-by-home-manager/</link>
      <pubDate>Sun, 10 Mar 2024 00:00:00 +0000</pubDate>
      
      <guid>https://haseebmajid.dev/posts/2024-03-10-til-clean-up-tmux-service-when-removed-by-home-manager/</guid>
      <description>&lt;p&gt;&lt;strong&gt;TIL: Clean Up Tmux Service When Removed by Home Manager&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Recently I stopped using tmux to try zellij, however I noticed when I removed tmux from my nix config. I was getting
the following error, when rebuilding my home-manager config:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;The user systemd session is degraded:
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  UNIT         LOAD   ACTIVE SUB    DESCRIPTION
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;● tmux.service loaded failed failed tmux default session &lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;detached&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Legend: LOAD   → Reflects whether the unit definition was properly loaded.
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        ACTIVE → The high-level unit activation state, i.e. generalization of SUB.
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        SUB    → The low-level unit activation state, values depend on unit type.
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I was wondering where this error was coming from, turns it the symlink to tmux.service has not been deleted that
nix would create.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p><strong>TIL: Clean Up Tmux Service When Removed by Home Manager</strong></p>
<p>Recently I stopped using tmux to try zellij, however I noticed when I removed tmux from my nix config. I was getting
the following error, when rebuilding my home-manager config:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">The user systemd session is degraded:
</span></span><span class="line"><span class="cl">  UNIT         LOAD   ACTIVE SUB    DESCRIPTION
</span></span><span class="line"><span class="cl">● tmux.service loaded failed failed tmux default session <span class="o">(</span>detached<span class="o">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">Legend: LOAD   → Reflects whether the unit definition was properly loaded.
</span></span><span class="line"><span class="cl">        ACTIVE → The high-level unit activation state, i.e. generalization of SUB.
</span></span><span class="line"><span class="cl">        SUB    → The low-level unit activation state, values depend on unit type.
</span></span></code></pre></div><p>I was wondering where this error was coming from, turns it the symlink to tmux.service has not been deleted that
nix would create.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">ls -al ~/.config/systemd/user/tmux.service
</span></span><span class="line"><span class="cl">Permissions Size User        Group       Date Modified Name
</span></span><span class="line"><span class="cl">.rw-rw-r--   <span class="m">453</span> haseebmajid haseebmajid <span class="m">22</span> Aug  <span class="m">2023</span>   /home/haseebmajid/.config/systemd/user/tmux.service
</span></span></code></pre></div><p>If we look at other systemd services we can see them symlinked to a nix package in the nix store.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">ls -al ~/.config/systemd/user
</span></span><span class="line"><span class="cl">lrwxrwxrwx     - haseebmajid haseebmajid <span class="m">20</span> Feb 17:04   spotifyd.service -&gt; /nix/store/7v52bpcyi0zqv012rrmd7s2r742hb2cy-home-manager-files/.config/systemd/user/spotifyd.service
</span></span><span class="line"><span class="cl">lrwxrwxrwx     - haseebmajid haseebmajid <span class="m">20</span> Feb 17:04   swayidle.service -&gt; /nix/store/7v52bpcyi0zqv012rrmd7s2r742hb2cy-home-manager-files/.config/systemd/user/swayidle.service
</span></span></code></pre></div><p>So we can simply remove the tmux file, <code>rm ~/.config/systemd/user/tmux.service</code>. I should look into why this symlink
is not removed.</p>
]]></content:encoded>
    </item>
    
    <item>
      <title>2023 In Summary, My Year of The Terminal</title>
      <link>https://haseebmajid.dev/posts/2023-12-31-2023-in-summary-my-year-of-the-terminal/</link>
      <pubDate>Sun, 31 Dec 2023 00:00:00 +0000</pubDate>
      
      <guid>https://haseebmajid.dev/posts/2023-12-31-2023-in-summary-my-year-of-the-terminal/</guid>
      <description>&lt;p&gt;For once, I am actually doing a year in review, to go over some of the things I&amp;rsquo;ve learnt over the last year.
Part of the reason is this has been probably my most transformative year since I have been a software engineer.
I have become far more terminal development driven, if that is a phrase one can use. What I mean is I changed my
development workflow to leverage being in the terminal more. I feel far more productive and efficient than I was at
the beginning of the year, for what it&amp;rsquo;s worth&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>For once, I am actually doing a year in review, to go over some of the things I&rsquo;ve learnt over the last year.
Part of the reason is this has been probably my most transformative year since I have been a software engineer.
I have become far more terminal development driven, if that is a phrase one can use. What I mean is I changed my
development workflow to leverage being in the terminal more. I feel far more productive and efficient than I was at
the beginning of the year, for what it&rsquo;s worth</p>
<p>The following sections will break down what I learnt, why I found it useful. The sections are ordered roughly in
the order I learnt the tool/thing throughout the year.</p>
<h2 id="neovim">Neovim</h2>
<p>The first big change I made was in April. I moved away from using VS Code to Neovim, mostly to flex on other developers
(joking of course). I had a colleague who started to have a look at Neovim, and I was intrigued at the things you can
now do in Neovim. It looked like it had all the main features I was using in VS Code.</p>
<p>I originally started using <a href="https://astronvim.com/">Astronvim</a>, but when I started adding my own plugins I found I broke it effortlessly, probably
a layer 8 issue. I then moved over to <a href="https://www.lazyvim.org/">Folke&rsquo;s LazyVim</a>, which had much better defaults and plugins for what I wanted.</p>
<p>Furthermore, I also took this as an opportunity to learn more vim binding and to become more efficient in vim. As I had got a bit
complacent with my current knowledge of vim bindings and shortcuts to move around and edit code.</p>
<p>Eventually, I ended up creating my own configuration, which most people recommend trying to do. I ended up using NixVim
to do this (more on NixOS later). But it was very useful to be able to see what Neovim could do, before I started
on my own config.</p>
<p>Since VS Code and my Neovim config both use the same LSP behind the scenes gopls, for Golang development I wasn&rsquo;t really
missing out on any features that VS Code offered over Neovim. Except perhaps remote sharing.</p>
<p>So why use Neovim:</p>
<ul>
<li>As most things with me and using Linux, I like to be able to customise and personalise things for myself</li>
<li>Requires fewer resources to run compared with my old editor</li>
<li>Runs in the terminal so can use it with tmux</li>
<li>Forced me to learn my tools a lot better</li>
</ul>
<p>By staying in the terminal, it allowed me to use tmux with Neovim, and manage my different projects much easier. It also
made it a lot more efficient to jump between different projects. Which is very useful when working with microservices.</p>
<p>If you want to use Neovim, I recommend doing the following:</p>
<ul>
<li>learn vim bindings, use a plugin in your current editor</li>
<li>use a distribution like LazyVim</li>
<li>write your own config</li>
<li>alongside this, look at other peoples&rsquo; workflow and see what you like, i.e. using tmux.</li>
</ul>
<p>Some of my favourite plugins:</p>
<ul>
<li>telescope of course</li>
<li>dap for debugging</li>
<li>neotest for testing</li>
<li>oil, for managing folders and files</li>
<li>codeium for AI completions</li>
</ul>
<h3 id="tmux">Tmux</h3>
<p>One of the main reasons I ended up moving to Neovim was that I was able to stay in the terminal more. I found a really
good workflow with Tmux. Where each folder/repository, would be a separate session in tmux. I would then use a the <a href="https://github.com/joshmedeski/t-smart-tmux-session-manager">
t smart session manager</a>, with the tmux resurrect and continuum plugins to help manage my sessions I have.</p>
<p>Tmux is a multiplexer, with a client server architecture, which means I can kill the terminal and the session still is
alive on the server. It also means I could open terminal windows effortlessly. Creating splits with ease. It also
stopped me from having a hundred VS Code instances open and trying to work out which one is the one I need.</p>
<p>For me, whilst Neovim was really cool to learn, combining it with tmux was a real game changer for my workflow. It just
made me feel so much more efficient, jumping between sessions, without needing a mouse being able to be more keyboard
driven.</p>
<h2 id="touch-typing">Touch Typing</h2>
<p>To become a more efficient developer, I also started to learn how to touch type properly, using all 5 of my fingers vs
previously relying mostly on two fingers. Even though I could type at a decent speed of 80 WPM, I would make plenty of mistakes.
Eventually, it would be much better for my wrists and fingers to touch type properly. Using several tools such as
typing club and monkey type. I was able to get back to my normal typing speed in a few months, which fewer mistakes.</p>
<p>Especially as I was now trying to use my vim bindings, and expanding my knowledge of vim shortcuts, I didn&rsquo;t want to have
to think where certain letters were or go and redo a shortcut because I made a mistake.</p>
<p>If you don&rsquo;t know how to touch type, I would recommend spending the effort, Especially if you look down when you type
it&rsquo;s better for you ergonomically and will be better for you eventually, I think.</p>
<h2 id="nixos">NixOS</h2>
<p>One of the other significant changes was in May I moved from Arch (I used arch btw), to shock surprise NixOS. I divided straight
into it. Which probably wasn&rsquo;t the cleverest thing I&rsquo;ve ever done. As there was a steep learning curve. I&rsquo;ve written
some previous articles which go more into detail about NixOS and how I set it up.</p>
<p><img
        loading="lazy"
        src="/posts/2023-12-31-2023-in-summary-my-year-of-the-terminal/images/btw.jpg"
        type=""
        alt="NixOS"
        
      /></p>
<p>The best thing about Nix was I can use declaratively set up my config, which makes it easier to keep multiple machines
in sync. I also think alongside home-manager it makes managing my user, such as installing software and config
for the apps. So even when I use another OS, I can still use nix and share config between multiple machines.</p>
<p>At times, it does feel like I am fighting the OS, especially when the package I need is not in nixpkgs, but overall, I am
happy to be able to keep all my config in code. Sync multiple devices. Also being able to revert to older
generations, making it harder to break my system.</p>
<p>I think where nix is powerful is its development environments you can create using nix flakes. Which solves a
lot of issues I had with dev containers. Making sure people have the same versions of the tools they require for a project.</p>
<p>So why use NixOS:</p>
<ul>
<li>declarative: put your config in code</li>
<li>rollbacks: easy to rollback changes</li>
<li>multiple versions of the same tool, installed</li>
</ul>
<p>If you want to use NixOS, I recommend doing the following:</p>
<ul>
<li>Try nix package manager on your current setup</li>
<li>Try NixOS in a VM</li>
<li>Move to NixOS, installing via an ISO</li>
<li>Look at nix flakes, for even more reproducibility</li>
</ul>
<p>You can read more about my basic <a href="https://haseebmajid.dev/posts/2023-10-24-part-2-how-to-setup-nixos-as-part-of-your-development-workflow/">setup here</a></p>
<h2 id="hyprland">Hyprland</h2>
<p>Alongside moving to NixOS, soon after I moved away from Gnome to Hyprland I wanted to have another go at a tiling window manager.
I kept seeing people using Hyprland, I tried a tiling manager QTile but found it a pain to
set everything up myself, that of a normal desktop environment.</p>
<p>Hyprland is nice because Wayland support, you might be thinking, why not use sway. I ended up using Hyprland because
the desktop sharing support was better with its own desktop portals fork. Allowing me to share a specific window
rather than my entire screen. This made it more practical to use at work. It also has a few nice features that people like
when ricing, like rounded corners, gaps and also some slick animations.</p>
<p>Other than that, a tiling manager allows you  to customise your setup to almost exactly whatever you want, as you
have to set up things like a notification daemon, app launcher and a status bar if you want one. It also allows us to
be more keyboard focused.</p>
<p>I think Hyprland has helped me use the keyboard more, relying on the mouse less. Allowing to be organised more
keeping different apps in different workspaces. Such as one for my main, another for the browser and for my to-dos etc.</p>
<p>You can read more about my <a href="https://haseebmajid.dev/posts/2023-11-15-part-3-hyprland-as-part-of-your-development-workflow/">Hyprland setup here</a></p>
<h2 id="split-keyboard">Split Keyboard</h2>
<p>Another one I copied from a colleague at work, he used a split keyboard so very late into the year, around December
I decided to take the plunge and buy a ZSA Voyager. Split keyboards, also sometimes called ergonomic keyboards, have
several benefits, here is a <a href="https://www.youtube.com/watch?v=76eALNFp3kk">link</a> to the video that finally convinced me.</p>
<p>The main advantages are because its split it opens up your chest, the keys are column staggered and so your fingers
just need to go up and down rather to the side. They are not cheap, however, and are quite an investment. So this
It would be something I upgrade after having most of the rest of your setup, such as a mouse, monitors etc. As a stop
gap mechanical keyboards are plenty affordable these days. You can get some fantastic ones cheapish, especially if
you can get it during a sale.</p>
<h2 id="desktop-vs-laptop">Desktop vs Laptop</h2>
<p>I bought a framework laptop, with an eGPU and then removed my desktop, and have had two stints trying to just live using
my laptop. Which is cool as it&rsquo;s more portable and when it&rsquo;s on my desk I can make more of a workstation. Close the lid
and connect it to all my peripherals, giving me a desktop like experience. Two monitors, keyboard, mouse, webcam and mic
etc.</p>
<p>Especially with the AMD motherboard, I am even able to play some games with minimal lag on 4k monitors without an
eGPU, such as gw2 and master duel (I know not very extensive games but still very cool).</p>
<p>I tried it earlier in the year and gave up on it and moved back to my desktop as it made gaming easier. But I am going
to give it another crack, especially with an AMD board, making Guild Wars 2 playable.</p>
]]></content:encoded>
    </item>
    
    <item>
      <title>TIL: How to Title Your Terminals When Running Tmux</title>
      <link>https://haseebmajid.dev/posts/2023-11-22-til-how-to-title-your-terminals-when-running-tmux/</link>
      <pubDate>Wed, 22 Nov 2023 00:00:00 +0000</pubDate>
      
      <guid>https://haseebmajid.dev/posts/2023-11-22-til-how-to-title-your-terminals-when-running-tmux/</guid>
      <description>&lt;p&gt;&lt;strong&gt;TIL: How to Title Your Terminals When Running Tmux&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I have been tmux with the foot terminal and when trying to share my screen I couldn&amp;rsquo;t work out which terminal to share
based on the name. Since they are running tmux, all the terminals were titled &lt;code&gt;terminal - t&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;To fix this and name it after what is running (and where) in tmux, i.e. &lt;code&gt;foot blog/nvim&lt;/code&gt;. We can do this by adding the
following to our tmux config:&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p><strong>TIL: How to Title Your Terminals When Running Tmux</strong></p>
<p>I have been tmux with the foot terminal and when trying to share my screen I couldn&rsquo;t work out which terminal to share
based on the name. Since they are running tmux, all the terminals were titled <code>terminal - t</code>.</p>
<p>To fix this and name it after what is running (and where) in tmux, i.e. <code>foot blog/nvim</code>. We can do this by adding the
following to our tmux config:</p>
<pre tabindex="0"><code class="language-tmux" data-lang="tmux">set-option -g set-titles on
set-option -g set-titles-string &#34;#S / #W&#34;
</code></pre><p>Here, the <code>#S</code> is the session name and <code>#W</code> the window name; hence, we get something like the above. Though you could use
lots of other different formats <sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup>.</p>
<p>This is enough for me to figure out which window to share.</p>
<div class="footnotes" role="doc-endnotes">
<hr>
<ol>
<li id="fn:1">
<p><a href="https://github.com/tmux/tmux/wiki/Formats">https://github.com/tmux/tmux/wiki/Formats</a>&#160;<a href="#fnref:1" class="footnote-backref" role="doc-backlink">&#x21a9;&#xfe0e;</a></p>
</li>
</ol>
</div>
]]></content:encoded>
    </item>
    
    <item>
      <title>TIL: How to Fix tmux-resurrect on NixOS</title>
      <link>https://haseebmajid.dev/posts/2023-09-01-til-how-to-fix-tmux-resurrect-on-nixos/</link>
      <pubDate>Fri, 01 Sep 2023 00:00:00 +0000</pubDate>
      
      <guid>https://haseebmajid.dev/posts/2023-09-01-til-how-to-fix-tmux-resurrect-on-nixos/</guid>
      <description>&lt;p&gt;&lt;strong&gt;TIL: How to Fix tmux-resurrect on NixOS&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;When I moved to NixOS I noticed that &lt;a href=&#34;https://github.com/tmux-plugins/tmux-resurrect&#34;&gt; tmux-resurrect &lt;/a&gt; stop restoring
some applications such as &lt;code&gt;man&lt;/code&gt; and &lt;code&gt;nvim&lt;/code&gt;. Like it used to on my Arch machine. I recently found a solution to my
problem (thanks to a lovely chap on the nixos discourse).&lt;/p&gt;
&lt;p&gt;By adding the following lines to our tmux config:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code class=&#34;language-tmux&#34; data-lang=&#34;tmux&#34;&gt;resurrect_dir=&amp;#34;$HOME/.tmux/resurrect&amp;#34;
set -g @resurrect-dir $resurrect_dir
set -g @resurrect-hook-post-save-all &amp;#39;target=$(readlink -f $resurrect_dir/last); sed &amp;#34;s| --cmd .*-vim-pack-dir||g; s|/etc/profiles/per-user/$USER/bin/||g; s|/home/$USER/.nix-profile/bin/||g&amp;#34; $target | sponge $target&amp;#39;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;What this does is it edits the tmux-resurrect file from this:&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p><strong>TIL: How to Fix tmux-resurrect on NixOS</strong></p>
<p>When I moved to NixOS I noticed that <a href="https://github.com/tmux-plugins/tmux-resurrect"> tmux-resurrect </a> stop restoring
some applications such as <code>man</code> and <code>nvim</code>. Like it used to on my Arch machine. I recently found a solution to my
problem (thanks to a lovely chap on the nixos discourse).</p>
<p>By adding the following lines to our tmux config:</p>
<pre tabindex="0"><code class="language-tmux" data-lang="tmux">resurrect_dir=&#34;$HOME/.tmux/resurrect&#34;
set -g @resurrect-dir $resurrect_dir
set -g @resurrect-hook-post-save-all &#39;target=$(readlink -f $resurrect_dir/last); sed &#34;s| --cmd .*-vim-pack-dir||g; s|/etc/profiles/per-user/$USER/bin/||g; s|/home/$USER/.nix-profile/bin/||g&#34; $target | sponge $target&#39;
</code></pre><p>What this does is it edits the tmux-resurrect file from this:</p>
<pre tabindex="0"><code># bat ~/.tmux/resurrect/last --plain

pane    dotfiles    0   1   :*  0   nvim ~/dotfiles :/home/haseeb/dotfiles  1   nvim    :/home/haseeb/.nix-profile/bin/nvim --cmd lua vim.g.loaded_node_provider=0;vim.g.loaded_perl_provider=0;vim.g.loaded_python_provider=0;vim.g.python3_host_prog=&#39;/nix/store/4n4d0f1xd14gl4pfymdcqb9pmagcyyfj-neovim-0.9.1/bin/nvim-python3&#39;;vim.g.ruby_host_prog=&#39;/nix/store/4n4d0f1xd14gl4pfymdcqb9pmagcyyfj-neovim-0.9.1/bin/nvim-ruby&#39;
</code></pre><p>to this:</p>
<pre tabindex="0"><code># bat ~/.tmux/resurrect/last --plain

pane    dotfiles    0   1   :*  0   nvim ~/dotfiles :/home/haseeb/dotfiles  1   nvim    :nvim
</code></pre><p>NOTE: we are just left with <code>:nvim</code> as the binary to run (from tmux-resurrect perspective).
Then to restore my neovim session we could use a plugin which creates a <code>Session.vim</code> file in the local directory
of that project, that tmux-resurrect can use to restore the actual neovim session rather than just running neovim.</p>
<p>However I don&rsquo;t want to manage session files like that. So I use <a href="https://github.com/rmagatti/auto-session"> <code>auto-session</code> </a>
which checks if a session exists in a specific directory and if it does it automatically restores the last saved session
when neovim opens.</p>
<h2 id="appendix">Appendix</h2>
<ul>
<li><a href="https://discourse.nixos.org/t/how-to-get-tmux-resurrect-to-restore-neovim-sessions/30819/2">Discourse Thread</a></li>
<li><a href="https://gitlab.com/hmajid2301/dotfiles/-/blob/06bf4ad267beb6693b941ef51d880e4d0fc1df0a/home-manager/programs/multiplexers/tmux.nix#L136-147">My tmux config</a></li>
</ul>
]]></content:encoded>
    </item>
    
    <item>
      <title>Setting Up Tmux With Nix Home Manager</title>
      <link>https://haseebmajid.dev/posts/2023-07-10-setting-up-tmux-with-nix-home-manager/</link>
      <pubDate>Mon, 10 Jul 2023 00:00:00 +0000</pubDate>
      
      <guid>https://haseebmajid.dev/posts/2023-07-10-setting-up-tmux-with-nix-home-manager/</guid>
      <description>&lt;h2 id=&#34;introduction&#34;&gt;Introduction&lt;/h2&gt;
&lt;p&gt;In this post I will show you how you can setup tmux (plugins) using the nix package manager, specifically using home-manager.
I will also show you how you can avoid an issue I encountered where tmux resurrect wasn&amp;rsquo;t working properly due to
plugin ordering.&lt;/p&gt;
&lt;p&gt;Typically we use the &lt;a href=&#34;https://github.com/tmux-plugins/tpm&#34;&gt;tmux plugin manager&lt;/a&gt; to manage our tmux plugins.
However, when I moved to NixOS, I wanted to move away from having lots of different ways of managing what is on my
system. For example, on my Arch Linux machine I had:&lt;/p&gt;</description>
      <content:encoded><![CDATA[<h2 id="introduction">Introduction</h2>
<p>In this post I will show you how you can setup tmux (plugins) using the nix package manager, specifically using home-manager.
I will also show you how you can avoid an issue I encountered where tmux resurrect wasn&rsquo;t working properly due to
plugin ordering.</p>
<p>Typically we use the <a href="https://github.com/tmux-plugins/tpm">tmux plugin manager</a> to manage our tmux plugins.
However, when I moved to NixOS, I wanted to move away from having lots of different ways of managing what is on my
system. For example, on my Arch Linux machine I had:</p>
<ul>
<li>Pacman/Yay</li>
<li>lazyvim</li>
<li>tpm</li>
</ul>
<p>However, it wasn&rsquo;t obvious how to do this. In my case, I decided to use <a href="https://nixos.wiki/wiki/Home_Manager">home-manager</a>
which is a tool we can use with
Nix to manage user config including dotfiles. For tmux specifically, there is a module we can leverage. So assuming
you already have home manager and Nix setup. We can create a new module, say called <code>tmux.nix</code></p>
<h2 id="tmuxnix">tmux.nix</h2>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-nix" data-lang="nix"><span class="line"><span class="cl"><span class="p">{</span> <span class="n">pkgs</span><span class="o">,</span> <span class="o">...</span> <span class="p">}:</span>
</span></span><span class="line"><span class="cl"><span class="k">let</span>
</span></span><span class="line"><span class="cl">  <span class="n">tmux-super-fingers</span> <span class="o">=</span> <span class="n">pkgs</span><span class="o">.</span><span class="n">tmuxPlugins</span><span class="o">.</span><span class="n">mkTmuxPlugin</span>
</span></span><span class="line"><span class="cl">    <span class="p">{</span>
</span></span><span class="line"><span class="cl">      <span class="n">pluginName</span> <span class="o">=</span> <span class="s2">&#34;tmux-super-fingers&#34;</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">      <span class="n">version</span> <span class="o">=</span> <span class="s2">&#34;unstable-2023-01-06&#34;</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">      <span class="n">src</span> <span class="o">=</span> <span class="n">pkgs</span><span class="o">.</span><span class="n">fetchFromGitHub</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">        <span class="n">owner</span> <span class="o">=</span> <span class="s2">&#34;artemave&#34;</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">        <span class="n">repo</span> <span class="o">=</span> <span class="s2">&#34;tmux_super_fingers&#34;</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">        <span class="n">rev</span> <span class="o">=</span> <span class="s2">&#34;2c12044984124e74e21a5a87d00f844083e4bdf7&#34;</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">        <span class="n">sha256</span> <span class="o">=</span> <span class="s2">&#34;sha256-cPZCV8xk9QpU49/7H8iGhQYK6JwWjviL29eWabuqruc=&#34;</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">      <span class="p">};</span>
</span></span><span class="line"><span class="cl">    <span class="p">};</span>
</span></span><span class="line"><span class="cl"><span class="k">in</span>
</span></span><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl">  <span class="n">programs</span><span class="o">.</span><span class="n">tmux</span> <span class="o">=</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="n">enable</span> <span class="o">=</span> <span class="no">true</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">    <span class="n">shell</span> <span class="o">=</span> <span class="s2">&#34;</span><span class="si">${</span><span class="n">pkgs</span><span class="o">.</span><span class="n">fish</span><span class="si">}</span><span class="s2">/bin/fish&#34;</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">    <span class="n">terminal</span> <span class="o">=</span> <span class="s2">&#34;tmux-256color&#34;</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">    <span class="n">historyLimit</span> <span class="o">=</span> <span class="mi">100000</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">    <span class="n">plugins</span> <span class="o">=</span> <span class="k">with</span> <span class="n">pkgs</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">      <span class="p">[</span>
</span></span><span class="line"><span class="cl">        <span class="p">{</span>
</span></span><span class="line"><span class="cl">          <span class="n">plugin</span> <span class="o">=</span> <span class="n">tmux-super-fingers</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">          <span class="n">extraConfig</span> <span class="o">=</span> <span class="s2">&#34;set -g @super-fingers-key f&#34;</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">        <span class="p">}</span>
</span></span><span class="line"><span class="cl">        <span class="n">tmuxPlugins</span><span class="o">.</span><span class="n">better-mouse-mode</span>
</span></span><span class="line"><span class="cl">      <span class="p">];</span>
</span></span><span class="line"><span class="cl">    <span class="n">extraConfig</span> <span class="o">=</span> <span class="s1">&#39;&#39;
</span></span></span><span class="line"><span class="cl"><span class="s1">    &#39;&#39;</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">  <span class="p">};</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre></div><p>In the file above there are a few key things I&rsquo;d like to discuss <code>programs.tmux.enable = true</code>, this automatically installs
tmux for us. We also set some other config options such as the shell to use and the history limit. Nix will automatically
add these to our tmux config file for us, which helps manage the config a bit easier in my opinion.</p>
<p>Next install tmux plugins available as a
<a href="https://search.nixos.org/packages?channel=unstable&amp;show=tmuxPlugins.better-mouse-mode&amp;from=0&amp;size=50&amp;sort=relevance&amp;type=packages&amp;query=better+mouse+mode">nix package</a> we can simply do:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-nix" data-lang="nix"><span class="line"><span class="cl"> <span class="n">plugins</span> <span class="err">=</span> <span class="k">with</span> <span class="n">pkgs</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">      <span class="p">[</span>
</span></span><span class="line"><span class="cl">        <span class="n">tmuxPlugins</span><span class="o">.</span><span class="n">better-mouse-mode</span>
</span></span><span class="line"><span class="cl">      <span class="p">];</span>
</span></span></code></pre></div><p>If however the plugin is not available, we can still install it like we did for tmux super fingers.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-nix" data-lang="nix"><span class="line"><span class="cl"><span class="n">tmux-super-fingers</span> <span class="err">=</span> <span class="n">pkgs</span><span class="o">.</span><span class="n">tmuxPlugins</span><span class="o">.</span><span class="n">mkTmuxPlugin</span>
</span></span><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="n">pluginName</span> <span class="o">=</span> <span class="s2">&#34;tmux-super-fingers&#34;</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">    <span class="n">version</span> <span class="o">=</span> <span class="s2">&#34;unstable-2023-01-06&#34;</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">    <span class="n">src</span> <span class="o">=</span> <span class="n">pkgs</span><span class="o">.</span><span class="n">fetchFromGitHub</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">        <span class="n">owner</span> <span class="o">=</span> <span class="s2">&#34;artemave&#34;</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">        <span class="n">repo</span> <span class="o">=</span> <span class="s2">&#34;tmux_super_fingers&#34;</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">        <span class="n">rev</span> <span class="o">=</span> <span class="s2">&#34;2c12044984124e74e21a5a87d00f844083e4bdf7&#34;</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">        <span class="n">sha256</span> <span class="o">=</span> <span class="s2">&#34;sha256-cPZCV8xk9QpU49/7H8iGhQYK6JwWjviL29eWabuqruc=&#34;</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">    <span class="p">};</span>
</span></span><span class="line"><span class="cl"><span class="p">};</span>
</span></span></code></pre></div><p>We tell home-manager where to get the plugin from on Git Hub,
which plugin we&rsquo;d like to install, and a specific revision (can be a tag or a commit sha). There is also a sha256, which
can be found when you run the <code>home-manager switch</code> command and leave the <code>sha256</code> field empty. It will initially fail
with the expected sha value which you can then copy over to the file.</p>
<p><img
        loading="lazy"
        src="/posts/2023-07-10-setting-up-tmux-with-nix-home-manager/images/example-sha.png"
        type=""
        alt="Example SHA"
        
      /></p>
<p>This sha is used to check if this derivation is already built by Nix and available to the machine, so we can skip
building it again. You can read more about it <a href="https://discourse.nixos.org/t/how-is-used-the-sha256-of-fetchfromgithub-exactly/4837">here</a>.</p>
<details
  class="notice warning"
  open="true"
>
    <summary class="notice-title">Using Same SHA</summary>
  
  <p>When I was first setting it up, I didn&rsquo;t fully realise what the sha256 was used for and shared between multiple plugins.
What will happen is that the first plugin will be installed. Then Nix will see that SHA is already installed so won&rsquo;t
install the remaining plugins.</p>
<p><strong>So make sure you add your plugins one at a time, to avoid this.</strong></p>

</details>

<p>Then we add it to our list of plugins we want to be installed. We can also specify extra config related to that plugin,
using the <code>extraConfig</code> field.
which I think helps organise our config a bit more, like so:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-nix" data-lang="nix"><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="n">plugin</span> <span class="o">=</span> <span class="n">tmux-super-fingers</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">    <span class="n">extraConfig</span> <span class="o">=</span> <span class="s2">&#34;set -g @super-fingers-key f&#34;</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre></div><h3 id="continuum--resurrect-issues">continuum &amp; resurrect issues</h3>
<p>I had some issues getting tmux resurrect and continuum to work on my new machine. It turned out it was due to the ordering
of my plugins. Any plugin that edits the right status bar, like the catppuccin theme plugin needs to go before these two.
Now my tmux sessions automatically save and reload themselves. So when I shut down my PC I can carry on from where I left.</p>
<p>Like so:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-nix" data-lang="nix"><span class="line"><span class="cl"><span class="c1"># must be before continuum edits right status bar</span>
</span></span><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="n">plugin</span> <span class="o">=</span> <span class="n">tmuxPlugins</span><span class="o">.</span><span class="n">catppuccin</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">    <span class="n">extraConfig</span> <span class="o">=</span> <span class="s1">&#39;&#39; 
</span></span></span><span class="line"><span class="cl"><span class="s1">    set -g @catppuccin_flavour &#39;frappe&#39;
</span></span></span><span class="line"><span class="cl"><span class="s1">    set -g @catppuccin_window_tabs_enabled on
</span></span></span><span class="line"><span class="cl"><span class="s1">    set -g @catppuccin_date_time &#34;%H:%M&#34;
</span></span></span><span class="line"><span class="cl"><span class="s1">    &#39;&#39;</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="n">plugin</span> <span class="o">=</span> <span class="n">tmuxPlugins</span><span class="o">.</span><span class="n">resurrect</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">    <span class="n">extraConfig</span> <span class="o">=</span> <span class="s1">&#39;&#39;
</span></span></span><span class="line"><span class="cl"><span class="s1">    set -g @resurrect-strategy-vim &#39;session&#39;
</span></span></span><span class="line"><span class="cl"><span class="s1">    set -g @resurrect-strategy-nvim &#39;session&#39;
</span></span></span><span class="line"><span class="cl"><span class="s1">    set -g @resurrect-capture-pane-contents &#39;on&#39;
</span></span></span><span class="line"><span class="cl"><span class="s1">    &#39;&#39;</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="n">plugin</span> <span class="o">=</span> <span class="n">tmuxPlugins</span><span class="o">.</span><span class="n">continuum</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">    <span class="n">extraConfig</span> <span class="o">=</span> <span class="s1">&#39;&#39;
</span></span></span><span class="line"><span class="cl"><span class="s1">    set -g @continuum-restore &#39;on&#39;
</span></span></span><span class="line"><span class="cl"><span class="s1">    set -g @continuum-boot &#39;on&#39;
</span></span></span><span class="line"><span class="cl"><span class="s1">    set -g @continuum-save-interval &#39;10&#39;
</span></span></span><span class="line"><span class="cl"><span class="s1">    &#39;&#39;</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre></div><p>I haven&rsquo;t worked out how to restore my nvim session, however. The resurrect plugin needs a session.vim file to do that.
For now, this is good enough, as I have a session manager with nvim itself so it is simply a button press to restore it.</p>
<p>If you are using home-manager make sure to import this module into your main home manager nix file such as <code>home.nix</code>.
Then you should be able to run <code>home-manager switch</code> to install the tmux, and its plugins and build the config at
<code>~/.config/tmux/tmux.conf</code>.</p>
<p><a href="https://gitlab.com/hmajid2301/dotfiles/-/blob/ccb08009df7e0d884db790bca57317748661e35b/home-manager/programs/tmux.nix">My tmux file</a></p>
]]></content:encoded>
    </item>
    
    <item>
      <title>My Development Workflow With Alacritty Fish Tmux Nvim</title>
      <link>https://haseebmajid.dev/posts/2023-05-02-my-development-workflow-with-alacritty-fish-tmux-nvim/</link>
      <pubDate>Tue, 02 May 2023 00:00:00 +0000</pubDate>
      
      <guid>https://haseebmajid.dev/posts/2023-05-02-my-development-workflow-with-alacritty-fish-tmux-nvim/</guid>
      <description>&lt;details
  class=&#34;notice info&#34;
  open=&#34;true&#34;
&gt;
    &lt;summary class=&#34;notice-title&#34;&gt;Workflows Change&lt;/summary&gt;
  
  This post is accurate as of date of publish. But likely will go stale, if I update my workflows I will likely publish
another post.
&lt;/details&gt;

&lt;p&gt;In this blog post, I will go over my current development workflow using the above tools namely, fish shell tmux and neovim.
I&amp;rsquo;ll be using the &lt;a href=&#34;https://gitlab.com/hmajid2301/dotfiles/-/tree/8da9d515234d050dc34703e94f647fd9cb40c61a&#34;&gt;dotfiles&lt;/a&gt;
found here.&lt;/p&gt;
&lt;p&gt;I aim to move away from using my mouse as much as possible as it just slows me down when my hands
are away from my keyboard.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<details
  class="notice info"
  open="true"
>
    <summary class="notice-title">Workflows Change</summary>
  
  This post is accurate as of date of publish. But likely will go stale, if I update my workflows I will likely publish
another post.
</details>

<p>In this blog post, I will go over my current development workflow using the above tools namely, fish shell tmux and neovim.
I&rsquo;ll be using the <a href="https://gitlab.com/hmajid2301/dotfiles/-/tree/8da9d515234d050dc34703e94f647fd9cb40c61a">dotfiles</a>
found here.</p>
<p>I aim to move away from using my mouse as much as possible as it just slows me down when my hands
are away from my keyboard.</p>
<details
  class="notice info"
  open="true"
>
    <summary class="notice-title">Theme</summary>
  
  I am using the catppuccin theme with the frappe variant.
</details>

<h2 id="alacritty">Alacritty</h2>
<p><a href="https://gitlab.com/hmajid2301/dotfiles/-/tree/8da9d515234d050dc34703e94f647fd9cb40c61a/alacritty">Link to config</a></p>
<p>This section should be pretty quick, <a href="https://alacritty.org/">alacritty</a> is the terminal I use on both Linux and MacOS.
I use it because it will run on Linux and MacOS so I can have a similar terminal between all of my devices where
I do any development. It is also GPU rendered so it should have better performance as compared with
the default terminals available on your OS.</p>
<p>It was born out of frustration with using vim inside tmux being slow. I haven&rsquo;t noticed
any issues with speed or lag when using alacritty that&rsquo;s the terminal I&rsquo;ll stick with.</p>
<p>Some people like to use <a href="https://sw.kovidgoyal.net/kitty/">kitty</a>, but I&rsquo;ve had no reason to swap yet.
One thing you cannot do in alacritty is open tabs, you can open multiple terminals or use tmux.</p>
<h3 id="config">config</h3>
<p>My Alacritty config doesn&rsquo;t have much of interest, except this snippet
which allows me to copy to my clipboard my selected text in the terminal and also right-click paste.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-yml" data-lang="yml"><span class="line"><span class="cl"><span class="nt">selection</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span><span class="nt">save_to_clipboard</span><span class="p">:</span><span class="w"> </span><span class="kc">true</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">mouse_bindings</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span>- {<span class="w"> </span><span class="nt">mouse: Right, action</span><span class="p">:</span><span class="w"> </span><span class="l">Paste }</span><span class="w">
</span></span></span></code></pre></div><p>However, as I&rsquo;m trying to use my mouse less this config is a lot less relevant</p>
<h4 id="macos">MacOS</h4>
<p>Since I want similar keymaps between Linux and MacOS I&rsquo;ve swapped the ctrl and super keys on my Mac.
So it matches my Linux machine and I don&rsquo;t have to memorise/get confused between
two different key bindings.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-yml" data-lang="yml"><span class="line"><span class="cl"><span class="nt">key_bindings</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span>- {<span class="w"> </span><span class="nt">key: C, mods: Command, chars</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;\x03&#34;</span><span class="w"> </span>}<span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span>- {<span class="w"> </span><span class="nt">key: D, mods: Command, chars</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;\x05&#34;</span><span class="w"> </span>}<span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span>- {<span class="w"> </span><span class="nt">key: R, mods: Command, chars</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;\x13&#34;</span><span class="w"> </span>}<span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span>- {<span class="w"> </span><span class="nt">key: W, mods: Command, chars</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;\x17&#34;</span><span class="w"> </span>}<span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span>- {<span class="w"> </span><span class="nt">key: A, mods: Command, chars</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;\x01&#34;</span><span class="w"> </span>}<span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span>- {<span class="w"> </span><span class="nt">key: H, mods: Command, chars</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;\x08&#34;</span><span class="w"> </span>}<span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span>- {<span class="w"> </span><span class="nt">key: J, mods: Command, chars</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;\x0A&#34;</span><span class="w"> </span>}<span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span>- {<span class="w"> </span><span class="nt">key: K, mods: Command, chars</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;\x0B&#34;</span><span class="w"> </span>}<span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span>- {<span class="w"> </span><span class="nt">key: L, mods: Command, chars</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;\x0C&#34;</span><span class="w"> </span>}<span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span>- {<span class="w"> </span><span class="nt">key: Back, mods: Super, chars</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;\x15&#34;</span><span class="w"> </span>}<span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span>- {<span class="w"> </span><span class="nt">key: Left, mods: Super, chars</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;\eb&#34;</span><span class="w"> </span>}<span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span>- {<span class="w"> </span><span class="nt">key: Right, mods: Super, chars</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;\ef&#34;</span><span class="w"> </span>}<span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span>- {<span class="w"> </span><span class="nt">key: Left, mods: Command, chars</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;\eOH&#34;</span><span class="nt">, mode</span><span class="p">:</span><span class="w"> </span><span class="l">AppCursor }</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span>- {<span class="w"> </span><span class="nt">key: Right, mods: Command, chars</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;\eOF&#34;</span><span class="nt">, mode</span><span class="p">:</span><span class="w"> </span><span class="l">AppCursor }</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span>- {<span class="w"> </span><span class="nt">key: J, mods: Alt, chars</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;\ej&#34;</span><span class="w"> </span>}<span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span>- {<span class="w"> </span><span class="nt">key: K, mods: Alt, chars</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;\ek&#34;</span><span class="w"> </span>}<span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span>- {<span class="w"> </span><span class="nt">key: H, mods: Alt, chars</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;\eh&#34;</span><span class="w"> </span>}<span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span>- {<span class="w"> </span><span class="nt">key: L, mods: Alt, chars</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;\el&#34;</span><span class="w"> </span>}<span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span>- {<span class="w"> </span><span class="nt">key: N, mods: Alt, chars</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;\en&#34;</span><span class="w"> </span>}<span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span>- {<span class="w"> </span><span class="nt">key: Minus, mods: Alt, chars</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;\e-&#34;</span><span class="w"> </span>}<span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span>- {<span class="w"> </span><span class="nt">key: Equals, mods: Alt, chars</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;\e=&#34;</span><span class="w"> </span>}<span class="w">
</span></span></span></code></pre></div><p>So here <code>ctrl + c</code> (remember my super and ctrl keys are swapped) will map to <code>super + c</code> in the terminal to kill a process.</p>
<h2 id="fish">fish</h2>
<p><a href="https://gitlab.com/hmajid2301/dotfiles/-/tree/8da9d515234d050dc34703e94f647fd9cb40c61a/fish">Link to config</a></p>
<p>I use <a href="https://fishshell.com/">fish</a> shell as my default shell. You can replicate a lot of the features I am about to
discuss in zsh as well, using extensions. However, I found it slowed down zsh a lot and it wasn&rsquo;t as responsive as fish.</p>
<p>You should know that fish shell is not POSIX compliant, which means you cannot always run bash commands in fish the
syntax sometimes will vary.</p>
<p>Some features I like in fish include:</p>
<p>Suggested commands as you type it will try to guess which command to run. The last one in your history that best matches.</p>
<p><a href="images/suggestion.png">Auto Suggestions</a></p>
<p>I&rsquo;m also a big fan of using abbreviations <sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup> which are similar to aliases except when you the &ldquo;alias&rdquo; it gets converted
to the actual command you want to run. Say we have:</p>
<p><code>__git.create_abbr gco        git checkout</code></p>
<p>When we type <code>gco</code> the shell will expand into <code>git checkout</code>. This has a few advantages now in your
shell history we have <code>git checkout</code> not <code>gco</code> making it easier to search through. Also, we know which command we will
type.</p>
<p>Fish also provides some syntax highlighting for our commands which makes them nicer to look at because colours are great!</p>
<h3 id="plugins">Plugins</h3>
<p>Some fish plugins I use include:</p>
<p><a href="https://github.com/PatrickF1/fzf.fish">PatrickF1/fzf</a> integrates fzf (powerful fuzzy finder) nicely with fish.
My main use case is improving reverse search seen below.</p>
<p><img
        loading="lazy"
        src="/posts/2023-05-02-my-development-workflow-with-alacritty-fish-tmux-nvim/images/reverse-search.png"
        type=""
        alt="Reverse Search"
        
      /></p>
<p>But it can allow you to do lots of other things such as searching for files <code>ctrl + alt + f</code>.</p>
<p><img
        loading="lazy"
        src="/posts/2023-05-02-my-development-workflow-with-alacritty-fish-tmux-nvim/images/file-search.png"
        type=""
        alt="File Search"
        
      /></p>
<p><a href="https://github.com/edc/bass">edc/bass</a> allows us to run bash utilities in fish shell.</p>
<h3 id="starship">Starship</h3>
<p>As my shell prompt, I use <a href="https://starship.rs/">starship prompt</a> a super customisable font with great defaults.</p>
<p><img
        loading="lazy"
        src="/posts/2023-05-02-my-development-workflow-with-alacritty-fish-tmux-nvim/images/prompt.png"
        type=""
        alt="Starship Prompt"
        
      /></p>
<p>But overall I could probably easily swap to zsh but I find fish to be more responsive and feel snappier. It has some
nice features which make our lives a bit easier.</p>
<h2 id="tmux">tmux</h2>
<p><a href="https://gitlab.com/hmajid2301/dotfiles/-/tree/8da9d515234d050dc34703e94f647fd9cb40c61a/tmux">Link to config</a></p>
<p>I mentioned <a href="https://github.com/tmux/tmux">tmux</a> above. What is tmux? Well, it is in the name itself.
It&rsquo;s a terminal multiplexer, what does that mean? Well, it means we can open multiple
panes (think of each as its separate terminal).</p>
<p>One nice feature of tmux is that say your terminal crashes and the tmux session will still be alive.
We can simply reattach to it later.</p>
<p><a href="images/tmux.png">Tmux Panes</a></p>
<p>In the image above we have 3 panes.</p>
<h3 id="session-vs-window-vs-pane">Session vs Window vs Pane</h3>
<p>tmux has this concept of sessions, windows and panes</p>
<p><img
        loading="lazy"
        src="/posts/2023-05-02-my-development-workflow-with-alacritty-fish-tmux-nvim/images/tmux-server.png"
        type=""
        alt="Tmux Architecture"
        
      /> <sup id="fnref:2"><a href="#fn:2" class="footnote-ref" role="doc-noteref">2</a></sup></p>
<ul>
<li>a session can have multiples windows (think of a window as tabs in a terminal)</li>
<li>a window can have multiple panes</li>
<li>a pane is where we run our commands</li>
</ul>
<p>Typically I create a new session for each project I am working on.
For example, at the moment I have the following sessions:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="c1"># tmux ls</span>
</span></span><span class="line"><span class="cl">blog: <span class="m">2</span> windows <span class="o">(</span>created Sun Apr <span class="m">30</span> 22:37:51 2023<span class="o">)</span> <span class="o">(</span>attached<span class="o">)</span>
</span></span><span class="line"><span class="cl">bookmarkey: <span class="m">2</span> windows <span class="o">(</span>created Sun Apr <span class="m">30</span> 20:15:51 2023<span class="o">)</span>
</span></span><span class="line"><span class="cl">dotfiles: <span class="m">1</span> windows <span class="o">(</span>created Sun Apr <span class="m">30</span> 20:15:51 2023<span class="o">)</span>
</span></span><span class="line"><span class="cl">talks: <span class="m">1</span> windows <span class="o">(</span>created Sun Apr <span class="m">30</span> 20:15:51 2023<span class="o">)</span>
</span></span></code></pre></div><p>Where bookmarkey, for example, has two windows one for the gui and one for the api, as it is a full-stack application.</p>
<h3 id="smart-session-manager">Smart Session Manager</h3>
<p>To help manage my sessions I use <a href="https://github.com/joshmedeski/t-smart-tmux-session-manager">tmux smart session manager</a>.
This amazing plugin allows us to create a new session in a specific folder.</p>
<p>Outside of tmux, I can use <code>t</code> to open this menu below:</p>
<p><img
        loading="lazy"
        src="/posts/2023-05-02-my-development-workflow-with-alacritty-fish-tmux-nvim/images/smart-manager.png"
        type=""
        alt="Smart Manager"
        
      /></p>
<p>Where you can see the existing sessions at the bottom see <code>blog</code>, <code>dotfiles</code> etc.
If I navigate to a folder where a session already exists it will automatically attach to that session.
Else it will create a session in that folder.</p>
<p>Note that plugin uses <a href="https://github.com/ajeetdsouza/zoxide">zoxide</a> which you can think of it as a smarter <code>cd</code>.
It keeps track of which folders we visit the most. For example, I have a folder at <code>~/projects/bookmarkey/gui</code>
since I visit it so often I can go to the folder by using this command <code>z gui</code>. The script combines this with the fzf fuzzy finding tool.
Provides a nice way to search through our folders and sessions.</p>
<p>Once I am done with a session I simply detach from it and swap to another session either by <code>&lt;prefix&gt; + d</code> or using the
<code>t</code> command or even within tmux <code>&lt;prefix&gt; + shift + t</code>, which brings up that search menu.</p>
<p>Essentially this means I can have all my different projects opened and set up just how I want but they are out of &ldquo;focus&rdquo;
until I need them. Making it easier to just focus on the project I am working on.</p>
<p>This was the plugin that convinced me to start using tmux.</p>
<h3 id="config-1">Config</h3>
<p>Some parts of my config that may be interesting</p>
<pre tabindex="0"><code class="language-conf" data-lang="conf">set-option -g prefix C-a
unbind-key C-b
bind-key C-a send-prefix

unbind %
unbind &#39;&#34;&#39;
bind | split-window -h -c &#34;#{pane_current_path}&#34;
bind - split-window -v -c &#34;#{pane_current_path}&#34;
</code></pre><p>I remap the prefix key from <code>ctrl + b</code> to <code>ctrl + a</code> and to create a split using <code>-</code> for horizontal and <code>|</code> for vertical
splits (all taken from other people&rsquo;s configs ofc 😅). These mappings just make more sense in my head and also are
similar to mappings to make splits in nvim as well.</p>
<p>The <code>-c &quot;#{pane_current_path}&quot;</code> part means when we open the new pane the working directory will be same as the current
pane it is opened from.</p>
<p>I use the following plugins:</p>
<pre tabindex="0"><code class="language-conf" data-lang="conf"># List of plugins
set -g @plugin &#39;tmux-plugins/tpm&#39;
set -g @plugin &#39;aserowy/tmux.nvim&#39;
set -g @plugin &#39;joshmedeski/t-smart-tmux-session-manager&#39;
set -g @plugin &#39;ofirgall/tmux-window-name&#39;
set -g @plugin &#39;tmux-plugins/tmux-resurrect&#39;
set -g @plugin &#39;tmux-plugins/tmux-continuum&#39;
set -g @plugin &#39;ofirgall/tmux-browser&#39;

run &#39;~/.tmux/plugins/tpm/tpm&#39;
</code></pre><p>They are set up using the <a href="https://github.com/tmux-plugins/tpm">tpm</a>. Then to install any new plugins you add to your
config you can do <code>&lt;prefix&gt; + shift + I</code>.</p>
<ul>
<li>aserowy/tmux.nvim: Installed in tmux and nvim allows for easier navigation between the two</li>
<li>joshmedeski/t-smart-tmux-session-manager: We spoke about this above, easier session management</li>
<li>tmux-plugins/tmux-resurrect: This and tmux-continuum are used to save and restore sessions so they persist even after shutdown</li>
<li>ofirgall/tmux-browser: It opens a browser when you attach and closes when you detach</li>
</ul>
<p>For restoring sessions:</p>
<pre tabindex="0"><code class="language-conf" data-lang="conf">## Restore Vim sessions
set -g @resurrect-strategy-vim &#39;session&#39;
## Restore Neovim sessions
set -g @resurrect-strategy-nvim &#39;session&#39;
## Restore Panes
set -g @resurrect-capture-pane-contents &#39;on&#39;

## Restore last saved environment (automatically)
set -g @continuum-restore &#39;on&#39;
set -g @continuum-boot &#39;on&#39;
</code></pre><p>Resurrect allows us to save and restore a session, continuum will automate the saving and restoration of sessions.</p>
<h3 id="neovim">neovim</h3>
<details
  class="notice info"
  open="true"
>
    <summary class="notice-title">dotfiles</summary>
  
  These dotfiles are very likely to change.
</details>

<p><a href="https://github.com/hmajid2301/starter/tree/9281544559ce93b5202fdbad9c700c8d11ba77cf">Link to config</a></p>
<p>I recently swapped from VSCode to [neovim]((<a href="https://neovim.io/">https://neovim.io/</a>) mainly just to give it ago after watching some
other developers&rsquo; workflows on Youtube such as <a href="https://www.youtube.com/c/theprimeagen">Primeagen</a>,
<a href="https://www.youtube.com/@ElijahManor">Elijah Manor</a> and <a href="https://www.youtube.com/@dreamsofcode">Dreams of Code</a>.</p>
<p>Some advantages include it being more lightweight and feels a bit more responsive. If you want to be able to customise
everything about your editor then neovim is for you. However, there are neovim distributions like LunarVim,
Astronvim and Nvchad, which come with a bunch of plugins keybindings all set up for you.</p>
<p>In my case, I ended up using <a href="https://www.lazyvim.org/">LazyVim</a> which has some nice defaults but is more barebones than
some of the distributions I listed above.</p>
<h3 id="plugins-1">Plugins</h3>
<p>Telescope is an amazing plugin we can make it even better with a few small additions.</p>
<p><a href="https://github.com/jvgrootveld/telescope-zoxide">telescope-zoxide</a> allows us to use zoxide with telescope we can swap
folders on the fly. If we add a shortcut like this:</p>
<p><code>vim.keymap.set(&quot;n&quot;, &quot;&lt;leader&gt;mm&quot;, require(&quot;telescope&quot;).extensions.zoxide.list, { desc = &quot;Change directory using zoxide&quot; })</code></p>
<p><img
        loading="lazy"
        src="/posts/2023-05-02-my-development-workflow-with-alacritty-fish-tmux-nvim/images/telescope-zoxide.png"
        type=""
        alt="Zoxide"
        
      /></p>
<p><a href="https://github.com/debugloop/telescope-undo.nvim">telescope-undo</a> allows us to see updates we have done to our file,
allowing us to revert to a previous version.</p>
<p><code>vim.keymap.set(&quot;n&quot;, &quot;&lt;leader&gt;uu&quot;, &quot;&lt;cmd&gt;Telescope undo&lt;cr&gt;&quot;, { desc = &quot;Show undoo tree&quot; })</code></p>
<p>To integrate with tmux we also install the <a href="https://github.com/aserowy/tmux.nvim">aseorwy/tmux.nvim</a> in nvim.
Now we can navigate our nvim and splits to our tmux panes. Which means we can say have a terminal open at the bottom.
Then go to it by pressing <code>ctrl + k</code>.</p>
<p><img
        loading="lazy"
        src="/posts/2023-05-02-my-development-workflow-with-alacritty-fish-tmux-nvim/images/tmux-nvim.png"
        type=""
        alt="Tmux Nvim"
        
      /></p>
<p>Finally, look at some of the keymaps (mostly nicked from ThePrimeagen):</p>
<p>Paste our contents without replace what&rsquo;s in the register.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-lua" data-lang="lua"><span class="line"><span class="cl"><span class="n">vim.keymap</span><span class="p">.</span><span class="n">set</span><span class="p">(</span><span class="s2">&#34;x&#34;</span><span class="p">,</span> <span class="s2">&#34;&lt;leader&gt;p&#34;</span><span class="p">,</span> <span class="s2">&#34;</span><span class="se">\&#34;</span><span class="s2">_dP&#34;</span><span class="p">,</span> <span class="p">{</span> <span class="n">desc</span> <span class="o">=</span> <span class="s2">&#34;Paste without updating register&#34;</span> <span class="p">})</span>
</span></span></code></pre></div><p>Allows us to keep indenting or outdenting without needing to reselect.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-lua" data-lang="lua"><span class="line"><span class="cl"><span class="n">vim.keymap</span><span class="p">.</span><span class="n">set</span><span class="p">(</span><span class="s2">&#34;v&#34;</span><span class="p">,</span> <span class="s2">&#34;&lt;&#34;</span><span class="p">,</span> <span class="s2">&#34;&lt;gv&#34;</span><span class="p">,</span> <span class="p">{</span> <span class="n">desc</span> <span class="o">=</span> <span class="s2">&#34;Stay in visual mode during outdent&#34;</span> <span class="p">})</span>
</span></span><span class="line"><span class="cl"><span class="n">vim.keymap</span><span class="p">.</span><span class="n">set</span><span class="p">(</span><span class="s2">&#34;v&#34;</span><span class="p">,</span> <span class="s2">&#34;&gt;&#34;</span><span class="p">,</span> <span class="s2">&#34;&gt;gv&#34;</span><span class="p">,</span> <span class="p">{</span> <span class="n">desc</span> <span class="o">=</span> <span class="s2">&#34;Stay in visual mode during indent&#34;</span> <span class="p">})</span>
</span></span></code></pre></div><p>At the moment my neovim setup is pretty basic but I&rsquo;m it will change as I learn more about neovim and improve my setup,
suggestions are always welcome.</p>
<h2 id="summary">Summary</h2>
<p>I hope you enjoyed this post a bit different to what I usually write but I enjoyed documenting my development workflow.
I will likely add more posts in the future going into my Linux setup and also other tools I&rsquo;m to become more efficient.
Such vim binding on Firefox. Basically I&rsquo;m trying to be more keyboard driven.</p>
<div class="footnotes" role="doc-endnotes">
<hr>
<ol>
<li id="fn:1">
<p><a href="https://www.sean.sh/log/when-an-alias-should-actually-be-an-abbr/">https://www.sean.sh/log/when-an-alias-should-actually-be-an-abbr/</a>&#160;<a href="#fnref:1" class="footnote-backref" role="doc-backlink">&#x21a9;&#xfe0e;</a></p>
</li>
<li id="fn:2">
<p><a href="https://arcolinux.com/everthing-you-need-to-know-about-tmux-panes/">https://arcolinux.com/everthing-you-need-to-know-about-tmux-panes/</a>&#160;<a href="#fnref:2" class="footnote-backref" role="doc-backlink">&#x21a9;&#xfe0e;</a></p>
</li>
</ol>
</div>
]]></content:encoded>
    </item>
    
  </channel>
</rss>
