iTerm2: How to unsplit a pane back to a tab or window

This morning I accidentally dragged an iTerm2 tab and created a split pane in one of my tabs. I searched for quite a while to find out how to move it back to its own tab. Finally, I found it at http://groups.google.com/group/iterm2-discuss/browse_thread/thread/920ff96f710a0a93:

You can already do this by holding cmd-shift-opt and dragging the pane to a
tab bar or away from any terminal window to create a new window.

Don’t be alarmed by super large VSIZE on OS X

(Also at https://github.com/urbancoding/jenx/issues/32)

Don’t freak out too much if 64-bit processes on OS X have a VSIZE of 10 GB or more.

    marca@SCML-MarcA:~$ cat macruby_test.rb 
    print "What's your name? "
    name = gets.chop
    puts "Hi, #{name}!"

    marca@SCML-MarcA:~$ psgrep macruby
    USER    PID  %CPU %MEM      VSZ    RSS   TT  STAT STARTED      TIME COMMAND
    marca 76551   0.0  0.3 10899176  12272 s004  S+    9:09PM   0:00.06 macruby macruby_test.rb

    marca@SCML-MarcA:~$ top -pid 76551 -l 1 | tail -2
    PID    COMMAND %CPU TIME     #TH #WQ #PORTS #MREGS RPRVT  RSHRD RSIZE VPRVT VSIZE PGRP  PPID  STATE    UID       FAULTS COW  MSGSENT MSGRECV SYSBSD SYSMACH CSW PAGEINS USER 
    76551  macruby 0.0  00:00.06 1   0   40+    131+   5640K+ 15M+  12M+  323M+ 10G+  76551 72846 sleeping 346486362 3266+  189+ 234+    115+    254+   157+    35+ 0       marca

What this shows is a ridiculously simple Ruby program (running under MacRuby) having a VSIZE of 10 GB.

OTOH, Activity Monitor shows up a much more sane “Virtual Mem” of 315.0 MB for this process:

http://cl.ly/3F3N0P2M0l2O3q0b280Y

Also, vmmap seems to indicate that most of the virtual memory comes from “reserved VM address space (unallocated)” and it seems to consider this as unimportant:

    marca@SCML-MarcA:~$ vmmap 76551
    Virtual Memory Map of process 76551 (macruby)
    Output report format:  2.2  -- 64-bit process
    
    ...
    
    ==== Summary for process 76551
    ReadOnly portion of Libraries: Total=68.5M resident=59.0M(86%) swapped_out_or_unallocated=9792K(14%)
    Writable regions: Total=8.1G written=5068K(0%) resident=5164K(0%) swapped_out=0K(0%) unallocated=8.1G(100%)
    
    REGION TYPE                      VIRTUAL
    ===========                      =======
    MALLOC                            286.3M        see MALLOC ZONE table below
    MALLOC (reserved)                   7.8G        reserved VM address space (unallocated)
    ...
    ===========                      =======
    TOTAL                               8.2G
    TOTAL, minus reserved VM space    463.3M

                                         VIRTUAL ALLOCATION      BYTES
    MALLOC ZONE                             SIZE      COUNT  ALLOCATED  % FULL
    ===========                          =======  =========  =========  ======
    auto_zone_0x100bbd000                 256.0M      10635       680K      0%
    DefaultMallocZone_0x100b5b000          29.2M      28569      3207K     10%
    DispatchContinuations_0x100bfe000      1024K          1         32      0%
    ===========                          =======  =========  =========  ======
    TOTAL                                 286.3M      39205      3887K      1%

This issue, by the way, is not specific to MacRuby (my initial suspicion). I saw a similar pattern with Xcode, which also has a VSIZE of around 11 GB. I did not see this pattern with MRI Ruby [ruby 1.9.3p0 (2011-10-30 revision 33570)], Mail.app, Finder, iTerm, Alfred, Safari, or mysqld — these apps all have a much lower VSIZE of around 3 or 4 GB each. I have no idea why.

OS X appears to “reserve” a large amount of virtual memory for 64-bit processes, but they are not necessarily using it just because it’s been reserved for them.

brew install growlnotify-1.2.2 on OS X 10.6 (Snow Leopard)

The latest growlnotify in homebrew (1.3) fails on OS X 10.6 (Snow Leopard), because it’s a Lion-only binary.

marca@SCML-MarcA:/usr/local$ growlnotify 
dyld: Symbol not found: _kSecRandomDefault
  Referenced from: /usr/local/bin/growlnotify
  Expected in: /System/Library/Frameworks/Security.framework/Versions/A/Security
 in /usr/local/bin/growlnotify
Trace/BPT trap

Here’s how to fix it (thanks to https://github.com/mxcl/homebrew/issues/8316):

Easy access to TrueCrypt from the command-line in OS X

TrueCrypt on Mac OS X has a nice GUI, but if you’re a command-line afficionado…

Put this in your ~/.bashrc or similar file:

alias truecrypt='/Applications/TrueCrypt.app/Contents/MacOS/Truecrypt --text'

Then you can do stuff like:

$ truecrypt
Usage: Truecrypt [--auto-mount <str>] [--backup-headers] [--background-task] [-C] [-c] [--create-keyfile] [--delete-token-keyfiles] [-d] [--display-password] 
[--encryption <str>] [--explore] [--export-token-keyfile] [--filesystem <] [-f] [--hash <str>] [-h] [--import-token-keyfiles] 
[-k <str>] [-l] [--list-token-keyfiles] [--load-preferences] [--mount] [-m <str>] [--new-keyfiles <str>] 
[--new-password <str>] [--non-interactive] [-p <str>] [--protect-hidden <str>] [--protection-keyfiles <str>] 
[--protection-password <str>] [--random-source <str>] [--restore-headers] [--save-preferences] [--quick] [--size <str>] 
[--slot <str>] [--test] [-t] [--token-lib <str>] [-v] [--version] [--volume-properties] [--volume-type <str>] [Volume path] [Mount point]
...

or:

$ truecrypt --text --non-interactive --password=(password) --mount /Users/marc/Dropbox/TrueCryptVolume.truecrypt /Volumes/TrueCrypt

marc@hyperion:~
12:31:43 $ ls /Volumes/TrueCrypt
Audio/     Backups/   Documents/ Taxes/

or:

$ truecrypt --list
1: /Users/marc/Dropbox/TrueCryptVolume.truecrypt /dev/disk4 /Volumes/TrueCrypt

or:

$ truecrypt --dismount
$ truecrypt --list
Error: No volumes mounted.

My failed attempt at using autofs to automount TrueCrypt volumes on OS X

I was trying to make it as easy as possible to access our YNAB file which lives in an encrypted TrueCrypt volume. The idea was to have OS X autofs automount the TrueCrypt volume so that when YNAB starts and attempts to load our document, TrueCrypt launches and asks for the password and then the volume mounts. I never got it working smoothly. I also tried sticking the password in the script, which is less than ideal, but that didn’t work either.

The following almost works, but not quite. If you can get it working, please let me know.

First, /etc/auto_master:

marc@hyperion:~
09:30:48 $ cat /etc/auto_master
#
# Automounter master map
#
+auto_master		# Use directory service
/net			-hosts		-nobrowse,hidefromfinder,nosuid
/home			auto_home	-nobrowse,hidefromfinder
/Network/Servers	-fstab
/-			-static
/auto			auto_truecrypt

Then /etc/auto_truecrypt (which is executable):

marc@hyperion:~
09:30:53 $ cat /etc/auto_truecrypt 
#!/bin/sh

TRUECRYPT_VOLUME="/Users/marc/Dropbox/TrueCryptVolume.truecrypt"

key="$1"

if [ "$1" == "Truecrypt" ]; then
    echo "-fstype=truecrypt    :${TRUECRYPT_VOLUME}"
fi

And /sbin/mount_truecrypt:

marc@hyperion:~
09:30:58 $ cat /sbin/mount_truecrypt 
#!/bin/sh

echo "$0: Called with $@" >> /dev/ttys000
# echo open -W /Applications/TrueCrypt.app --args "$7" "$8" >> /dev/ttys000
# open -W /Applications/TrueCrypt.app --args "$7" "$8"
echo /Applications/TrueCrypt.app/Contents/MacOS/TrueCrypt --text --non-interactive --password=(password) "$7" "$8" >> /dev/ttys000
/Applications/TrueCrypt.app/Contents/MacOS/TrueCrypt --text --non-interactive --password=(password) "$7" "$8"

As is, when I have the script calling /Applications/TrueCrypt.app/Contents/MacOS/TrueCrypt with a password, I get:

$ cd /auto/Truecrypt
(Mac locks up with spinning beach ball)

The script actually locks up my MacBook Pro with OS X 10.6.8. The script is probably called in a kernel context or with some big lock and trying to launch a complex userland process from there creates some kind of deadlock. Well, that’s my guess anyway. So be careful — don’t try this if you’re not ready to reboot.

How to build MacVim with Python 2.7

The first few times I tried building MacVim, it kept linking with the system Python. I wanted it to use my Python 2.7 install. I finally found the right incantation:

./configure --enable-rubyinterp=yes --enable-pythoninterp=dynamic --with-python-config-dir=/usr/local/lib/python2.7/config

The --enable-pythoninterp=dynamic was the magic that I needed to make it work.

Skype AppleScripts

These are some AppleScripts that I developed to make it easier to dial into a daily conference call. For this conference call, I dial into an 888 number and then I dial an 8 digit conference code and hit the ‘#’ key to enter a particular conference. Surprisingly, Skype doesn’t let you do this in a simple way by adding something like “,,12345678#” to the phone number, so I had to resort to scripting.

SkypeDialer.applescript provides core services that can be used by other AppleScripts, including SkypeDialerGUI. You should open SkypeDialer.applescript with AppleScript Editor and then save it as a stay-open application (File | Save As… and then for the File Format, select “Application” and in Options, make sure that “Stay Open” is checked). I saved mine in /Applications so I have /Applications/Skype Dialer.app.

SkypeDialerGUI can be used as a regular script or an application.

GitHub repository: skype-applescripts