<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Terminal on Cesar Gimenes</title><link>https://crg.eti.br/tags/terminal/</link><description>Recent content in Terminal on Cesar Gimenes</description><generator>Hugo -- gohugo.io</generator><language>en</language><managingEditor>crg@crg.eti.br (Cesar Gimenes)</managingEditor><webMaster>crg@crg.eti.br (Cesar Gimenes)</webMaster><lastBuildDate>Tue, 31 Dec 2024 17:34:13 -0300</lastBuildDate><atom:link href="https://crg.eti.br/tags/terminal/index.xml" rel="self" type="application/rss+xml"/><item><title>Plasma Effect in the Terminal with Golang</title><link>https://crg.eti.br/pub/efeito-plasma-no-terminal-com-golang/</link><pubDate>Tue, 31 Dec 2024 17:34:13 -0300</pubDate><author>crg@crg.eti.br (Cesar Gimenes)</author><guid>https://crg.eti.br/pub/efeito-plasma-no-terminal-com-golang/</guid><description>&lt;p>One kind of program I&amp;rsquo;ve always found interesting is the &lt;em>demo&lt;/em>: eye-catching graphical effects with code that squeezes every ounce of performance out of the machine. The plasma effect is one of my favorites, simulating a fluid in motion.&lt;/p>
&lt;figure class="media-frame media-center fade-in">&lt;a href="https://crg.eti.br/pub/efeito-plasma-no-terminal-com-golang/plasma.webp">
&lt;picture>
&lt;source media="(max-width: 480px)" srcset="https://crg.eti.br/pub/efeito-plasma-no-terminal-com-golang/plasma_hu_3e89f9757017ba57.webp">
&lt;source media="(max-width: 1080px)" srcset="https://crg.eti.br/pub/efeito-plasma-no-terminal-com-golang/plasma_hu_3490c725fbb4fdb0.webp">
&lt;img alt="plasma in the terminal with Go" src="https://crg.eti.br/pub/efeito-plasma-no-terminal-com-golang/plasma_hu_5639f6b4b1ba2b78.webp" height="832" width="1280" loading="lazy" decoding="async">
&lt;/picture>
&lt;/a>&lt;/figure>&lt;p>To create the plasma effect, I use several trigonometric functions to calculate the background color of each character, passing time as a parameter to generate the animation. The code is relatively simple, but the optimization is a bit more complex.&lt;/p></description></item><item><title>Happy 2025, Fireworks in the Terminal with Golang</title><link>https://crg.eti.br/pub/feliz-2025-com-fogos-de-artificio-no-terminal-com-golang/</link><pubDate>Tue, 31 Dec 2024 13:09:42 -0300</pubDate><author>crg@crg.eti.br (Cesar Gimenes)</author><guid>https://crg.eti.br/pub/feliz-2025-com-fogos-de-artificio-no-terminal-com-golang/</guid><description>&lt;p>A small program celebrates the arrival of 2025 with fireworks in the terminal. It includes several interesting tricks to start your year with plenty of code.&lt;/p>
&lt;figure class="media-frame media-center fade-in">&lt;a href="https://crg.eti.br/pub/feliz-2025-com-fogos-de-artificio-no-terminal-com-golang/fireworks-em-golang.webp">
&lt;picture>
&lt;source media="(max-width: 480px)" srcset="https://crg.eti.br/pub/feliz-2025-com-fogos-de-artificio-no-terminal-com-golang/fireworks-em-golang_hu_540d81dfb0c7b7ac.webp">
&lt;source media="(max-width: 1080px)" srcset="https://crg.eti.br/pub/feliz-2025-com-fogos-de-artificio-no-terminal-com-golang/fireworks-em-golang_hu_a9d6cf735954d9aa.webp">
&lt;img alt="fireworks in Go" src="https://crg.eti.br/pub/feliz-2025-com-fogos-de-artificio-no-terminal-com-golang/fireworks-em-golang_hu_87a35e7dddfadd11.webp" height="1532" width="2188" loading="lazy" decoding="async">
&lt;/picture>
&lt;/a>&lt;/figure>&lt;p>We use &lt;code>os.Stdout.WriteString&lt;/code> to write directly to the stdout descriptor, that is, the terminal&amp;rsquo;s standard output. This is the fastest way to write to the terminal, but it is not synchronized. That means there is no guarantee the output will be written in the expected order. In our case, though, this is desirable because it lets the fireworks overlap, giving the impression that they are exploding simultaneously.&lt;/p></description></item><item><title>Rewriting the Old TSR Using Bash</title><link>https://crg.eti.br/pub/reescrevendo-velho-tsr-usando-bash/</link><pubDate>Sat, 21 Dec 2024 17:26:25 -0300</pubDate><author>crg@crg.eti.br (Cesar Gimenes)</author><guid>https://crg.eti.br/pub/reescrevendo-velho-tsr-usando-bash/</guid><description>&lt;p>When I started programming, computing was different from today. The operating system was single-tasking; only one program could run at a time. There were no modern features like protected and mapped memory. Even so, it was possible to create concurrent behavior in programs, but you had to be careful to keep any part from blocking execution. For example, there could be no loops waiting for keyboard input or very long processes. Writing a non-blocking program was tricky in languages like Clipper.&lt;/p></description></item><item><title>A Script for Fast Directory Navigation Using fzf</title><link>https://crg.eti.br/pub/script-rapido-navegacao-diretorios-fzf/</link><pubDate>Sun, 24 Nov 2024 15:43:50 -0300</pubDate><author>crg@crg.eti.br (Cesar Gimenes)</author><guid>https://crg.eti.br/pub/script-rapido-navegacao-diretorios-fzf/</guid><description>&lt;p>This article presents a script to make directory navigation faster, continuing the series on reducing cognitive complexity.&lt;/p>
&lt;p>You often need to move between several directories in one or many projects. Remembering paths and locating files becomes an unnecessary effort.&lt;/p>
&lt;p>One solution is to keep a list of the most recently visited directories so you can switch between them quickly. Dave Eddy implemented this idea in his &lt;a href="https://github.com/bahamas10/bash-cdstack">cdstack&lt;/a>.&lt;/p>
&lt;p>Inspired by that approach, I built my own version, better suited to the way I work.&lt;/p></description></item><item><title>Reducing Cognitive Complexity in Programming</title><link>https://crg.eti.br/pub/diminuindo-a-complexidade-cognitiva-na-programacao/</link><pubDate>Sat, 23 Nov 2024 21:28:27 -0300</pubDate><author>crg@crg.eti.br (Cesar Gimenes)</author><guid>https://crg.eti.br/pub/diminuindo-a-complexidade-cognitiva-na-programacao/</guid><description>&lt;p>I spend a lot of time and effort reducing cognitive complexity when I program.&lt;/p>
&lt;p>Cognitive complexity is how much you have to think to get a task done. Small details can make a task unnecessarily complex.&lt;/p>
&lt;p>For example, finding a snippet of code hidden among many files inside a large directory structure takes effort. Even if the structure is familiar and well designed, the goal is not to navigate through it opening files until you find the code to edit; the goal is simply to edit the code. Anything beyond that is wasted cognitive effort.&lt;/p></description></item><item><title>tr - A Utility for Replacing Characters</title><link>https://crg.eti.br/pub/tr-substituindo-caracteres/</link><pubDate>Sun, 28 Aug 2022 18:42:40 -0300</pubDate><author>crg@crg.eti.br (Cesar Gimenes)</author><guid>https://crg.eti.br/pub/tr-substituindo-caracteres/</guid><description>&lt;p>This is a simple and very useful utility. Basically, &lt;code>tr&lt;/code> filters strings one character at a time, and when used correctly it is even UTF-8 compatible.&lt;/p>
&lt;p>Character filtering is defined by the parameters, and to make things easier you can use character &lt;em>classes&lt;/em>, for example &lt;code>[:upper:]&lt;/code> for all uppercase letters or &lt;code>[:cntrl:]&lt;/code> for all control characters.&lt;/p>
&lt;h2 id="parameters">Parameters&lt;/h2>
&lt;p>The parameters I use most are the following:&lt;/p>
&lt;ul>
&lt;li>&lt;code>-d&lt;/code> &lt;em>delete&lt;/em> to remove characters.&lt;/li>
&lt;li>&lt;code>-s&lt;/code> &lt;em>squeeze&lt;/em>, which is quite handy for collapsing sequences of repeated characters.&lt;/li>
&lt;/ul>
&lt;h2 id="examples">Examples&lt;/h2>
&lt;p>Converts uppercase to lowercase, but fails with UTF-8 characters.&lt;/p></description></item><item><title>fmt - A Simple Text Formatting Utility</title><link>https://crg.eti.br/pub/fmt-formatando-texto/</link><pubDate>Tue, 23 Aug 2022 01:04:14 -0300</pubDate><author>crg@crg.eti.br (Cesar Gimenes)</author><guid>https://crg.eti.br/pub/fmt-formatando-texto/</guid><description>&lt;p>The &lt;code>fmt&lt;/code> utility is a simple, fast text formatter. Its purpose is to format text files or strings received via stdin so that lines don&amp;rsquo;t exceed the maximum number of characters per line defined by the user.&lt;/p>
&lt;p>It was originally intended to be used together with the mail utility, but it can be useful alongside other programs such as vim, for example.&lt;/p>
&lt;p>The main parameters are:&lt;/p>
&lt;ul>
&lt;li>&lt;code>-w&lt;/code>, which sets the desired number of characters per line.&lt;/li>
&lt;li>&lt;code>-t&lt;/code>, which sets the tab width.&lt;/li>
&lt;/ul>
&lt;p>There are several other useful parameters; check your system&amp;rsquo;s &lt;em>manpage&lt;/em> to learn more.&lt;/p></description></item><item><title>First steps when setting up a new server</title><link>https://crg.eti.br/pub/configurando-novo-servidor/</link><pubDate>Mon, 03 May 2021 18:30:30 -0300</pubDate><author>crg@crg.eti.br (Cesar Gimenes)</author><guid>https://crg.eti.br/pub/configurando-novo-servidor/</guid><description>&lt;p>Whenever I bring up a new machine I always run a few commands and set up some configuration. A lot of it is already handled by my &lt;a href="https://github.com/crgimenes/dotfiles">dotfiles&lt;/a>, but there&amp;rsquo;s always plenty of custom work left to do.&lt;/p>
&lt;p>The first thing is to get SSH access and make sure the root password isn&amp;rsquo;t the default one.&lt;/p>
&lt;p>Next I give my user sudo access, in case it doesn&amp;rsquo;t have it already.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>usermod -aG sudo &lt;span style="color:#0a3069">${&lt;/span>&lt;span style="color:#953800">USER&lt;/span>&lt;span style="color:#0a3069">}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>If it&amp;rsquo;s a machine on the local network, I set it up to use &lt;a href="https://crg.eti.br/pub/zero-configuration-network-no-debian/">zero configuration network&lt;/a>, a much more convenient way to reach the machine, especially on IPv6 networks. Otherwise, this is a good time to add the machine to a domain.&lt;/p></description></item><item><title>The UNIX Manual</title><link>https://crg.eti.br/pub/o-manual-do-unix/</link><pubDate>Wed, 10 Feb 2021 06:45:14 +0000</pubDate><author>crg@crg.eti.br (Cesar Gimenes)</author><guid>https://crg.eti.br/pub/o-manual-do-unix/</guid><description>&lt;p>On November 3, 1971, the first version of the &lt;a href="https://www.bell-labs.com/usr/dmr/www/1stEdman.html">Unix Programmer&amp;rsquo;s Manual&lt;/a> was released, commonly known as man pages.&lt;/p>
&lt;p>You can download it as PDF or PostScript from &lt;a href="https://www.bell-labs.com/usr/dmr/www/">Dennis Ritchie&amp;rsquo;s page at Bell Labs&lt;/a>, maintained by Nokia for historical reasons.&lt;/p>
&lt;p>It&amp;rsquo;s interesting how UNIX commands haven&amp;rsquo;t changed much over the years. If you&amp;rsquo;re a Linux or BSD user, you&amp;rsquo;ll certainly recognize most of them. It&amp;rsquo;s also remarkable how such a simple idea can be so incredibly useful.&lt;/p></description></item><item><title>A find command tip</title><link>https://crg.eti.br/pub/dica-do-comando-find/</link><pubDate>Wed, 14 Oct 2020 06:45:14 +0000</pubDate><author>crg@crg.eti.br (Cesar Gimenes)</author><guid>https://crg.eti.br/pub/dica-do-comando-find/</guid><description>&lt;p>I use the find command a lot to look for files, whether in bash scripts or straight from the command line.&lt;/p>
&lt;p>An interesting trick is excluding some files from the list. For example, I recently needed to look for all &amp;ldquo;.md&amp;rdquo; files but wanted to exclude everything starting with an underscore, as well as the &amp;ldquo;default.md&amp;rdquo; file.&lt;/p>
&lt;p>To do that I used the &lt;em>-not&lt;/em> parameter before the &lt;em>-name&lt;/em> parameter, as in the example below.&lt;/p></description></item><item><title>Unit Test Coverage in Go</title><link>https://crg.eti.br/pub/cobertura-de-testes/</link><pubDate>Wed, 13 Feb 2019 06:45:14 +0000</pubDate><author>crg@crg.eti.br (Cesar Gimenes)</author><guid>https://crg.eti.br/pub/cobertura-de-testes/</guid><description>&lt;p>Unit tests are incredibly important, even for a compiled language like Golang.&lt;/p>
&lt;p>Fortunately, most programming languages today have a good variety of unit testing tools. Go ships with some surprising ones, not just for running tests but also for analyzing code to find coverage gaps.&lt;/p>
&lt;p>A quick, visual way to analyze test coverage is to write a script around &lt;code>go tool cover&lt;/code> and load it in &lt;code>zsh&lt;/code> or &lt;code>bash&lt;/code>, which makes inspecting the code very simple.&lt;/p></description></item><item><title>Editing Command Lines in the Terminal</title><link>https://crg.eti.br/pub/comandos-longos-no-terminal/</link><pubDate>Sun, 08 Jul 2018 06:45:14 +0000</pubDate><author>crg@crg.eti.br (Cesar Gimenes)</author><guid>https://crg.eti.br/pub/comandos-longos-no-terminal/</guid><description>&lt;p>I use the terminal a lot. It is amazing how the good old &lt;em>command line interface&lt;/em> &lt;code>cli&lt;/code> is still relevant, and still simply the fastest way to command a computer despite so many years of progress in computing.&lt;/p>
&lt;p>We just haven&amp;rsquo;t found a better way to enter commands yet. Over time, though, those commands have grown into what are practically small programs, sometimes several lines long, and sometimes containing things that are hard to edit, like regular expressions.&lt;/p></description></item></channel></rss>