@madpilot makes

Making the OSX Terminal.app work properly

I just acquired a 13″ MacBook so I can build some me iPhone and iPad apps, and the allure of Unix on the desktop is a nice added benefit, however it is apparent that the default terminal emulator is kind of balls out of the box. I spend A LOT of time in a terminal, with VIM being my IDE is choice. What many people might not know is that modern terminal emulators support mouse gestures, as does vim (:set mouse=a).

I use this. All the time.Vim 7 supports files tabs, which allows you to open multiple files at once (command :tabe ). Vim being vim, you can navigate your tabs using key sequences (Next Tab :tabn Previous Tab :tabp Move to tab :tabm et al.), but clicking stuff with your mouse is easier.The scroll wheel is also quite useful, which vim also supports.Finally, click and dragging over text in vim with a mouse enters Visual mode, which allows you to yank and delete blocks of text, also quite handy.The problem is, Terminal.app doesn’t support mouse stuff… Out of the box any way.

Step 1: Download and install SIMBL

Step 2: Download and install MouseTerm

Step 3: Restart Terminal.app

Right, so that is sorted, next up: OSX’s stupid keybindings. Ok, I guess it makes sense for the home key to go to the very beginning of the document and end to do the opposite, but really the Windows way of home and end placing the cursor to the beginning and end of the line is more practical. Also, PgUp and PgDn don’t work. So, open Terminal.app then select Preferences from the Terminal menu. Click the Keyboard tab, and paste the following strings into the areas next to the Keys:

home: 33[H
end: 33[F
pgup: 33[5~
pgdn:  33[6~

FINALLY, these binding don’t place nice with vim, so open up .vimrc and enter the following:

set mouse=a
map ^[[F $
imap ^[[F ^O$
map ^[[H g0
imap ^[[H ^Og0