diff --git a/dotfiles/lib/shellrc/aliases.sh b/dotfiles/lib/shellrc/aliases.sh index f5c0c21b..37e2b09c 100644 --- a/dotfiles/lib/shellrc/aliases.sh +++ b/dotfiles/lib/shellrc/aliases.sh @@ -1,6 +1,5 @@ alias emacs="emacsclient -t" alias tmux="tmux -2" -alias remote_os_copy='linux_nc_paste_to_remote_clipboard' alias tmux_cb_to_remote_cb='tmux saveb - | linux_nc_paste_to_remote_clipboard' alias timestamp='date +%s' alias go2dotfiles='cd $(dirname `readlink -f ~/.zshrc | xargs dirname`)' diff --git a/dotfiles/lib/shellrc/functions.sh b/dotfiles/lib/shellrc/functions.sh index 66221109..867ebcea 100644 --- a/dotfiles/lib/shellrc/functions.sh +++ b/dotfiles/lib/shellrc/functions.sh @@ -87,9 +87,23 @@ function shell_stats() { } function is_ssh() { - p=${1:-$PPID} - read pid name ppid < <(ps -o pid= -o comm= -o ppid= -p $p) - [[ "$name" =~ sshd ]] && { echo "Is SSH : $pid $name"; return 0; } - [ "$ppid" -le 1 ] && { echo "Adam is $pid $name"; return 1; } - is_ssh $ppid + test $SSH_CLIENT +} + +function is_osx() { + case `uname` in + 'Darwin') + return 0 + ;; + *) + return 1; + ;; + esac +} + +function clipboard() { + if is_osx; + then + pbcopy + fi } diff --git a/dotfiles/lib/shellrc/remote_clipboard.sh b/dotfiles/lib/shellrc/remote_clipboard.sh index 5be40dd2..55814664 100644 --- a/dotfiles/lib/shellrc/remote_clipboard.sh +++ b/dotfiles/lib/shellrc/remote_clipboard.sh @@ -18,3 +18,21 @@ function linux_nc_paste_to_remote_clipboard() { function osx_nc_paste_to_remote_clipboard() { nc localhost ${1-$REMOTE_CLIPBOARD_PORT} -D } + +function remote_os_copy() { + if is_osx; + then + osx_nc_paste_to_remote_clipboard + else + linux_nc_paste_to_remote_clipboard + fi +} + +function smart_copy() { + if is_ssh; + then + remote_os_copy + else + clipboard + fi +}