Copy and paste with single command/key with tmux

Clash 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?
tmux
add a comment |Â
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?
tmux
add a comment |Â
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?
tmux
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?
tmux
asked Jan 24 at 8:15
Chris Steinbach
1063
1063
add a comment |Â
add a comment |Â
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.
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-Xwas 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
add a comment |Â
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.
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-Xwas 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
add a comment |Â
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.
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-Xwas 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
add a comment |Â
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.
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.
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-Xwas 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
add a comment |Â
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-Xwas 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
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password