From e33c0ee81fba0b333e93fd86adf7f71163ae0bd1 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Fri, 30 Nov 2012 04:02:12 +0900 Subject: [PATCH] fix setclip using exec --- bashrc | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/bashrc b/bashrc index e6b715e..33e1a67 100755 --- a/bashrc +++ b/bashrc @@ -450,30 +450,25 @@ catclip(){ } setclip(){ + if test $# -eq 0 + then + exec 3<&0 + else + exec 3<<__EOF__ +`cat "$@"` +__EOF__ + fi if iswindows then - if test $# -eq 0 - then - sed -e 's/$/\r/' | tee /dev/clipboard - else - cat "$@" | sed -e 's/$/\r/' | tee /dev/clipboard - fi + 0<&3 sed -e 's/$/\r/' | tee /dev/clipboard elif isdarwin then - if test $# -eq 0 - then - pbcopy - else - cat "$@" | pbcopy - fi + pbcopy 0<&3 else - if test $# -eq 0 - then - xclip -i -f -selection "primary" | xclip -i -f -selection "clipboard" - else - cat "$@" | xclip -i -f -selection "primary" | xclip -i -f -selection "clipboard" - fi + 0<&3 xclip -i -f -selection "primary" | \ + xclip -i -f -selection "clipboard" fi + exec 3<&- } open_file(){