Tag Archives: display

cp437: Turning frogs into handsome princes, since 2013

I got a note from Markus Ulfberg back in December, and his tip was such a cool little program that I’ve been holding it in reserve in hopes of showing it off properly, once I find a application that really really needs it.

The problem is that I haven’t stumbled across anything that desperately deserved its attention. And as it’s been a couple of months since Markus’s e-mail, I’ll just give it the spotlight on its own. Here’s cp437, and what it can do for you.

2015-03-03-6m47421-cp437-bitchx-01 2015-03-03-6m47421-cp437-bitchx-02 2015-03-03-6m47421-cp437-bitchx-03

At left, brand X. At center and right, cp437 with bitchx. And suddenly the glory days of ANSI graphic art have returned. What will you be drinking, sir?

I don’t know all the ins and outs of codepages or why some tools show scrambled glyphs in the terminal or the framebuffer. I’m just a lowly user, accepting life as it appears in front of my blinky-blinky cursor and learning to suffer when things aren’t gorgeous.

But cp437 manages to seamlessly and transparently convert frogs into handsome princes, and I have no better explanation than magic. It’s gotta be the shoes.

I can think of several tools that will probably benefit from cp437’s love — Markus mentions camp and duhdraw as two winners, and I’m sure there are lots more. I daresay there are even some image converter tools that would refine their art with the help of cp437.

So I’ll leave it to you to experiment — and experience — the cp437 goodness. In the mean time, I’m going to wander back through the back catalogue and see if anything suddenly changes from ugly duckling to swan, by sprinkling a little cp437 on it. … :mrgreen:

color-invaders.sh: A script! and a site!

My favorite e-mails are the ones with lots of exclamation points. It’s usually a sign that someone is quite enthusiastic about the program they want to share. Or quite incensed at something I wrote. 😦

karl sent an orchard of exclamation points (happy ones, that is) on Saturday along with a note about color-invaders.sh, which apparently has its roots on the Crunchbang forums.

2015-02-26-6m47421-color-invaders.sh

And there you can see my very bland color scheme, which probably wouldn’t win any exclamation points from karl.

Aside from drawing the classic invaders in colors that you have set for your shell, color-invaders.sh doesn’t really do much. And there are lots of similar tools, that really only show what colors you set, so you can see if your desktop is something worth sharing with the wide, wide world. πŸ˜•

Part of karl’s enthusiasm though, was for a website that lets you experiment with colors and returns the codes necessary to implement them. karl didn’t say where that came from or if it was his own invention, but I don’t think it is.

I am sure there are other sites that similarly streamline the coding portion of custom shell colors; if there is a better one, feel free to mention it. And if you have a script or tool that displays shell colors in a more inventive fashion, pass it along too.

I am sure at least one person — mostly likely karl! — would be happy! to hear about them! :mrgreen:

P.S.: For what it’s worth, I don’t usually run a custom color scheme, and that’s by choice. A long time ago I was looking at the colors in a program and wondering why some things were hard to see, and realized I had inadvertently mashed two similar colors together, making the program somewhat difficult to read. I keep it plain now. Sorry, karl. πŸ˜‰

cam and cam: One for the eyes, one for the ears

In a rather odd twist, I have two programs entitled “cam,” one which has a visual focus, and another which has an audio purpose. Let’s start with the eyes.

2014-12-23-jsgqk71-cam

And I am beginning to believe that tools that translate from standard image formats to terminal output are not so rare after all.

This cam is available in the AUR as cam-git, but to be honest, the version given there wouldn’t build for me.

However, following the instructions on the home page made a workable cam, and as you can see, it converts our old pal Smiley into its text-only version with no real effort. It also manages a fair representation of the original colors, and shades things appropriately where it can.

cam also squeezes its output to fit the current terminal dimensions, without losing the aspect ratio — something I liked in the last converter we saw, and in others from years past.

cam seems eager to take on the role of a slideshow tool as well, with options for pausing between separate image files, preset looped shows, sizing in proportion to the terminal dimensions, and eight- or nine-position alignment that overwrites the current terminal content. It’s a nifty effect.

This cam is a solid thumbs-up in terms of graphics viewing for console environments, and unless you have something specific that you need from another converter tool, it might usurp others you already know.

