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. 😀