Skip to content

Instantly share code, notes, and snippets.

@yuryu
Created July 5, 2012 11:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuryu/3053028 to your computer and use it in GitHub Desktop.
Save yuryu/3053028 to your computer and use it in GitHub Desktop.
Mac pbcopy helper
bufferfile "$HOME/screen-exchange"
bind ^] eval 'writebuf -e utf8' 'exec sh -c "cat ~/screen-exchange | ~/invoke-pbcopy.sh"' 'echo pasted.'
#!/bin/sh
function concat_passphrase()
{
echo 'SECRET-PASSPHRASE'
cat -
}
concat_passphrase | nc -w1 localhost 12345
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>localhost.pbcopy</string>
<key>ProgramArguments</key>
<array>
<string>/Users/yuryu/safe-pbcopy.rb</string>
</array>
<key>inetdCompatibility</key>
<dict>
<key>Wait</key>
<false/>
</dict>
<key>Sockets</key>
<dict>
<key>Listeners</key>
<dict>
<key>SockServiceName</key>
<string>12345</string>
<key>SockNodeName</key>
<string>127.0.0.1</string>
</dict>
</dict>
</dict>
</plist>
#!/usr/bin/ruby
SHARED_KEY = 'SECRET-PASSPHRASE';
key = gets
exit if key.chomp != SHARED_KEY
IO.popen('sh -c "LANG=en_us.UTF-8 pbcopy"', 'w') do |pb|
while line = gets
pb.puts line
end
end
Host *
RemoteForward 12345 localhost:12345
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment