<?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>Terminal on Haseeb Majid</title>
    <link>https://haseebmajid.dev/tags/terminal/</link>
    <description>Recent content in Terminal on Haseeb Majid</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en</language>
    <lastBuildDate>Thu, 25 Apr 2024 00:00:00 +0000</lastBuildDate><atom:link href="https://haseebmajid.dev/tags/terminal/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Part 4b Foot Terminal as Part of Your Development Workflow</title>
      <link>https://haseebmajid.dev/posts/2024-04-25-part-4b-foot-terminal-as-part-of-your-development-workflow/</link>
      <pubDate>Thu, 25 Apr 2024 00:00:00 +0000</pubDate>
      
      <guid>https://haseebmajid.dev/posts/2024-04-25-part-4b-foot-terminal-as-part-of-your-development-workflow/</guid>
      <description>&lt;p&gt;Earlier this year I spoke about using Wezterm as my terminal of choice, however since then, I have swapped back to the
foot terminal emulator. I also have kitty available on my system. However, I don&amp;rsquo;t use it much.&lt;/p&gt;
&lt;p&gt;In this article, I want to add a quick addendum to why I moved away from Wezterm. Note as per that post, this is again
not a super important decision, almost any full colour supported terminal will basically like every other. So if one
work for you, feel free to stick to it.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>Earlier this year I spoke about using Wezterm as my terminal of choice, however since then, I have swapped back to the
foot terminal emulator. I also have kitty available on my system. However, I don&rsquo;t use it much.</p>
<p>In this article, I want to add a quick addendum to why I moved away from Wezterm. Note as per that post, this is again
not a super important decision, almost any full colour supported terminal will basically like every other. So if one
work for you, feel free to stick to it.</p>
<h2 id="why-i-swapped">Why I swapped?</h2>
<p>The main reason was I had constant issue with Wezterm on Hyprland playing nice. Within about 6 months it
probably broke 3 times or so. I am not sure where the issue lies, whether with Hyprland, Wezterm or even myself.
Though I did see the author of Hyprland reference, Wezterm not working properly with Wayland. So in the end I decided
to go back to a terminal I had no issues with on Wayland, which was foot. A terminal specifically built to run on
Wayland.</p>
<p>I already had the config in my nix config, so it was mostly a case of doing <code>terminals.foot.enable = true;</code>. Then changing
a few key bindings and I am off.</p>
<h2 id="downsides">Downsides</h2>
<p>The main down-sides with this approach is that foot will only run on Linux machines, whereas Wezterm and other terminals
can run on other operating systems as well. Again I don&rsquo;t plan on not working on a Linux machine, in the near future
so this isn&rsquo;t a big issue for me.</p>
<h2 id="settings">Settings</h2>
<p>Having a look at my config, located somewhere like <code>cli/termains/foot/default.nix</code>:</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">config</span><span class="o">,</span>
</span></span><span class="line"><span class="cl">  <span class="n">lib</span><span class="o">,</span>
</span></span><span class="line"><span class="cl">  <span class="o">...</span>
</span></span><span class="line"><span class="cl"><span class="p">}:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="n">programs</span><span class="o">.</span><span class="n">foot</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">catppuccin</span><span class="o">.</span><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></span><span class="line"><span class="cl">      <span class="n">settings</span> <span class="o">=</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">        <span class="n">main</span> <span class="o">=</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">          <span class="n">term</span> <span class="o">=</span> <span class="s2">&#34;foot&#34;</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">          <span class="n">font</span> <span class="o">=</span> <span class="s2">&#34;MonoLisa Nerd Font:size=14&#34;</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;fish&#34;</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">          <span class="n">pad</span> <span class="o">=</span> <span class="s2">&#34;30x30&#34;</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">          <span class="n">selection-target</span> <span class="o">=</span> <span class="s2">&#34;clipboard&#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></span><span class="line"><span class="cl">        <span class="n">scrollback</span> <span class="o">=</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">          <span class="n">lines</span> <span class="o">=</span> <span class="mi">10000</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="p">};</span>
</span></span><span class="line"><span class="cl">  <span class="p">};</span>
</span></span><span class="line"><span class="cl"><span class="err">}</span>
</span></span></code></pre></div><p>Again, basic like Wezterm. I am using the catppuccin theme, using the <a href="https://github.com/catppuccin/nix">catppuccin/nix</a>
nix config to theme it. Reducing the boilerplate I have to write. Then I set the font I want, Mono Lisa. Finally set
my default shell and that I want to copy selected text to my clipboard automatically.</p>
<p>Not much more to it tbh! Again, as I say, don&rsquo;t need to be super fancy.</p>
]]></content:encoded>
    </item>
    
    <item>
      <title>Part 4: Wezterm Terminal as Part of Your Development Workflow</title>
      <link>https://haseebmajid.dev/posts/2024-01-05-part-4-wezterm-terminal-as-part-of-your-development-workflow/</link>
      <pubDate>Fri, 05 Jan 2024 00:00:00 +0000</pubDate>
      
      <guid>https://haseebmajid.dev/posts/2024-01-05-part-4-wezterm-terminal-as-part-of-your-development-workflow/</guid>
      <description>&lt;p&gt;I will preface this article by saying, out of all the tools/apps in this series, this is probably the least important
