Copy/Paste between multiple command lines

Discussion in 'Command Line' started by Calin Tamaian, Oct 2, 2013.

  1. Calin Tamaian

    Calin Tamaian New Member

    Messages:
    1
    Likes Received:
    2
    Trophy Points:
    3
    Hello to everyone,

    I am relative new to Linux and I have 2 scenarios that i cannot figure out:

    .1. I have 2 window command lines open. I want to be able to execute command in one window and export the command history to the second window.

    Reason: sometimes I have to execute very long commands that need to be executed in parallel with a slightly different option. So far I used copy/paste from mouse. Is there any way to do it with only keyboard?

    .2. I have 2 scripts opened in 2 different command lines.I want to be able to copy paste between them without using mouse (I use vim editor). If I yank one line I can paste it in the same file but not in the other
    file, opened in the other window.


    Reason: sometimes I debug and I have 4-5 command windows opened and it would be helpful to edit "on-the-go" and not use mouse for copy/paste. I installed the Yankring plugin (vim) but for this purpose it doesn't help (or I haven't figured it out)

    If anyone has any idea please share.

    Thank you in advance!
    Calin
    DevynCJohnson and ryanvade like this.
  2. ryanvade

    ryanvade Administrator Staff Member Staff Writer

    Messages:
    1,128
    Likes Received:
    376
    Trophy Points:
    83
  3. KenJackson

    KenJackson Active Member

    Messages:
    129
    Likes Received:
    28
    Trophy Points:
    28
    Install the xclip package. I have this in my universal .bashrc file that I use on a wide variety of platforms:
    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
    This gives me commands getclip and putclip (which are native to Cygwin, so I check).

    Then if I type a long long line, I hit up arrow to retrieve it, CTRL-A to get to the start,
    add echo " in front of it, CTRL-E to move the cursor to the end, and add " | putclip at the end and execute again. And voila! It's in the clipboard for pasting.

Share This Page