Tag Archives: osx

So you want to move your Homebrew folder

By default, Homebrew gets installed under /usr/local. This is great, because it doesn't require you to use sudo to install and upgrade packages. But the downside is that it turns your /usr/local directory into a git repository. If you don't have any conflict with this, then by all means, stick with the default.

I had a conflict. Specifically, I use nave for node version management. Unfortunately, both Homebrew and nave drop a README.md in /usr/local, which means nave frequently modifies a file that's under Homebrew's version control and brew update breaks.

Solution

I decided to "move" my Homebrew directory to ~/Homebrew. Here are the steps I followed:


I didn't document this as I did it. Hopefully, I didn't forget anything.

updated

Yosemite Upgrade Changes Open File Limit

OSX has a ridiculously low limit on the maximum number of open files. If you use OSX to develop Node applications -- or even if you just use Node tools like grunt or gulp -- you've no doubt run into this issue.

To address this, I have this line in my $HOME/.bash_profile:

ulimit -n 1000000 unlimited

And a corresponding entry in /etc/launchd.conf:

limit maxfiles 1000000

That solved the problem until I upgraded to OSX Yosemite, after which I began seeing the following error every time I opened a terminal window:

bash: ulimit: open files: cannot modify limit: Invalid argument

Oy.

Luckily, I a little Google foo yielded this Superuser post (and answer).

So it was a quick fix:

$ echo kern.maxfiles=65536 | sudo tee -a /etc/sysctl.conf
$ echo kern.maxfilesperproc=65536 | sudo tee -a /etc/sysctl.conf
$ sudo sysctl -w kern.maxfiles=65536
$ sudo sysctl -w kern.maxfilesperproc=65536
$ ulimit -n 65536 65536    

Then I updated my $HOME/.bash_profile to change the ulimit directive to match that last command, above, and I was back in business.

Fargo as a Fluid App

I thought it would be cool to have Fargo as a separate Fluid App. For those who don't know, Fluid let's you make a web app into what feels like a regular desktop app (for Mac OS X only). For me at least, this will make it easier to find Fargo among my many open windows and browser tabs -- now it's got it's own icon in my Dock and it's own spot in the Cmd-Tab switcher. It makes Fargo feel like the first-class Mac App that it is.

Here my switcher now -- there's our beloved dino!
enter image description here

If you want to set this up too, know that I had to jump through a few hoops to get it to work. The difficulty appeared to be a by-product of Fargo needing to get my authorization to connect to my Dropbox account (in technical terms, OAuth is a pain in the ass). The workaround was to get this authorization before creating the Fluid App.

  1. Open Safari
  2. Go to http://fargo.io to launch Fargo
  3. Follow the prompts to authorize Fargo to connect to your Dropbox account
  4. Close Safari (optional)
  5. Create your Fargo Fluid App (follow the instructions on http://fluidapp.com/)
  6. Launch your new Fargo Fluid App

Why did that work?!

I'm using a free version of Fluid (for now -- still kicking the tires). The free version doesn't have separate cookie storage -- it shares it with Safari (Fluid is built on Apple's WebKit, like Safari). So, by setting everything up in Safari first, Fluid was able to piggyback on that setup when it created the Fargo app. Neat trick -- but not a long term solution. For example, I want to pay for the full version of Fluid (to support the developer), but I suspect this trick won't work in the full version.

Using watch with a bash alias

I love the Unix watch command. On OSX, you can install it easily with Homebrew:

brew install watch

Something I didn't realize until 10 minutes ago is that if you want to watch the output of something in your bash aliases, watch will complain because it cannot find the command. This is because watch evaluates the command you pass to it with 'sh -c', which does not expand aliases. However, if you also create an alias for watch itself, aliases will work. So, you can add the following to your .bashrc:

alias watch='watch '

Note the trailing space inside the quotation marks.

Link:

Remap Mac Terminal Command-K

In case I need to remember that I did this...

By default, the Mac Terminal assigns the "Clear Scrollback" command to Command-K. This is annoying, because I often use Nano, which uses Control-K to cut a line of text, and I frequently press Command-K instead of Control-K by accident. This clears my screen while I'm in the middle of editing a file. Very annoying.

The solution is to assign a new (harder to hit by accident) command to the "Clear Scrollback" command, so that when I inevitably mistype Command-K, nothing happens.

Remap Command-K