Here’s the other cam, which is an acronym for CPU’s Audio Mixer. I’ve looked high and low for a home page for this cam, but the only sites I can see in the source code, and the only addresses I find in the Debian packages are all dead.

2014-12-23-jsgqk71-cam-02

Which might be a foregone conclusion, since cam’s source codes show dates as early as 1994, and I don’t expect the home page for an OSS-era audio mixer to survive 20 years until now. Not that it can’t be done, only that it doesn’t surprise me if it didn’t.

This cam seems to work well in hand with alsa-oss, but the only mixer controls I can muster are the ones you see in the screenshot.

I also can’t account for the oddball characters used in cam’s display, but I’m willing to either chalk that up to cam’s age, or to my less-than-expert setup, or using the Mint live environment. Any one or all could be a factor there.

This second cam might be a little less useful for those reasons, but it also has most of the requisites I look for in a decent console application — good use of color, onboard help and key cues, and a straightforward focus that doesn’t wander all over the map.

Still, it’s good to know it’s available, even if it’s not altogether as employable as it may have been. 😦

dbar and cpubar: Progress for the people

I mentioned pscpug over a month ago, as a neat, vertically scrolling CPU monitor that required very little in the way of system overhead or terminal real estate. You can get something like that from cpubar, which is itself an offshoot of dbar.

2014-12-14-6m47421-cpubar

Showing you one — and in this case, that’s cpubar, modified slightly for terminal width and the display character — is showing you both of them, since they are tightly related. dbar can stand alone or work as a progress bar with other applications, or be modified or injected into other arenas.

Neither one comes with a makefile or any additional components; click on the download links on the home page, and you get the raw .c file … only. You’re signing on for about 4Kb apiece for the pure code though, and I’m fairly sure you can afford it.

It does also make me curious as to why dbar is bundled in Debian. Seeing how the i386 package expands to about 10 times what the raw downloadable takes, this might be one of those very, very few times when you’re doing just as well to download and build it yourself.

In any case, it’s not in Arch or AUR, which is probably more of an oversight than any statement about inflating tiny programs by bundling them in your distro. If you feel like adopting a terribly simple application and adding it to AUR, this would be an easy one.

Speaking directly to cpubar, you have the option (as I hinted) to stretch the bar to a specific length, given in characters. You can also adjust the interval and select a specific character to show. There are no allowances for color, but I’m sure one of you talented C wizards can come up with a solution to that in about an hour. πŸ˜‰

I don’t have any complaints about cpubar (or dbar, for that matter), except to mention that the character count given as a flag is for the length of the bar only, and not your terminal width. In other words, you have to mentally subtract the 12 characters that are shown statically by cpubar, if you want it to fit neatly into a terminal space. It’s not the way I would have written it, but there’s a lot here that can be adjusted to your liking.

And so, in closing, if you’re wondering what use cpubar (or maybe even dbar) could be, think about a two-line terminal emulator pressed against the root window, showing CPU load at a two-second interval. Or if you’re feeling really ambitious, jam it into conky … or maybe conconky.

That should keep you busy for a while. πŸ˜‰

echo: And an inescapable fragment of history

After much internal debate, I decided to include echo in this august parade. echo hardly does anything, but I use it so much that it would be a glaring omission if I didn’t include it.

You probably already know what echo is for: It outputs a string of text. That’s the first line of the man page, after all.

kmandla@6m47421: ~$ echo Hello world.
Hello world.

And now you’ve seen all that echo does … mostly. πŸ˜‰

Like any good tool, it has a few things you can customize. For starters there is an -n flag, which prevents echo from breaking to a new line when it finishes. In other words:

kmandla@6m47421: ~$ echo -n Hello world.
Hello world.kmandla@6m47421: ~$ 

echo can also do some funny things, if you allow it with the -e flag. The man page has a full list, but for example, line feeds are possible. A line feed is not a newline, as this should show:

kmandla@6m47421: ~$ echo -e "Hello \fworld."
Hello 
      world.

And line feeds are not carriage returns, as this should show:

kmandla@6m47421: ~$ echo -e "Hello there, \rworld."
world.there,

