macvim doc icons redux & howto

So I had some questions on how I generated the MacVim document/file type icons since the included script has been broken for a lot of people.

To use the /src/macvim/icons/ script, you need to make a few changes:

  1. You need a 512px version of the apple “GenericDocumentIcon.icns”
    • I took the 1024px version from Mavericks, exported all the png files, and created a new icns with 512px max size.
    • I placed the 512px icon in the “icons” directory and modified the docerator.py and make_icns.py files

  2. Copy or export a 512px version of the icon you want to use, rename it ‘vim-noshadow-512.png’, and place it in the /icons folder.
  3. Download a pre-compiled version of “makeicns” and place it in the /icons/makeicns folder, then comment out the relevant portion of the makefile.
  4. Modify the make_icns.py script to generate 512px for all sizes (alternatively you could just change every icon type to the ‘large’ preset instead of ‘small’, I just found it was fewer changes to add 512px to the small preset.)

  5. ‘cd’ into the /icons directory and run: ‘make getevny’ followed by ‘make all’
    (Note: this will generate an error at the end because we’re no longer using the ‘link’ option for any icons, you could always comment out the call to ‘link’ but I just haven’t bothered.)

whitespace in vim

vim_whitespace

So one thing that’s annoyed me about my recent switch to vim, is the lack of any easy way to show all whitespace/invisible characters. “set list” is a great start, but I really want to see ALL invisibles, even spaces, which seems pretty much impossible in vim.

So for now I’ve settled on just showing tabs, eol, etc. at least this makes it so if something looks like a space, it is almost certainly just a plain space.

If you want to mimick this setup, add the following two lines to your .vimrc

au BufNewFile,BufRead *.* set list listchars=eol:¬,tab:\▸\ ,trail:~,extends:>,precedes:<

OSX – Disconnect/Disassociate wifi on boot

So I don’t really expect very many people to care about this, but I finally solved an OSX annoyance that’s been bugging me for a while.

My scenario is this, I use OSX on a desktop with both ethernet and wifi. I prefer to use my ethernet connection, but OSX automatically connects to wifi on boot/wake if I have any saved networks. This causes some problems with my computer being assigned multiple IP’s, trying to register multiple hostnames, etc.

Now the simplest solution would be to simply turn off wifi, and only turn it on when I need it, but that just seems kludgy to me. I want to leave the physical wifi card enabled, but just not connect to wifi on startup.

And it turns out that isn’t possible, but you can force airport/wifi to disconnect from the command line, provided you enter your admin/sudo password. Every. Single. Time.

sudo /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -z

If you try to run that without “sudo” it will tell you:

root required to disassociate

At first, I just set up and alias to this, but it’s still not perfect, since typing a password every time the computer boots, or wakes from sleep is a bit annoying.

This morning I finally found a workaround.

This is a two part fix, first we need to add an entry to our /etc/sudoers file to allow the airport-z command to run as root, without a password.

sudo visudo

And under the line:

%admin ALL=(ALL) ALL

Add the following:

%admin ALL=(root) NOPASSWD: /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -z

This line allows users in the admin group to run the airport command to disassociate, without a password. You can further refine this by replacing “%admin” with your username, so only your user account can run the command without a password.

And a natural extension of this, is that we can now use launchd to automate this at boot.

Donwload this plist file and place it in /Library/LaunchDaemons, repair permissions, and reboot. Whenever you login, this will run, and automatically disconnect wifi. You can further automate this with a tool like sleepwatcher to automatically disconnect on wake from sleep too.

A file broswer for macvim?

macvim-split-browser

So in my foray into learning vi/vim, I’ve discovered a wonderful fork of the already awesome macvim with a built-in file-browser. Now, apparently you can add a file browser to any vi/vim with plugins, but this version is written in Obj-C so it’s native to OSX.

And of course with my luck the fork hasn’t been updated in almost a year.

So I spent a few minutes today to fork the fork and merge in all the latest commits from the upstream macvim repo.

If anyone wants to use this fork, the easiest way is with homebrew, just edit the macvim formula:

brew edit macvim

Find this line:

head 'https://github.com/b4winckler/macvim.git', :branch => 'master'

And replace it with this:

head 'https://github.com/jocelynmallon/macvim.git', :branch => 'split-browser'

Then install from head (be sure to uninstall the old version first if you already had it installed):

brew install macvim --HEAD --override-system-vim