Saturday, March 13, 2010

Mac OS X Backspace and Delete For Old Unix Geeks Like Me

 Below is a picture of my toolbar:

As you can tell, this is not your typical toolbar on a MacBook Pro.  I have demoted the standard Apple apps and promoted applications such as:

  1. Terminal
  2. Console
  3. Network Utility
  4. System Profiler
  5. Activity Monitor
  6. Techtool Deluxe
  7. VirtualBox
  8. Spaces
  9. Time Machine
  10. Opera
  11. Chrome
  12. Firefox
So, I am not your typical Apple Fan Boy user is my point.  I like the power tools of life.  I like saving time.  I love that my MacBook Pro runs Unix underneath.  I am more and more impressed with Mac OS X until I ran into the no damn BACKSPACE key on the MacBook Pro.  That was a stupid design decision.   Please don't tell me how Steve Jobs is god and that whatever decision he makes are great.  I will show you the Apple Lisa in my father's basement.  I will show you pictures of the Newton.  Even Apple can make mistakes.  Don't get me wrong, Steve Jobs is a marketing genius, but he is not god.

I am an old Unix guy.  I have been using Unix since 1981.  That is a lot longer than most, but not as long as some.  What I love about Unix is its simplicity.  It is elegant in its simplicity.  Everything is a file with Unix and that makes it very extensible.  It is exponentially extensible.  I love power tools that just work.  I am a vi person and up until recently a Pine person for email.  Why?  Huge capabilities with absolute minimal key strokes.

Bill Joy used to send his emails with lower case only because he calculated that he saved something like 27% by avoiding the short pause to hit the shift key at the beginning of sentences.  I think he is probably unique in that style :-)   If you look at vi, you see an extremely powerful editor.  Speaking of vi, there is a long standing story about Bill writing vi in a weekend.  He did not.  See below.
Below is a short snippet from an interview with Bill Joy on the creation of vi that was reproduced by SoftPanorma which was reproduced from Linux Magazine November 1999 FEATURES onThe Joy of Unix: 
Linux Magazine: So you didn't really write vi in one weekend like everybody says? 
Bill Joy: No. It took a long time. It was really hard to do because you've got to remember that I was trying to make it usable over a 300 baud modem. That's also the reason you have all these funny commands. It just barely worked to use a screen editor over a modem. It was just barely fast enough. A 1200 baud modem was an upgrade. 1200 baud now is pretty slow.
9600 baud is faster than you can read. 1200 baud is way slower. So the editor was optimized so that you could edit and feel productive when it was painting slower than you could think. Now that computers are so much faster than you can think, nobody understands this anymore.
The people doing Emacs were sitting in labs at MIT with what were essentially fibre-channel links to the host, in contemporary terms. They were working on a PDP-10, which was a huge machine by comparison, with infinitely fast screens.
So they could have funny commands with the screen shimmering and all that, and meanwhile, I'm sitting at home in sort of World War II surplus housing at Berkeley with a modem and a terminal that can just barely get the cursor off the bottom line.
It was a world that is now extinct. People don't know that vi was written for a world that doesn't exist anymore -- unless you decide to get a satellite phone and use it to connect to the Net at 2400 baud, in which case you'll realize that the Net is not usable at 2400 baud. It used to be perfectly usable at 1200 baud. But these days you can't use the Web at 2400 baud because the ads are 24 kilobytes.
Back to the point of this blog post where I am admittedly jumping into some historical rat holes :-)  I have been using Unix since 1981 and have always used the DELETE key as the Unix intr and the BACKSPACE key as the erase key.   What does this mean in English?  The DELETE key interrupts or basically kills what you were doing on a command line.  The BACKSPACE key will backspace to the left of where you are on the line and remove whatever it backspaces over.  Some individuals use CONTROL-C as the Unix intr function.  I never liked that because that involved pausing and hitting the control key then the C key.  Like Bill Joy, I believe shorter is better.

On the MacBook Pro there is no BACKSPACE key.  This is stupid.  Apple easily could have put a BACKSPACE key on the keyboard.  Why do I need only one FN key, one CONTROL key, but I need TWO COMMAND keys and TWO ALT/OPTION keys?  I realize that the Apple Fan Boys and Apple Sycophants will go nuts over this heresy, but it makes no damn sense....

BUT, there is a solution.  After googling my brains out and going down many, many wrong paths, I have found a solution that works for me.  Now, for the average Apple user, this may not be the solution, but for old Unix geeks, it is a very clean solution.

You need to do three things:

  1. Turn off the keyboard shortcut for the F12 key that pops up the Dashboard.  You do this by going into System Preferences--> Keyboard --> Dashboard & Dock then deselect the Dashboard F12 function.  See below.

    2.  Select the Use all F1, F2, etc. as standard function keys.  What this means is that to use the functions that are represented by icons on your upper row function keys, you MUST first hold down the FN key.  No big deal to me, because these keys are not used that often for a typical Unix geek.  Your typical Apple user might freak out though.  Your typical Apple user is not using a Unix terminal all the time like I am though either.   You do this by going into System Preferences--> Keyboard --> Keyboard then select the Use all F1, F2, etc. as standard function keys.    See below.

   3.   Redefine the F12 key by going into the Terminal Settings--> Preferences --> Settings --> Keyboard  and redefine the F12 key to be a CONTROL-H which shows up as a \010  as you see below.

   3.  Then make sure your  stty looks like the following in your .cshrc file   stty  intr '^?'
         The system defaults to having CONTROL-H as the backspace key.  In other words, the system puts in the equivalent of     stty erase '^H'

Now, when it hit the DELETE key it will operate as an intr and when you hit the F12 key it will operate as the erase function as all of us old geeks are used to.   Three easy steps.....

NOTE:  A question I received in early August 2010 asked me, "I've just switched from a PC to MAC, and this is also my only complaint. I'm just a regular user though - how the heck do I access my .cshrc file so that I can follow your above instructions? Thanks so much." 

The answer to the question is that the terminal app is located in the Utilities Folder inside the Applications Folder.  The purpose of this post is for those individuals who are using a terminal window and want the  DELETE key it will operate as an intr and when you hit the F12 key it will operate as the erase function.