If you remember computers from way, waaay back, you probably already knew the difference. If you don’t it might help to imagine a printer head moving across a page. Line feeds advance the paper without moving the head, and carriage returns bring the printer head back to the starting edge without advancing the paper. Put both of them together and you have a newline. And of course, all of this evolved from the days of manual typewriters, when your printer was 168cm tall and took coffee breaks twice a day.

I’ll leave it to you to explore all the subtleties of echo; there aren’t many, but it is a utility that you can use on a daily basis and still not see every option. And of course, echo is part of the world-famous coreutils suite. πŸ™‚

head and tail: Flip a coin

I should have mentioned one or both of these by this point in time. I use both head and tail on an almost-daily basis, and leaving those two out until now was an egregious oversight. 😳

Both head and tail are easy enough to figure out: By default, they show the first and last 10 lines of a file, respectively. Nothing fancy there.

2014-08-04-6m47421-head-tail

There are a few flags that are worth mentioning, and since both head and tail are owned by coreutils, some of those options are shared between the two.

  • -cN: Shows N characters (technically bytes) instead of lines. This can be a godsend if you just want to pluck a certain number of characters out of /dev/urandom.
  • -n: Sets the number of lines to show, so you’re not limited to just 10. You can use bytes here as well, and specify a specific data quantity with conventional suffixes for multipliers. So for example, head --bytes=1b sample.txt would show the first 512 bytes of sample.txt.
  • If you add a minus sign to the --bytes data quantity in head, or a plus sign to the --bytes data quantity in tail, both tools will omit the last or first block of that size. That might be a little confusing; think of head --bytes=-12 sample.txt as “show me all but the last 12 characters of sample.txt” and tail --bytes=+12 sample.txt as “show me all but the first 12 characters of sample.txt.” It might take a little getting used to, but it works, and can be handy.

tail has another flag that deserves attention, mostly because I get the feeling most people don’t know about it. We’ve looked over a lot of log display utilities in the past, and most of them operate by hovering over a log file and echoing it to the screen when it changes. If you pick the right tool, it might also colorize the text. πŸ™‚

Perhaps you knew this and perhaps you didn’t, but tail has a built-in log display mode, as the --follow flag.

2014-08-04-6m47421-tail-follow

As you can see there, with no more than just the -F option, you’ll get a by-the-second update of what appears in a log file, each line added to your display as it is added to the original file. No muss, no fuss.

Like I said, you get both of these tools as part of coreutils, and I have yet to meet a distro that didn’t include that by default. So they’re probably on your machine, and I hope you make good use of them. πŸ˜‰

column: With oddly satisfying results

I’m going to stick to the C section for a day or two, and hopefully whittle down the disproportionate number of titles I have listed there. I’m not sure why, but it seems that between October of last year and now, I managed to collect 30+ titles in the C section alone. And it hasn’t helped that ls vimwiki/ | shuf -n1 kept pulling stuff from outside that band.

column is on the list, and is something I use on a weekly, if not daily basis. Here’s column, in its most daring escapade yet: πŸ™„

2014-07-28-lv-c5551-column

And the attraction should be immediate. If we’re going to talk about tools that improve readability, column needs to be at the top of the list. Even when combined with yesterday’s deluge of colorificated diff tools, column makes things better.

2014-07-27-lv-c5551-wdiff-colordiff-column

It’s not always perfect, but I have a feeling that the escape sequences used to trigger colors might interfere with the final results. No major loss.

The point is that column, by default, and especially when used in conjunction with the -t flag, is going to be a real improvement for scanning lists of data and finding corresponding entries. Keep that in mind next time you’re working with csv files.

column takes very few options, and in general they are only affect how the rows and columns are generated, or determining display width. You won’t find a whole lot of frills with column, even if it does amazing work.

I know what you’re thinking at this point: You’re imagining that a utility as simple and cool as this could only come from one place — coreutils. Surprise: This appears in util-linux in Arch, and bsdutils in Debian. 😯 O_o Why? IDK. IANADD. πŸ˜€

ansiweather: One-line weather report, with frills

If it seems like most of the titles thus far are in the early part of the alphabet, that is only to be expected. There hasn’t been much of a chance to pull in titles from the latter half, after scraping through everything after about section N onward.

So just by virtue of time and random chance, a lot of what I have is in the A through M portion. I hope that doesn’t disappoint. πŸ˜‰

Here’s ansiweather, which might seem a bit minimalistic at first.

