Entering text in the terminal is complicated

submited by
Style Pass
2024-07-08 18:00:03

The other day I asked what folks on Mastodon find confusing about working in the terminal, and one thing that stood out to me was “editing a command you already typed in”.

This really resonated with me: even though entering some text and editing it is a very “basic” task, it took me maybe 15 years of using the terminal every single day to get used to using Ctrl+A to go to the beginning of the line (or Ctrl+E for the end).

So let’s talk about why entering text might be hard! I’ll also share a few tips that I wish I’d learned earlier.

A big part of what makes entering text in the terminal hard is the inconsistency between how different programs handle entering text. For example:

First, there’s “the baseline” – what happens if a program just accepts text by calling fgets() or whatever and doing absolutely nothing else to provide a nicer experience. Here’s what using these tools typically looks for me – If I start dash (a pretty minimal shell) press the left arrow keys, it just prints ^[[D to the terminal.

At first it doesn’t seem like all of these “baseline” tools have much in common, but there are actually a few features that you get for free just from your terminal, without the program needing to do anything special at all.

Leave a Comment