Pimp my iTerm 8 comments

Posted by robon July 22, 2007

I'm about to show you how I roll with iTerm and Rails application development. It may seem a little screwy to a proficient TextMate users, but hear me out. I know my way around Vim. That makes me very productive with it. My problem with TextMate, is that it isn't totally about getting away from the mouse, clicking, and pressing arrow keys. Don't get me wrong; they get a *lot* right.

"Damn, I though Rob was going to blog about something other then his aversion to non-home row hand positions!"

My whole Mac life changed when iTerm got tabs. It really got me to a place where I didn't miss Linux as bad. But still, opening tabs, logging into servers, changing directories, and starting services, still takes time. When you bounce between projects as often as I do, it becomes a real problem. I had to figure out a way to script some of this.

So, here's what that quest produced. It's a shell script, that runs AppleScript (what a goofy language!) and gets my iTerm window all set up to jump into a project after having been away for a bit. In other words, it opens up tabs and executes various commands in each tab, all following a single press of the "return" key. Check it out:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/sh

if [[ $# == 0 ]]; then
  PROJECT_DIR=$PWD
elif [[ $# == 1 && -d "$1" ]]; then
  PROJECT_DIR="$@"
else
  print "usage: iterm.sh [rails project directory]"
  return 1
fi
    
osascript <<-eof
  tell application "iTerm"

    make new terminal

    tell the last terminal

      activate current session

      launch session "Default Session"

      tell the last session
          set name to "app"
          write text "cd \"$PROJECT_DIR\"/app"
          write text "clear; ls"
      end tell

      launch session "Default Session"
      tell the last session
          set name to "app"
          write text "cd \"$PROJECT_DIR\"/app"
          write text "clear; ls"
      end tell

      launch session "Default Session"
      tell the last session
          set name to "server"
          write text "cd \"$PROJECT_DIR\""
          write text "./script/server"
      end tell

      launch session "Default Session"
      tell the last session
          set name to "console"
          write text "cd \"$PROJECT_DIR\""
          write text "./script/console"
      end tell

      launch session "Default Session"
      tell the last session
        set name to "yell"
        write text "cd \"$PROJECT_DIR\""
        write text "cd log"
        write text "tail -f yell.log"
      end tell

    end tell
  end tell
eof

To use, save to an executable file and run from the same directory as your Rails project. Pass the project directory as an argument to the script.

$ iterm tupleshop.blog

then watch what happens:

I use the first two tabs as my primary work areas. I usually have the Vim screen split once or twice. Any more editor's open and I usually loose track of where things are. The functions of the remaining tabs should be evident. The only strange one is named "yell." That's where I tail my stupid simple log file (that I blogged about once) called yell.log.

So, if you find this solution, or the problem I'm trying to solve, interesting, please share your ideas.

(I'd love to meet a TextMate pro and swap for Vim training sessions. Although, I know from experience that getting fast is not something you do in one sitting.)


FireFox lost my favorite feature! 3 comments

Posted by robon July 19, 2007

For years I waited for FireFox to get some of the most basic Emacs keybindings. My favorite was CTRL+A which would take you to the beginning of the location bar, or where ever you happened to be editing text. Very handy. I just upgraded and POOF!... it was gone. I'll make some noise to the developers and try to get this fixed ASAP. Wish me luck.

UPDATE: Sorry, I must be going crazy. Looks like this was the case of my system getting temporarily borked. The strange thing is that I verified this with a coworker who said he noticed it too. But maybe he didn't actaully try it. Anyway... I'm glad this was my mistake and not the fault of Firefox.


Apple! Go add me some keybindings. 2 comments

Posted by robon July 14, 2007

One step closer to a mouse-free lifestyle:

  1. For window movement: I'll hold down "~" and "Space" with my left hand (5th finger and thumb), while my right hand moves the currently selected window around with the Vi style movement keys: "h", "j", "k", and "l".
  2. To resize a window: I'll Hold down "~" + "3" + "Space" (5th and 3rd fingers, and thumb), where Vi movement keys now control the position of the bottom right corner of the window relative to the upper left corner--which remains stationary--resizing the window. (Most X users don't need such a detailed explanation. Instead, read: "Enlightenment style window resizing.")

I don't want to induce too much panic, but if I don't see these ideas added by Leopard, I'm going to drive down there and have a serious talk with someone–yeah, maybe you Steve–and it could get ugly.