Written by Sean Behan on Sun Jun 17th 2012

Using the system clipboard with tmux on OS X is broken. I really like tmux but having copy and paste is kind of important for me. Here is my attempt to get it back with a simple bash script until I find something better. The approach is to take a named pipe and feed it the contents of "tmux showb". A bash script will manage the pipe and because this script is initialized from a normal session it will write to the system clipboard just fine.

In my .bash_profile...

pipe4tmux=/tmp/pipe4tmux
alias tcp="tmux showb > $pipe4tmux"
if [[ ! -p $pipe4tmux ]]; then
~/pipe4tmux.sh &
fi

And in pipe4tmux.sh...

#!/bin/bash
pipe4tmux=/tmp/pipe4tmux
echo "Starting named pipe $pipe4tmux"
trap "rm -f $pipe4tmux" EXIT

if [[ ! -p $pipe4tmux ]]; then
    mkfifo $pipe4tmux
fi

while true
do
    pbcopy < $pipe4tmux
done

echo "Quitting pipe4tmux $pip4tmux"

Tagged with..
#bash #configuration #development environment #named pipe #pipes #tmux #bash #environment #Linux

Just finishing up brewing up some fresh ground comments...