<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xml:base="https://bjorn.now/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Gum on bjorn.now</title><link>https://bjorn.now/tags/gum/</link><description>Recent content in Gum on bjorn.now</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Wed, 20 Aug 2025 23:02:03 +0800</lastBuildDate><atom:link href="https://bjorn.now/tags/gum/feed.xml" rel="self" type="application/rss+xml"/><item><title>gum: clean user interactions for shell scripts</title><link>https://bjorn.now/til/2025-08-20-gum-is-a-cli-tool-that-helps-your-make-your-scripts-easy-to-interact-with/?utm_medium=feed</link><pubDate>Wed, 20 Aug 2025 23:02:03 +0800</pubDate><guid>https://bjorn.now/til/2025-08-20-gum-is-a-cli-tool-that-helps-your-make-your-scripts-easy-to-interact-with/</guid><description>gum simplifies making shell scripts interactive: no more wrestling with read commands and ANSI escape codes for user input: just proper text editing, defaults, and clean UI.
Their demo:</description><content:encoded><![CDATA[<p><a href="https://github.com/charmbracelet/gum">gum</a> simplifies making shell scripts interactive: no more wrestling with read commands and ANSI escape codes for user input: just proper text editing, defaults, and clean UI.</p>
<p><a href="https://github.com/charmbracelet/gum/blob/9ab722ca4fe1e248283091626bd9fe5ecea65e1b/examples/demo.sh">Their demo</a>: <figure><img src="/img/2025/gum-demo.gif"
    alt="gum gemo">
</figure>
</p>
<p>For example, if you run:</p>
<div class=" copy-enabled">
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">gum input --width <span class="m">50</span> --header <span class="s2">&#34;Favorite author?&#34;</span> <span class="se">\
</span></span></span><span class="line"><span class="cl"><span class="se"></span> --value <span class="s2">&#34;Terry Pratchett&#34;</span></span></span></code></pre></div>
</div>
<p>It will give you a question with a sensible default that you can then change as you want, and what you wrote as you hit <code>enter</code> will be returned so your script can then use it.</p>
<p>If you instead has some options where you want to select one:</p>
<div class=" copy-enabled">
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">gum choose --header <span class="s2">&#34;Favorite book?&#34;</span> <span class="se">\
</span></span></span><span class="line"><span class="cl"><span class="se"></span> <span class="s2">&#34;Hogfather&#34;</span> <span class="s2">&#34;Thief of Time&#34;</span> <span class="s2">&#34;The Night Watch&#34;</span> <span class="s2">&#34;Small Gods&#34;</span></span></span></code></pre></div>
</div>
<p>Which gives you a selection box, you can configure to allow multiple selections, and the one you pick is then returned.</p>
<p>And one I really love, have it show a spinner to indicate that yes… something is still going on:</p>
<div class=" copy-enabled">
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">gum spin --title<span class="o">=</span><span class="s2">&#34;Counting down from 10&#34;</span> sleep <span class="m">10</span></span></span></code></pre></div>
</div>
<p>Built on <a href="https://github.com/charmbracelet/bubbletea">bubbletea</a>, a Go TUI framework, use that directly if you need these components in Go code rather than shell scripts.</p>]]></content:encoded></item></channel></rss>