2014-07-19-6m47421-ansiweather-01

Mmm, color. πŸ˜€ Let’s get a close-up, and give ansiweather a chance to shine.

2014-07-19-6m47421-ansiweather-02

Whoa! Okay! That’s too close. But I think you can see one of ansiweather’s high points there: the use of specific weather ideographs as embellishments.

ansiweather also allows for forecast data, specific date formats, and of course, specific locations. All condensed into a single-line display.

Pretty cool. Colorful, terse, customizable, lightweight. I can find nothing wrong. Except of course, that those little umbrellas and clouds probably won’t show up in a virtual console. That’s a mighty small complaint though.

At this point, ansiweather is probably either a stroke of genius to you, or something so completely understated as to be rubbish. But consider adding ansiweather to …

  • vtclock, which allows you to pipe in the results of a command. Now you have a weather clock for your desktop;
  • Your .bashrc / .bash_profile, or maybe even somehow part of /etc/issue, which would give every console a weather report at login. This one might take a little effort to produce.
  • ticker or ticker, either of which will scroll that information across your console, vertically or horizontally;
  • figlet, or for real craziness, toilet … say no more;
  • or even just watch, which will allow you to paint it into a corner and update at set intervals. If you use a graphical desktop, try a terminal emulator set to be completely transparent, forced to the root desktop, reshaped to only one or two lines, and updating ansiweather at intervals. It’s like conky, without conky. πŸ˜‰

You might also consider cramming this into a terminal multiplexer, either as a specific panel or “desktop widget,” or through some sort of built-in status bar. Let me know if you figure that one out.

At first ansiweather might seem like a triviality, but like a lot of things with Linux, it’s not the tool that matters. It’s how you use it. πŸ˜‰

xargs: Obviously first

I feel strangely underqualified to mention xargs, even though it’s on my list as the first tool in the X section … once X itself is thrown out, of course. πŸ™„

I’ve known about and used xargs for the better part of a decade now, and it continues to crop up from time to time.

Strangely enough, I couldn’t spit out my own example of how to use it, even if I tried. It’s one of those things that’s around just enough to be useful, but not so often that I take the time to learn it right.

There are a few fun things that you do with xargs, that are worth mentioning.

2014-07-04-6m47421-xargs-01

The problem with that particular example is that you get the same results from

kmandla@6m47421: ~$  find music/ -maxdepth 1 -type d -exec echo "Directory: "{} \;

and so I can’t help but wonder what use it would be.

More helpful is the ability to pass specific information to other programs with xargs. For example. …

2014-07-04-6m47421-xargs-02

There, the results of ls are fed into wc via xargs. The problem again though, is that you get identical results from

kmandla@6m47421: ~/temp$ wc -l output-*

(Some restrictions may apply.) Which, at this point, probably makes you wonder what use xargs is, if so much of it is more easily done with the options available in other software.

Well here’s something that would be a little more tricky without xargs.

2014-07-04-6m47421-xargs-03

There, the -n 2 flag told xargs to lop off the results two at a time, and continue through the list to the end. So each pair of files gets run through wc, a total is shown, and then the next two are sent. An esoteric example, but nifty.

Here’s one more.

2014-07-04-6m47421-xargs-04

This time, xargs encountered the -t flag, which tells it to display the command it has received before showing the output. Useful for troubleshooting your command, or as a visual border for the results you get.

I’m sure you can come up with some more interesting and useful examples than these. Like I said, I encounter xargs just often enough to know what it does and why it’s necessary, but not enough to get into the nitty-gritty.

xargs is in findutils in both Arch and Debian. πŸ˜‰

od: Not “overdose” nor “olive drab”

Until yesterday I didn’t even know the od tool existed.

2014-02-17-lv-r1fz6-od

Which tells you either I haven’t been paying attention, or it’s just never happened that I needed an octal dump utility. πŸ˜• But at least now the name makes sense. πŸ™„

You can see the kinds of things od can do in the screenshot above, and the flag options for od are a mile long. I swear it.

And since od can dump to several different output “types” — including human-readable characters — it means it does have some utility beyond spitting out long lists of numbers between 0 and 7.

But mostly I include it because I happen to think very highly of anything out of coreutils … even if it just dumps files to octal. 😐