An ncurses virgin installs it and tries it out



Having dabbled in a ton of different languages lately, I felt the overwhelming urge this week just to get back to some good ol' C, and what better and more productive way to do so that to mess around with ncurses!

I have to come clean and admit this, but I've never really used ncurses for anything other than some rudimentary crap, and what little I did I've completely forgotten in a vast ocean of nested Java streamreaders. I've written a ton of scripts and basic applications to run in the shell (mostly for server admin tasks) but I've never used ncurses to make more sophisticated shell interfaces, so I thought I'd finally give it a shot.

Getting ncurses in the first place

The first thing that always trips me up is I forget having the ncurses binaries (which most free and open source OSs do) is different from having the development versions you can include in C code. Fortunately it's really simple to install on at least the systems I maintain.

Here's a quiz: which is for FreeBSD and which is for Fedora? :)

# pkg_add -rv ncurses-devel
# cd /usr/ports/devel/ncurses-devel
# make install clean
# yum install ncurses-devel

In either case, it works! Hallelujah! I can never spell that word.

#include <stdarg.h>
#include <ncurses.h>

int main(void) {
    printw("Grilled cheese sandwiches!");

    return 0; /* Is all gooooood! */

The iPad has just come out!? Why ncurses?

Two reasons. First, I have a whole bunch of machines that just exist to run Folding@Home that don't have X on them at all, and I would love to create pretty little interfaces I could use with them.

Secondly, and you'll probably think it's silly, but our first family computer was a DOS machine and I've always wanted to write my own *nix versions of some of my favourite old DOS applications that I can run in FreeBSD or on my Mac Terminal. For example, my favourite editor of all time is still the IBM E Editor, and having a version of that with syntax highlighting would make me ditch Vim, nano and TextMate for good! I know, I know, it's sad and silly, but it'd be so much fun! Do any open source implementations of REXX exist? That was a fun language :).

My studies start again in two weeks, wonder how much of this I can do before then? At the very least I'd like to have that old DOS menu system ported. Sounds like an alcoholic beverage.

Author bio and support


Ruben Schade is a technical writer and infrastructure architect in Sydney, Australia who refers to himself in the third person. Hi!

The site is powered by Hugo, FreeBSD, and OpenZFS on OrionVM, everyone’s favourite bespoke cloud infrastructure provider.

If you found this post helpful or entertaining, you can shout me a coffee or send a comment. Thanks ☺️.