decision you will make. You can use any terminal editor and basically still have the same development workflow as me.
Some common terminal emulators include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;kitty&lt;/li&gt;
&lt;li&gt;alacritty&lt;/li&gt;
&lt;li&gt;foot&lt;/li&gt;
&lt;li&gt;wezterm&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;background&#34;&gt;Background&lt;/h2&gt;
&lt;p&gt;After a break that was probably too long in this series, we&amp;rsquo;re on to the next part looking at our terminal and how we
set it up. Part of the reason was when I started this series I was using alacritty, however after moving to
Hyprland I soon moved over to the foot terminal. The main reason for this was the sixel support with a CLI file manager.
&lt;code&gt;lf&lt;/code&gt;. Which worked with the foot terminal emulator, but I couldn&amp;rsquo;t get working with alacritty. This was so that I could
preview images in the CLI when using &lt;code&gt;lf&lt;/code&gt;.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>I will preface this article by saying, out of all the tools/apps in this series, this is probably the least important
decision you will make. You can use any terminal editor and basically still have the same development workflow as me.
Some common terminal emulators include:</p>
<ul>
<li>kitty</li>
<li>alacritty</li>
<li>foot</li>
<li>wezterm</li>
</ul>
<h2 id="background">Background</h2>
<p>After a break that was probably too long in this series, we&rsquo;re on to the next part looking at our terminal and how we
set it up. Part of the reason was when I started this series I was using alacritty, however after moving to
Hyprland I soon moved over to the foot terminal. The main reason for this was the sixel support with a CLI file manager.
<code>lf</code>. Which worked with the foot terminal emulator, but I couldn&rsquo;t get working with alacritty. This was so that I could
preview images in the CLI when using <code>lf</code>.</p>
<p>So essentially, the main reason this article is delayed is that I wasn&rsquo;t quite set on the terminal I wanted to use.</p>
<h2 id="why-wezterm">Why Wezterm?</h2>
<p>However, recently, I actually started using Wezterm. There were a few reasons for this, the main being I could configure
Wezterm using Lua. Which also the main language we will use to configure our editor, Neovim. So I favoured
being also able to edit my terminal using the same language <sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup>.</p>
<p>Another reason you might want to use Wezterm vs foot is that is cross-platform so if you use multiple OSs you can share
the same terminal emulator, i.e. on macOS, Linux and Windows. Wezterm is also GPU accelerated like kitty and alacritty,
whereas foot is not. However, I don&rsquo;t really do anything in my terminal which needs GPU acceleration to the point I
notice a difference.</p>
<p>Finally, Wezterm does offer some form of session management similar to Tmux. However, it is not as feature rich, as I need
like switching sessions or saving and restoring sessions. That I can easily do in tmux. We will talk about this more
in a future article.</p>
<p>tl;dr: I want to configure my editor in Lua.</p>
<h2 id="configuration">Configuration</h2>
<p>Now onto the real meat and potatoes of this article, how did I configure wezterm?
So I am going to assume you are using NixOS with home-manager as we set up in our previous posts.
We will put our Wezterm config in home-manager so that we can also use the same config for non NixOS machines which
use Nix package manager.</p>
<h3 id="aside-home-manager-organisation">(Aside) Home Manager Organisation</h3>
<p>I have my home-managers module organised such that common apps are kept in the same folder. So I keep all my terminal
configs in one place, i.e. in my case, <code>home-manager/terminals/wezterm</code>. The folder also contains for foot, alacritty.
These all get imported by a main module, then the user can choose in their nix <code>home.nix</code> config which ones to enable
(for use) and which one to set as the default.</p>
<p>So I have <code>home-manager/default.nix</code>, which imports all the terminal configs:</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">imports</span> <span class="o">=</span> <span class="p">[</span>
</span></span><span class="line"><span class="cl">  <span class="sr">./browsers/firefox.nix</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">  <span class="sr">./editors/nvim</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">  <span class="sr">./multiplexers/tmux.nix</span>
</span></span><span class="line"><span class="cl">  <span class="sr">./multiplexers/zellij</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">  <span class="sr">./shells/fish.nix</span>
</span></span><span class="line"><span class="cl">  <span class="sr">./shells/nushell.nix</span>
</span></span><span class="line"><span class="cl">  <span class="sr">./shells/zsh.nix</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line hl"><span class="cl">  <span class="sr">./terminals/alacritty.nix</span>
</span></span><span class="line"><span class="cl">  <span class="sr">./terminals/foot.nix</span>
</span></span><span class="line"><span class="cl">  <span class="sr">./terminals/wezterm</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>Then in say <code>hosts/framework/home.nix</code>, which is the entry point for my home-manager config:</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">config</span> <span class="o">=</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="n">modules</span> <span class="o">=</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">      <span class="n">terminals</span> <span class="o">=</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">        <span class="n">wezterm</span><span class="o">.</span><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="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><h2 id="config">Config</h2>
<p>My <code>home-manager/terminals/wezterm/default.nix</code> looks like this:</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">config</span><span class="o">,</span>
</span></span><span class="line"><span class="cl">  <span class="n">lib</span><span class="o">,</span>
</span></span><span class="line"><span class="cl">  <span class="n">pkgs</span><span class="o">,</span>
</span></span><span class="line"><span class="cl">  <span class="o">...</span>
</span></span><span class="line"><span class="cl"><span class="p">}:</span>
</span></span><span class="line"><span class="cl"><span class="k">with</span> <span class="n">lib</span><span class="p">;</span> <span class="k">let</span>
</span></span><span class="line"><span class="cl">  <span class="n">cfg</span> <span class="o">=</span> <span class="n">config</span><span class="o">.</span><span class="n">modules</span><span class="o">.</span><span class="n">terminals</span><span class="o">.</span><span class="n">wezterm</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="k">in</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">  <span class="n">options</span><span class="o">.</span><span class="n">modules</span><span class="o">.</span><span class="n">terminals</span><span class="o">.</span><span class="n">wezterm</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="n">mkEnableOption</span> <span class="s2">&#34;enable wezterm terminal emulator&#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></span><span class="line"><span class="cl">  <span class="n">config</span> <span class="o">=</span> <span class="n">mkIf</span> <span class="n">cfg</span><span class="o">.</span><span class="n">enable</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="n">programs</span><span class="o">.</span><span class="n">wezterm</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">package</span> <span class="o">=</span> <span class="n">pkgs</span><span class="o">.</span><span class="n">wezterm-nightly</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">      <span class="n">extraConfig</span> <span class="o">=</span> <span class="nb">builtins</span><span class="o">.</span><span class="n">readFile</span> <span class="sr">./config.lua</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="p">}</span>
</span></span></code></pre></div><p>The first part is the boilerplate required for enabling this terminal, if enabled in the nix config options. Then
I pull in extra config from a Lua file. This means I can use the Lua LSP; however, it does mean I cannot pull in
config options from other bits of my nix config. Like my default shell, but for now, I am happy to leave this hard-coded
while I am still tweaking my wezterm config.</p>
<p>Where my Lua config, <code>home-manager/terminals/wezterm/config.lua</code> looks like:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-lua" data-lang="lua"><span class="line"><span class="cl"><span class="kd">local</span> <span class="n">wezterm</span> <span class="o">=</span> <span class="n">require</span><span class="p">(</span><span class="s2">&#34;wezterm&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="kr">return</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">	<span class="n">color_scheme</span> <span class="o">=</span> <span class="s2">&#34;Catppuccin Mocha&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">	<span class="n">default_prog</span> <span class="o">=</span> <span class="p">{</span> <span class="s2">&#34;fish&#34;</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl">	<span class="n">font</span> <span class="o">=</span> <span class="n">wezterm.font</span><span class="p">(</span><span class="s2">&#34;MonoLisa Nerd Font&#34;</span><span class="p">),</span>
</span></span><span class="line"><span class="cl">	<span class="n">font_size</span> <span class="o">=</span> <span class="mf">14.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">	<span class="n">enable_tab_bar</span> <span class="o">=</span> <span class="kc">false</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">	<span class="n">term</span> <span class="o">=</span> <span class="s2">&#34;wezterm&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">	<span class="n">keys</span> <span class="o">=</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">key</span> <span class="o">=</span> <span class="s2">&#34;t&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">			<span class="n">mods</span> <span class="o">=</span> <span class="s2">&#34;SUPER&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">			<span class="n">action</span> <span class="o">=</span> <span class="n">wezterm.action</span><span class="p">.</span><span class="n">DisableDefaultAssignment</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="p">}</span>
</span></span></code></pre></div><p>Where this is pretty basic, I set my colour scheme to catppuccin mocha which I use across all of my tools/apps for a
consistent look and feel. Then I set the default shell to fish and my default font to monolisa my current favourite
font (even though you have to pay for it, I just really like how it looks).</p>
<p>Then I disable the <code>super + t</code> key so it doesn&rsquo;t create new tabs. As, I will leverage a multiplexer like zellij or tmux.
Which we will go over in a future post.</p>
<h2 id="more-ramblings">More Ramblings</h2>
<p>As I said, the terminal is probably the least important part of this workflow, as they  all do the same thing. So
pick your favourite and use that. As you can see for my current config, there is nothing special or really that different.
Currently, it is pretty simple. I may later combine this file, when I want to dynamically set the <code>default_prog</code> and
<code>font</code>.</p>
<p>One final thing, for the moment wezterm is crashing on NixOS, there is a fix in place, but there hasn&rsquo;t been a
new release (tag), so I have set up using the git repo to build the latest version of wezterm, so I can use it, until
a new version is released in nixpkgs. At the time of writing, the last release for wezterm was <code>20230712-072601-f4abf8fd</code>,
which was released on July 12th, 2023. You can find how I packaged it
<a href="https://gitlab.com/hmajid2301/dotfiles/-/blob/b9f1454e8bc07d4af7192c5a48a53a765d586646/pkgs/wezterm-nightly/default.nix">here</a>.</p>
<p>Which I nicked from someone else and changed it a bit to make it work with a new release of wezterm. But I cannot
where I found the original.</p>
<p>But that&rsquo;s about it, to be honest!</p>
<div class="footnotes" role="doc-endnotes">
<hr>
<ol>
<li id="fn:1">
<p><a href="https://wezfurlong.org/wezterm/features.html">https://wezfurlong.org/wezterm/features.html</a>&#160;<a href="#fnref:1" class="footnote-backref" role="doc-backlink">&#x21a9;&#xfe0e;</a></p>
</li>
</ol>
</div>
]]></content:encoded>
    </item>
    
  </channel>
</rss>
