Tag Archives: bash

OS X’s Terminal: Getting Home, End, PgUp, PgDn to work

Apple’s Terminal on a Macbook requires a weird combination of fn+shift+left/right, fn+shift+up/down to get Home, End, PgUp and PgDn to work. And that still causes issues in a couple of places.

Despite maintaining my philosophy of “use defaults wherever possible”, I’ve decided to ditch iTerm and iTerm2 for a simple reason: after quitting from Apple’s Terminal, upon restart in Lion I get a screenful of information from my previous session. Quite handy if I had to restart a machine for some reason, but I don’t want to lose the context!

Here are two fixes found Francois Planque’s post.

First part involves fixing the escape sequences sent by the Terminal. Open Preferences (for example, by hitting Cmd+,), and navigate to Settings tab, then for the profile you want to adjust, navigate to Keyboard tab.

Over there, define the following escape sequences upon pressing home, end, page up and page down:

home: \033[1~
end: \033[4~
page up: \033[5~
page down: \033[6~

If you mess up something during input, use your mouse to hit the button “Delete one character”. To get \033 in the dialog box, just press the Escape key instead of typing backslash, zero, three, three.

After applying this, voila! vim and mc now type these keys correctly.

But, you’ve just messed up bash.

Second fix involves editing ~/.inputrc (or /etc/inputrc). Neither of these rc files existed on my machine. From Garret LeSage‘s blog post (and as suggested in a comment on Francois’s blog), I simply copy pasted the following:

"\e[1~": beginning-of-line
"\e[4~": end-of-line
"\e[5~": beginning-of-history
"\e[6~": end-of-history
"\e[3~": delete-char
"\e[2~": quoted-insert
"\e[5C": forward-word
"\e[5D": backward-word
"\e\e[C": forward-word
"\e\e[D": backward-word
set completion-ignore-case On

It’s nice to see an OS X-related tech post that’s still as useful in 2012 as it was in 2005. And it’s even nicer to see that it was originally intended for other UNIX and UNIX-style systems.

By the way: this post’s ID is 2 * 333. Make of it whatever you want. 🙂

Checking out webkit without test cases

So you want to check out webkit to do some hacking. If you already tried this, you know that the test cases folder is enormous.

Not enormous solely by its size (which may be somewhat tolerable), but by amount of files in there. That’s absolutely preposterous. I think that the ratio when I last canceled the checkout was something like 15mb of content versus 75mb of disk space usage. I think I used FAT back then. That means 60mb went just to store information about files. (These sizes of course do not ignore the duplicates in the .svn folders.)

It’s completely irresponsible that someone put those in the project root, where nearly all the subfolders are essential except those test cases.

So if we just want to try out stuff and play around without running test cases ourselves, we don’t want to check out this enormous folder and get stuck on this for half an hour, an hour, two or even more. Here comes svn’s –depth parameter. UPDATE: Note! You will want to double-check that when you copy paste the command line from this site, there is actually two dashes before “depth”. I’ve noticed that during copy-paste, they were replaced by a single line.

$ svn co http://svn.webkit.org/repository/webkit/trunk webkit --depth immediates
$ cd webkit
$ for i in `ls -d */ | sed 's/\///g' | grep -v Tests`; do cd "$i" ; svn update --set-depth infinity; cd .. ; done

  1. So, we checkout only immediate children-files for webkit and put them in webkit subdirectory. 
  2. Then we list only directories, (ls -d */) and remove all the appended slashes (sed ‘s/\///g’). We have one directory per line now. Finally we get only lines that do NOT include word Tests (grep -v Tests).
  3. Finally, we enter each directory, and tell svn to update, but now with infinite depth.
That’s it! You should now have a Webkit working copy.
Tested on Mac OS X 10.6 Snow Leopard, with Webkit revision 52487. YMMV, but I think this should work on any Unix including GNU/Linux. You can probably pull this off on Windows using Cygwin or even msys.

Updated on Aug 22 2012, primarily to update formatting.