Enable Sublime Text in Tmux Command Line on MacOS

Problem Description

When you create a symbolic link to start sublime text editor from command line in tmux, you get an error message:

1
Unable to launch sublime text

This is due to tmux doesn’t have root access to the bin directory. The following steps fixed this issue for me on my Mac.

System Details and Application

  • OS:

    1
    macOS Version 10.13.5
  • Applications:

    1
    2
    Sublime Text 3
    Tmux running from iTerm 2
1
ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl

Install a wrapper to handle subl -w in tmux

1
brew install reattach-to-user-namespace

Add command to ~/.tmux.conf

1
echo "set-option -g default-command \"reattach-to-user-namespace -l bash\"" >> ~/.tmux.conf

Restart the tmux server

1
tmux kill-server