Fix for `open` command in tmux on OS X
This was a deceptively difficult problem to solve that I just encountered, so I thought I would document the fix for the likely droves of others out there who might experience similar issues.
In OS X, a terminal can typically invoke the default program for a given filetype by simply running open file.jpg. This works quite well without additional configuration for most common file extensions. Examples include:
-
open file.htmlwill spawn your default browser withfile.html -
open .spawns a new Finder window at the current working directory -
open file.jpglaunches Preview displaying your photo
However, this all breaks down when you’re running your terminal session within tmux. You’ll likely be granted with the following error:
The window server could not be contacted. open must be run with a user logged in at the console, either as that user or as root.
Yuck.
Here’s the fix…
I...