All posts by Peter Ridge

Peter is a product development and management professional whose career has spanned from computer hardware and software engineering to product packaging, print advertising and user experience design. He is a published author and has applied his skills to a variety of businesses from start up ventures to top-10 media companies.

Flashback: Windows 386

Previously, I had posted about good ole Windows 1.0. Oh the memories! Well, if that wasn’t enough retro for you, here’s some Windows/386 nostalgia.

In addition to running multiple Windows applications, Windows/386 was able to run multiple DOS programs simultaneously utilizing the 80386 CPU’s protected (a.k.a. virtual 8086) mode. Each program would get its own virtual address space as if it had all the RAM to itself (less a few kilobytes of overhead for the OS to manage everything). And it looked like…OS/2! Even the promo video lauded that fact.

And here it is, the Windows/386 promo video. Warning: Make sure you’re sitting down.

More Windows/386 goodies:

Pidgin Has No Sound In Ubuntu Gutsy Gibbon

For some reason, Pidgin, which is included in Ubuntu 7.10 Gutsy Gibbon, has no notification sounds even though other applications do play properly. Whether I selected Automatic or ALSA as the output method, no sounds would play. Here’s how I fixed it.

  1. In Pidgin, select Preferences from the Tools menu (or press Ctrl+P)
  2. Click on the Sounds tab
  3. In the Method drop down list, select Command
  4. In the Sound command text box, enter the following: aplay %s
  5. Select an event with an assigned sound from the Sound Events list
  6. Click the Test button. You should now hear the notification sound
  7. Click the Close button

Aplay is the command-line ALSA sound player. I tested it on the command line and it played audio files just fine. So, it also works in Pidgin.

Syntax Errors Running sh Scripts on Ubuntu

Normally, I install programs from the Ubuntu repositories but today I needed to install a VPN client from a tarball using a shell script. When I ran the included install.sh file, I got a couple syntax errors:

install.sh: 22: function: not found
install.sh: 24: Syntax error: “}” unexpected

Looking inside the script, I saw that it runs /bin/sh. Nothing unusual there. Well, it turns out that on Ubuntu, sh is a symlink to dash. Apparently, since the Edgy version of Ubuntu, sh has been pointing to dash and causing various compatibility problems with custom scripts meant for sh. I’m running Gutsy so my sh points to dash as well.

Two quick ways to fix the problem is to either change #!/bin/sh in the script file to #!/bin/bash (which I did) or change the symlink for /bin/sh to point to bash instead of dash. I may opt for the latter but the former worked just fine to get my VPN client installed.

Monitor Linux Exit Codes on the Command Line

As you may already know, when programs end in Linux they return a value to the shell known as an exit or error code. It’s often a zero when everything is OK and a positive or negative number when something goes wrong (the actual definition is program-dependent). Normally, this value is used by scripts to know if a command failed so that it can act accordingly. However, as a power user, it’s good to know about this value as well.

The most common way to determine what exit code was returned by a command is to output the contents of the special shell variable ‘?’ to the console. This is accomplished as follows:

echo $?

For example,

~$ date
Wed Nov 13 21:24:07 PST 2007
~$ echo $?
0
~$ _

Here, I ran the date command which displayed the current system date/time. Then, by echoing the ‘?’ variable, I see that the date command exited with a code of zero indicating that everything was fine. Contrast this with the following:

~$ ls foo
ls: foo: No such file or directory
~$ echo $?
2
~$ _

According to the man page for the ls command, the exit codes are defined as “Exit status is 0 if OK, 1 if minor problems, 2 if serious trouble.” Since there was no file or directory named ‘foo’, the ls command returned an exit code of two to indicate “serious trouble”.

OK, so what if you always want to be able to tell what the exit code of a command is without having to always remember to echo it to the console? Well, you can add the value to the command prompt. Simply insert the string ‘$?’ wherever you like in your existing prompt string (PS1, PS2, PS3 and/or PS4).

My original PS1 was

‘u:w$ ‘

which looks like,

peter:~$ _

So, I added ‘:E$?’ between the user name (u) and colon and exported the new string to PS1.

export PS1=’u:E$?:w$ ‘

Now, my prompt looks like,

peter:E0:~$ _

I added the ‘E’ character to remind me that this is an error/exit code but you can leave it off. Going back to the ls example, let’s see what happens with the new prompt.

peter:E0:~$ ls foo
ls: foo: No such file or directory
peter:E2:~$ _

As you can see, my new prompt makes the exit code 2 plainly visible. I no longer have to bother to type the echo command and I can even check previous exit codes in the backscroll buffer. You can’t do that with the echo command since the ‘?’ shell variable is overwritten after every command.

Got more cool Linux tricks? Share them in the comments.

Gmail Macros Update for Greasemonkey

Since the release of the new and improved Gmail, Mihai Parparita’s Gmail Macros script for Greasemonkey stopped working. If you use Gmail but haven’t tried this script before, it’s a must-have for a more complete set of keyboard shortcuts for Gmail.

Mihai has a new version of the script on his blog, Persistent.info. If you’re really in a hurry, you can just click, Install Gmail Macros, right now. Note that you need to have the Greasemonkey add-on for Firefox in order to install and use this. Also, remove the older version of Gmail Macros if you still have it.

The following is a quick guide to the commands provided by the new Gmail Macros:

Label management
To use these, press the shortcut key followed by just enough letters of the desired label name for it to be uniquely identified. A bubble will display what you’re typing as well as the matched label’s name. Gmail natively has a g shortcut but the script will enable this functionality for all your labels, not just the special Gmail ones such as inbox.

g: Go to a label
l: Apply a label
b: Remove a label

Message viewing and management
e: Archive (works in all views, unlike the y shortcut)
d: Discard (mark as read, then archive)
f: Focus (view all unread and inbox messages)

The d shortcut is a bit of a misnomer since it doesn’t really throw the message away. If you really want to put a message into the trash, the native shortcut is Shift+3, which is #.

Selecting messages by type
Shift+8: followed by a (all messages), n (none), r (read), u (unread), s (starred) or t (unstarred)

Shift+8 is a nicer choice than the old Shift+x since Shift+8 is * which is commonly used as a wildcard character that means “everything”. Thus, the shortcut sequence *r nicely translates to “select all read”.

Note that previously, r marked messages read and Shift+z marked them unread. This is handled directly by Gmail now with the Shift+i (read) and Shift+u (unread) shortcuts. However, it would be nice to have r and u as alternatives since they are more intuitive and align with the Shift+8 shortcuts. Alas, u is already used natively to go back up to the message list view.

The t shortcut to trash a message is gone due to Gmail’s native Shift+3 shortcut. I liked the t shortcut, but there were times when I accidentally hit t when I meant to press y, so Shift+3 is safer.

It seems that the help screen, which popped up when the h key was pressed, is also gone. This was very handy for learning the shortcuts, both the native Gmail ones as well as the new ones added by the script. Hopefully, it’ll be added back as well.

The full list of native Gmail shortcuts can be found in the Gmail Help topic, What are the keyboard shortcuts?

Bonus tip: If you also use the Mozilla Thunderbird email client and wish you had some Gmail-like shortcuts for it, check out the GmailUI add-on. It has many handy features including the y (archive), j and k (up/down message) shortcuts, Gmail-like search expressions and quick calculations from the search box.