Sunday, September 25, 2011

tmux: awesome yet frustrating

So tmux is pretty awesome. You can split a terminal into several windows, and then you can subdivide each window into panes. (A terminology that I rather like.) Here's my config file (~/.tmux.conf):

bind k kill-session

new -s theusual -n tehusual
split-window htop
split-window
clock-mode
setw main-pane-width 55
select-layout -t 0 main-vertical
selectp -t 0

And yeah, that didn't work the first time. There are some things about tmux configuration that are... non-obvious. Let's run through the config, and then I'll detail my issues and what I did to fix them. In the following, I'll be using Emacs notation (i.e. C-x means Ctrl+x, M-x means Alt+x, et cetera.)

bind k kill-session

This one's easy. This binds the tmux kill-session command to C-b k, so that I can exit tmux easily without having to close each pane individually.

new -s theusual -n tehusual

This creates a new session, which is the parent object of windows. That is, one session can have several windows which can in turn have several panes. This session is called "theusual," and it creates a window inside the new session called "tehusual." It was unclear from the documentation whether sessions and windows share a namespace, so I thought it best to differentiate the two.

This is also where I ran into my first problem. Try as I might, tmux would not launch into my new session. Instead, it would create a default session first and put theusual in the background, thus squeezing a couple extra keystrokes out of me in the process.

After an hour of frantic googling, the solution turned out to be to not run "tmux" but instead run "tmux attach". The latter instructs tmux to not create a default session, and instead attach itself to an already running session, the one that had just been created by running .tmux.conf. (Fun fact! You can detach tmux instead of quitting entirely with C-b d.)

split-window htop
split-window
clock-mode

The next three instructions cause tehusual to be split twice so that it now contains three panes: the original pane which is split in twain and then split again. Note that panes are zero-indexed. So pane 0 contains a bash prompt (the default command,) pane 1 contains htop (a rather nice top replacement,) and pane 2 is placed into clock mode.

Here's where I ran into the second and third problems. At first, no panes were being created at all! I was stuck with just one big pane. After a while, I discovered that I did not actually have htop installed. A quick visit to SlackBuilds.org fixed that, but it leads us to an important point. tmux fails silently if the command passed to split-window fails. Silent failure is always a bad design choice, but here again it rears its ugly head.

The last two lines had originally been one: "split-window 'tmux clock-mode'". Well, tmux didn't like that. The solution seemed to be to run split-window on a line by itself, and then switch the newly created pane, which apparently has focus, into clock-mode.

setw main-pane-width 55
select-layout -t 0 main-vertical
selectp -t 0

The last three lines ended up being the least trouble.

Let's do the second line first. A window can be given various layouts which automatically reposition panes. I chose "main-vertical," which rearranges panes into one main pane and one or more baby panes. The "-t 0" option simply specifies window 0 (aka tehusual).

Going backwards, the first line sets a window option that specifies the main pane in the main-vertical layout should be 55 in width; a number I arrived at after experimentation.

Finally, the last line selects pane 0 as the pane having focus. Fun facts! You can switch pane focus with C-b o and rotate panes with C-b C-o. That is, the contents of pane 1 go to pane 0, the contents of pane 2 go to pane 1, and the contents of pane 0 go to pane 2. It's a nice quick way to give htop more real estate when I need to fiddle with it.

And there you have it. The icing on the cake was to add " [[ $TERM != "screen" ]] && tmux attach && exit" to my .bashrc file. This checks to see if my current terminal is already tmux (tmux terminals identify themselves as screen, presumably for interoperability with GNU screen.) Then it executes "tmux attach" and then exits.

And yes, I know it's silly to run konsole now, but I haven't gotten around to configuring xterm.

Monday, August 29, 2011

Ready Player One - A Review

I just finished reading Ready Player One by Ernest Cline. RPO is a book that has exactly two things going for it. A heaping tablespoon of 80s nostalgia and promise. Regarding the former, I can only barely remember the 80s (for which I daily thank an assortment of deities,) so it does not apply. Regarding the latter, I am greatly anticipating Cline's second book. But his first one is as standard fare as it gets. Minor spoilers ahead!

The setting is cyberpunk. Classic cyberpunk. The world sucks, evil corporations rule everything, and the populace frolics in a fantastic virtual world. Enter OASIS, every MMO you ever want to play. It is so immersive and pervasive that it has become synonymous with "internet." Non-gamers can stick to the delights it offers in non-PVP zones, while gamers can go to any of the thousands of gamer-oriented worlds, themed however you like. Fantasy worlds. Cyberpunk worlds. Western worlds. You name it, OASIS has it.

Enter James Halliday, the reclusive, eccentric multibillionaire creator of OASIS who dies in the second paragraph. After his death, his video will is released. Turns out he hid an easter egg worth his entire fortune somewhere in OASIS. Thousands, tens of thousands, hundreds of thousands of egg hunters (gunters) spend years trying to find Halliday's egg. Enter Wade Watts, the book's disadvantaged teenage protagonist, and his OASIS friends.

Halliday's (and the author's) great love was 80s geekery. Dungeons and Dragons, video games, mecha anime, cult classic movies, et cetera. Various allusions to everything from Atari 2600 games to Rush in his video point the way to the egg. In this, Cline's knowledge and love of 80s geekery shines through, from bits of Pac-Man trivia to D&D adventure modules. It shines brightly and focuses into an amplified beam of coherent light, piercing readers' eyeballs and making them cry, "Ow! My suspension of disbelief!" It often feels like the book is an outlet for Cline's hobbies. A way to get the entire world to admire his knowledge of the decade's best subculture. The book is littered with bits of trivia that just don't belong, scenes that break the sweet, sweet illusion of fiction.

Neither the plot nor the characters do much to elevate the book beyond "compendium of trivia." The characters are archetypal, and the plot is extraordinarily predictable. In fact, I would call it nothing more than the ultimate adolescent male geek fantasy. Our teenage male protagonist saves the (virtual) world, becomes filthy rich, and gets the cute/shy/geeky girl. And all by playing video games, listening to Rush, and watching Monty Python films. Every geek dude having spent sufficient lonely Friday nights playing video games alone in his room has already envisioned the entire plot of the book. Or at least I have. Often. Before crying myself to sleep.

All in all, I give the book three out of five Awesome Book Merit Points. It's not a bad book exactly, but it contains no surprises, and its greatest strength (80s trivia) frequently turns into one of its weaknesses. It's certainly worth a read if you're jonesing for some 80s nostalgia. Or, like me, you're just a video game history buff. Otherwise, I would skip it and wait for his next book.

Incidentally, I think Cline is a very promising novelist. With a little restraint and direction, his obvious enthusiasm for awesome stuff could be channeled into something truly great.

Thursday, March 24, 2011

Point-of-Sale with Bitcoins

I've been thinking a lot about Bitcoins lately. For those of you who are too lazy to click links, Bitcoins are a brand new cryptocurrency. They're backed by some heavy-duty economic theory and secured by modern cryptography. They're entirely digital and decentralized. You don't need any banks or anything to transfer Bitcoins from one person to another, just one of their unique Bitcoin addresses and a handful of IP packets. The last I checked, 1 BTC = $0.84 USD.

So I got to thinking about issues that might occur in the event that Bitcoins catch on. First, they'll need some fancy symbol that you can type with shift and 4. I recommend a B with lines through it.

Secondly, there needs to be a convenient way for Bitcoins to be used out in meatspace. There needs to be a quick, point-of-sale-type way to transfer Bitcoins from one entity to another. I have a couple of thoughts for this.

The obvious solution is smartphones. Anyone with a smartphone running a Bitcoin client could, for example, scan a QR code for the Bitcoin address of an establishment at the register and transfer money that way.

The second thought would be if everyone carried their Bitcoin wallets around on a thumb drive, encrypted with a PIN number or some such. Then a cashier could transfer the money on a computer behind the counter, or, even better, a dedicated PIN-pad-esque device.

Anyway, just a couple of thoughts about Bitcoins in the real world.

Saturday, March 5, 2011

Gnome 3.0 and KDE4's netbook interface

There's been some kerfluffle over GNOME 3 removing minimize and maximize buttons. Here's my two cents!

I've been using KDE4's lovely netbook interface fairly extensively for a couple of months now, and I've grown to love it. Although minimize and maximize both still exist, at least, their importance is greatly diminished. All windows are maximized by default, and minimization is accomplished with smart hiding. I.e., if I click the activity with which I launch applications in the activity switcher in the panel, all windows get hidden.

This is only annoying (and easily remedied at that) once in a blue moon, when I'm trying to drag and drop between applications. Otherwise, it makes sense and is exactly what I want. One application has all of my focus at a time, which is exactly what I do on other desktop environments anyway. Everything else is just an alt+tab away.

I believe this is a tentative step in the right direction, but Gnome is going about it all wrong. Features in flux shouldn't be removed for removal's sake (which is what seems to have happened,) but de-emphasized by other smart design chioces.