Copy and paste with single command/key with tmux

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












I really like the tmux-copycat plugin for selecting filenames in the terminal buffer, but one thing that would make it even better is the ability to copy and paste the selected text with one command (preferably bound to a key).



I'm not aware of any existing command to do this, so I imagine some trickery is needed. Any tips on where to get started on a solution?







share|improve this question
























    up vote
    1
    down vote

    favorite












    I really like the tmux-copycat plugin for selecting filenames in the terminal buffer, but one thing that would make it even better is the ability to copy and paste the selected text with one command (preferably bound to a key).



    I'm not aware of any existing command to do this, so I imagine some trickery is needed. Any tips on where to get started on a solution?







    share|improve this question






















      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I really like the tmux-copycat plugin for selecting filenames in the terminal buffer, but one thing that would make it even better is the ability to copy and paste the selected text with one command (preferably bound to a key).



      I'm not aware of any existing command to do this, so I imagine some trickery is needed. Any tips on where to get started on a solution?







      share|improve this question












      I really like the tmux-copycat plugin for selecting filenames in the terminal buffer, but one thing that would make it even better is the ability to copy and paste the selected text with one command (preferably bound to a key).



      I'm not aware of any existing command to do this, so I imagine some trickery is needed. Any tips on where to get started on a solution?









      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 24 at 8:15









      Chris Steinbach

      1063




      1063




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote













          There is a pair of tmux commands that will do what you want. You'll want to bind them to a new shortcut (probably a prefix-key-command).



          Let's say you are currently in copy mode and you've selected some text. Go to the command line (usually with prefix-:) and enter:



          send-keys -X copy-selection-and-cancel ; paste-buffer 


          That will do exactly what it says: put the selection in a paste buffer, cancel copy mode, and paste the paste-buffer contents to the shell command line (or wherever you were when you entered copy-mode).



          So now you can bind those commands to key of your choosing with something like this in your tmux.conf file



          bind-key X send-keys -X copy-selection-and-cancel ; paste-buffer 


          The only difference between this and running it directly is the need to escape the ;. Hit that bound key next time you've selected some text in copy-mode and you've got your all-in-one copy-and-paste shortcut.



          You might want to tune this a bit. For instance, you can use the -t target-page option to paste-buffer to paste to somewhere other than the current pane. Look at docs for the two commands in the tmux man page for ideas.






          share|improve this answer




















          • Looks good, although I'm running an older (and somewhat customized) build of tmux that doesn't support the -X option. No doubt I'll award you the answer once I've managed to update and test.
            – Chris Steinbach
            Jan 29 at 7:15










          • @ChrisSteinbach Sure. I'm not sure what version -X was added but it's been a while...since at least March 2013. If you can do so upgrading will be well worth it (features, stability, bug fixes).
            – B Layer
            Jan 29 at 11:42










          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );








           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f419277%2fcopy-and-paste-with-single-command-key-with-tmux%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          1
          down vote













          There is a pair of tmux commands that will do what you want. You'll want to bind them to a new shortcut (probably a prefix-key-command).



          Let's say you are currently in copy mode and you've selected some text. Go to the command line (usually with prefix-:) and enter:



          send-keys -X copy-selection-and-cancel ; paste-buffer 


          That will do exactly what it says: put the selection in a paste buffer, cancel copy mode, and paste the paste-buffer contents to the shell command line (or wherever you were when you entered copy-mode).



          So now you can bind those commands to key of your choosing with something like this in your tmux.conf file



          bind-key X send-keys -X copy-selection-and-cancel ; paste-buffer 


          The only difference between this and running it directly is the need to escape the ;. Hit that bound key next time you've selected some text in copy-mode and you've got your all-in-one copy-and-paste shortcut.



          You might want to tune this a bit. For instance, you can use the -t target-page option to paste-buffer to paste to somewhere other than the current pane. Look at docs for the two commands in the tmux man page for ideas.






          share|improve this answer




















          • Looks good, although I'm running an older (and somewhat customized) build of tmux that doesn't support the -X option. No doubt I'll award you the answer once I've managed to update and test.
            – Chris Steinbach
            Jan 29 at 7:15










          • @ChrisSteinbach Sure. I'm not sure what version -X was added but it's been a while...since at least March 2013. If you can do so upgrading will be well worth it (features, stability, bug fixes).
            – B Layer
            Jan 29 at 11:42














          up vote
          1
          down vote













          There is a pair of tmux commands that will do what you want. You'll want to bind them to a new shortcut (probably a prefix-key-command).



          Let's say you are currently in copy mode and you've selected some text. Go to the command line (usually with prefix-:) and enter:



          send-keys -X copy-selection-and-cancel ; paste-buffer 


          That will do exactly what it says: put the selection in a paste buffer, cancel copy mode, and paste the paste-buffer contents to the shell command line (or wherever you were when you entered copy-mode).



          So now you can bind those commands to key of your choosing with something like this in your tmux.conf file



          bind-key X send-keys -X copy-selection-and-cancel ; paste-buffer 


          The only difference between this and running it directly is the need to escape the ;. Hit that bound key next time you've selected some text in copy-mode and you've got your all-in-one copy-and-paste shortcut.



          You might want to tune this a bit. For instance, you can use the -t target-page option to paste-buffer to paste to somewhere other than the current pane. Look at docs for the two commands in the tmux man page for ideas.






          share|improve this answer




















          • Looks good, although I'm running an older (and somewhat customized) build of tmux that doesn't support the -X option. No doubt I'll award you the answer once I've managed to update and test.
            – Chris Steinbach
            Jan 29 at 7:15










          • @ChrisSteinbach Sure. I'm not sure what version -X was added but it's been a while...since at least March 2013. If you can do so upgrading will be well worth it (features, stability, bug fixes).
            – B Layer
            Jan 29 at 11:42












          up vote
          1
          down vote










          up vote
          1
          down vote









          There is a pair of tmux commands that will do what you want. You'll want to bind them to a new shortcut (probably a prefix-key-command).



          Let's say you are currently in copy mode and you've selected some text. Go to the command line (usually with prefix-:) and enter:



          send-keys -X copy-selection-and-cancel ; paste-buffer 


          That will do exactly what it says: put the selection in a paste buffer, cancel copy mode, and paste the paste-buffer contents to the shell command line (or wherever you were when you entered copy-mode).



          So now you can bind those commands to key of your choosing with something like this in your tmux.conf file



          bind-key X send-keys -X copy-selection-and-cancel ; paste-buffer 


          The only difference between this and running it directly is the need to escape the ;. Hit that bound key next time you've selected some text in copy-mode and you've got your all-in-one copy-and-paste shortcut.



          You might want to tune this a bit. For instance, you can use the -t target-page option to paste-buffer to paste to somewhere other than the current pane. Look at docs for the two commands in the tmux man page for ideas.






          share|improve this answer












          There is a pair of tmux commands that will do what you want. You'll want to bind them to a new shortcut (probably a prefix-key-command).



          Let's say you are currently in copy mode and you've selected some text. Go to the command line (usually with prefix-:) and enter:



          send-keys -X copy-selection-and-cancel ; paste-buffer 


          That will do exactly what it says: put the selection in a paste buffer, cancel copy mode, and paste the paste-buffer contents to the shell command line (or wherever you were when you entered copy-mode).



          So now you can bind those commands to key of your choosing with something like this in your tmux.conf file



          bind-key X send-keys -X copy-selection-and-cancel ; paste-buffer 


          The only difference between this and running it directly is the need to escape the ;. Hit that bound key next time you've selected some text in copy-mode and you've got your all-in-one copy-and-paste shortcut.



          You might want to tune this a bit. For instance, you can use the -t target-page option to paste-buffer to paste to somewhere other than the current pane. Look at docs for the two commands in the tmux man page for ideas.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 24 at 9:42









          B Layer

          3,8991525




          3,8991525











          • Looks good, although I'm running an older (and somewhat customized) build of tmux that doesn't support the -X option. No doubt I'll award you the answer once I've managed to update and test.
            – Chris Steinbach
            Jan 29 at 7:15










          • @ChrisSteinbach Sure. I'm not sure what version -X was added but it's been a while...since at least March 2013. If you can do so upgrading will be well worth it (features, stability, bug fixes).
            – B Layer
            Jan 29 at 11:42
















          • Looks good, although I'm running an older (and somewhat customized) build of tmux that doesn't support the -X option. No doubt I'll award you the answer once I've managed to update and test.
            – Chris Steinbach
            Jan 29 at 7:15










          • @ChrisSteinbach Sure. I'm not sure what version -X was added but it's been a while...since at least March 2013. If you can do so upgrading will be well worth it (features, stability, bug fixes).
            – B Layer
            Jan 29 at 11:42















          Looks good, although I'm running an older (and somewhat customized) build of tmux that doesn't support the -X option. No doubt I'll award you the answer once I've managed to update and test.
          – Chris Steinbach
          Jan 29 at 7:15




          Looks good, although I'm running an older (and somewhat customized) build of tmux that doesn't support the -X option. No doubt I'll award you the answer once I've managed to update and test.
          – Chris Steinbach
          Jan 29 at 7:15












          @ChrisSteinbach Sure. I'm not sure what version -X was added but it's been a while...since at least March 2013. If you can do so upgrading will be well worth it (features, stability, bug fixes).
          – B Layer
          Jan 29 at 11:42




          @ChrisSteinbach Sure. I'm not sure what version -X was added but it's been a while...since at least March 2013. If you can do so upgrading will be well worth it (features, stability, bug fixes).
          – B Layer
          Jan 29 at 11:42












           

          draft saved


          draft discarded


























           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f419277%2fcopy-and-paste-with-single-command-key-with-tmux%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          Peggy Mitchell

          Palaiologos

          The Forum (Inglewood, California)