2013-11-22 11:52:22 -07:00
|
|
|
REMOTE_CLIPBOARD_PORT='1234'
|
|
|
|
|
2014-10-28 03:48:51 -06:00
|
|
|
alias rc_ssh="ssh -R 1234:localhost:1234 "
|
2014-10-09 22:54:45 -06:00
|
|
|
|
2013-11-22 11:52:22 -07:00
|
|
|
function remote_clipboard_server() {
|
|
|
|
while [ 1 ]
|
|
|
|
do
|
2014-10-09 23:44:02 -06:00
|
|
|
ncat -l -p ${1-$REMOTE_CLIPBOARD_PORT} -e "pbcopy"
|
2013-11-22 11:52:22 -07:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
function remote_clipboard_server_daemon() {
|
|
|
|
daemonize `which reattach-to-user-namespace` -l $SHELL -c "source ~/.zshrc; remote_clipboard_server"
|
|
|
|
}
|
|
|
|
|
2014-10-09 22:54:45 -06:00
|
|
|
function _linux_nc_paste_to_remote_clipboard() {
|
2013-11-22 11:52:22 -07:00
|
|
|
nc localhost ${1-$REMOTE_CLIPBOARD_PORT} -q 0
|
|
|
|
}
|
|
|
|
|
2014-10-09 22:54:45 -06:00
|
|
|
function _osx_nc_paste_to_remote_clipboard() {
|
2014-10-09 23:44:02 -06:00
|
|
|
nc localhost ${1-$REMOTE_CLIPBOARD_PORT}
|
2013-11-22 11:52:22 -07:00
|
|
|
}
|
2014-04-14 00:19:14 -06:00
|
|
|
|
|
|
|
function remote_os_copy() {
|
|
|
|
if is_osx;
|
|
|
|
then
|
2014-10-09 22:54:45 -06:00
|
|
|
_osx_nc_paste_to_remote_clipboard
|
2014-10-08 05:03:32 -06:00
|
|
|
|
2014-04-14 00:19:14 -06:00
|
|
|
else
|
2014-10-08 05:03:32 -06:00
|
|
|
_linux_nc_write_remote_clipboard
|
2014-04-14 00:19:14 -06:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function smart_copy() {
|
|
|
|
if is_ssh;
|
|
|
|
then
|
|
|
|
remote_os_copy
|
|
|
|
else
|
2014-11-07 06:11:23 -07:00
|
|
|
oscopy
|
2014-04-14 00:19:14 -06:00
|
|
|
fi
|
|
|
|
}
|