<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: naked on the bus</title>
    <description>The latest articles on DEV Community by naked on the bus (@nakedonthebus).</description>
    <link>https://dev.to/nakedonthebus</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3186192%2Fb4f7cef0-41ef-46d8-8754-a89d14afd229.png</url>
      <title>DEV Community: naked on the bus</title>
      <link>https://dev.to/nakedonthebus</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nakedonthebus"/>
    <language>en</language>
    <item>
      <title>Enchant your terminal application with python: survey, glow, rich, textwrap.</title>
      <dc:creator>naked on the bus</dc:creator>
      <pubDate>Mon, 26 May 2025 15:50:29 +0000</pubDate>
      <link>https://dev.to/nakedonthebus/enchant-your-terminal-application-with-python-survey-glow-rich-textwrap-and-more-j62</link>
      <guid>https://dev.to/nakedonthebus/enchant-your-terminal-application-with-python-survey-glow-rich-textwrap-and-more-j62</guid>
      <description>&lt;p&gt;Yesterday, i read &lt;a class="mentioned-user" href="https://dev.to/nish2005karsh"&gt;@nish2005karsh&lt;/a&gt; 's interesting &lt;a href="https://dev.to/nish2005karsh/make-your-terminal-beautiful-with-python-ascii-art-fancy-progress-bars--25f7"&gt;post&lt;/a&gt; on  making Python terminal apps look better with ASCII art and progress bars. I first thought about adding a comment with more styling tools, but then figured, 'Why not make it an article?' So, here’s my very first piece, packed with my advice for adding some personality to your terminal applications.&lt;/p&gt;

&lt;h3&gt;
  
  
  introduction
&lt;/h3&gt;

&lt;p&gt;Terminal applications have always fascinated me. I remember watching 80s sci-fi movies with my parents as a kid; every time the hacker needed to 'breach' a system or crack into something, they’d be hammering away at those almost surreal command-line interfaces, often seen in scientific labs filled with glowing CRT monitors. Think of iconic examples like Ghost in the Shell, Blade Runner, The Matrix, and so on – all those luminous characters on a dark screen just had a certain mystique to me.&lt;/p&gt;

&lt;p&gt;So, when I started developing actual CLI apps, I immediately tried to 'juice them up', and I found it surprising how much some easy-to-use libraries can make the entire experience – both the UI and UX – so much more enjoyable and friendly. That's why this article won't just be about visual flair (UI), but also about the overall user experience (UX).&lt;/p&gt;

&lt;h3&gt;
  
  
  ASCII art
&lt;/h3&gt;

&lt;p&gt;Many apps use ASCII art banners as the very first thing you see when they run – a great way to make an impression. In the post I mentioned before, the author uses &lt;a href="https://pypi.org/project/pyfiglet/" rel="noopener noreferrer"&gt;pyfiglet&lt;/a&gt; and does something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import pyfiglet
# Create an ASCII banner with your app's name
ascii_banner = pyfiglet.figlet_format("Your App Name")
print(ascii_banner)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With pyfiglet, you can also easily change the &lt;a href="http://www.figlet.org/" rel="noopener noreferrer"&gt;font style&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(pyfiglet.figlet_format("text to render", font="slant"))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But sometimes, just creating text banners isn't enough. What if you want to convert an actual image into ASCII art, or perhaps add some stylish borders to your text.&lt;/p&gt;

&lt;h3&gt;
  
  
  asciiart.eu
&lt;/h3&gt;

&lt;p&gt;A fantastic online tool for this is &lt;a href="https://www.asciiart.eu/" rel="noopener noreferrer"&gt;asciiart.eu&lt;/a&gt;. It's excellent for converting both text to ASCII and, images to ASCII. The site offers an incredible array of tools and parameters you can tweak to get just the right look.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fquqnovydlvhxg9unx3fk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fquqnovydlvhxg9unx3fk.png" alt="Image description" width="800" height="291"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx0icchse1bj20v2n0fc6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx0icchse1bj20v2n0fc6.png" alt="Image description" width="800" height="402"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4m2kt21woakkl0596z0n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4m2kt21woakkl0596z0n.png" alt="Image description" width="800" height="244"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsks1tunir6jed9lsxhpl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsks1tunir6jed9lsxhpl.png" alt="Image description" width="800" height="501"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  survey
&lt;/h3&gt;

