I enjoy my "putclip" and "getclip" aliases

Discussion in 'Command Line' started by KenJackson, May 26, 2012.

  1. KenJackson

    KenJackson Active Member

    Messages:
    129
    Likes Received:
    28
    Trophy Points:
    28
    Thought I'd share something I find useful.

    Linux has the command-line xclip command, which I find to be much less intuitive that Cygwin's getclip and putclip commands. So I put this in universal ~/.bashrc file which I copy to every machine I use:
    Code:
    if [ -n "$(type -P xclip)" ]; then
        test -z "$(type -P putclip)"  && \
            alias putclip="$(type -P xclip) -sel clip -i"
        test -z "$(type -P getclip)"  && \
            alias getclip="$(type -P xclip) -sel clip -o"
        alias xclip='xclip -sel clip'
    fi
    It first checks to see if xclip exists (as a file, not alias/function), then checks to see if putclip and getclip files are missing. If those test pass, it creates aliases.

    I find these very helpful, since I tend to work primarily in bash shells. As one example, If I happen to check my mail and cat a message to the shell that has an interesting URL, I might do something like this:
    Code:
    <some_mailx_command> | grep -o 'http.*x.html' | putclip
    Then I press ALT-TAB until Firefox is in front, CTRL-T to open a new tab, CTRL-V to paste it in and ENTER to see the page.

    That works even when I've SSH'ed into a remote Linux server from either Linux or Cygwin.

    Fun stuff! :D

    bashcommando and DevynCJohnson like this.

Share This Page