&lt;p&gt;Next up is &lt;a href="https://github.com/Exahilosys/survey" rel="noopener noreferrer"&gt;survey&lt;/a&gt;. This is a Python toolkit that provides interactive widgets for your CLI, such as sortable and filterable menus, or masked input for passwords. It has several useful features, so the best way to explore them all is to check out the official documentation.&lt;br&gt;
To give you a better idea, here's a glimpse from survey's documentation: &lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fztndqezqq4zsp2qktcdj.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fztndqezqq4zsp2qktcdj.gif" alt="Image description" width="1224" height="552"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Adding interactive elements like these can make your CLI much more navigable and significantly improves the overall user experience.&lt;/p&gt;
&lt;h3&gt;
  
  
  glow
&lt;/h3&gt;

&lt;p&gt;Next, let's talk about &lt;a href="https://github.com/charmbracelet/glow" rel="noopener noreferrer"&gt;glow&lt;/a&gt;. As its tagline suggests, it's designed to simply "Render markdown on the CLI." This is incredibly useful for displaying formatted text, like README files or documentation, directly in your terminal.&lt;/p&gt;

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

&lt;p&gt;glow is a standalone program that you can typically install using your system's package manager.&lt;br&gt;
For example on arch is :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pacman -S glow
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To integrate glow into your Python application and display a Markdown, you can use the os.system call like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;## make sure glow is available on the machine
 if glow_available:
     try:
         os.system(f'glow "{file_with_markdown_to_display}"')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  textwrap
&lt;/h3&gt;

&lt;p&gt;Next, we have Python's built-in &lt;a href="https://docs.python.org/3/library/textwrap.html" rel="noopener noreferrer"&gt;textwrap&lt;/a&gt; module. As the name suggests, its primary purpose is to wrap text output neatly within the terminal, preventing long lines from overflowing and improving readability.&lt;/p&gt;

&lt;p&gt;The great thing about textwrap is that it's part of Python's standard library, so there's no need for any separate installation. You can use it right away:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import textwrap

your_long_string = "This is a very long string that would normally exceed the typical terminal width and look messy if not wrapped properly. Textwrap helps us manage this."

# Wrap the string to a maximum width of 80 characters
wrapped_text = textwrap.fill(your_long_string, width=80)
print(wrapped_text)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  rich
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/Textualize/rich" rel="noopener noreferrer"&gt;rich&lt;/a&gt; is so feature-packed that it might even feel like 'overkill' for very simple tasks. However, this extensive capability means you can do almost anything you can imagine with terminal styling and layout.&lt;/p&gt;

&lt;p&gt;Given its breadth, the best approach is to explore its excellent documentation and pick out the specific components or features you need for your particular application.&lt;/p&gt;

&lt;p&gt;The official documentation includes a cool cheat sheet:&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjycdsmemxg340urcib8a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjycdsmemxg340urcib8a.png" alt="Image description" width="800" height="896"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Practical example
&lt;/h3&gt;

&lt;p&gt;To show how these tools can work together effectively and bring some "juice" to a real application, I'd like to share a mini-project I developed a few months ago. It's a command-line interface (CLI) called cj, designed to let you interact with the Gemini AI chat directly from your terminal. It uses glow, and survey, and also alot of &lt;code&gt;os.system('clear')&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Feel free to explore the source code, see how it's put together, or even install it from its GitHub &lt;a href="https://github.com/naked-on-the-bus/cj" rel="noopener noreferrer"&gt;repository&lt;/a&gt; here.&lt;/p&gt;

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

</description>
      <category>python</category>
      <category>cli</category>
      <category>bash</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
