-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New layer: clipboard support on terminal for multiple systems #4662
Comments
👍 If you make a PR, i'm sure people would love you. |
The only stuff I can find about the terminal so far is stuff involving custom functions that call out to xclip or some other external plugin. This might be interesting to look at, though. The wiki seems mildly useful. And lastly, as further research, this answer which gives a nice useful hint as to how yanking behavior changes from emacs 24 to emacs 25 (notably that |
Possibly useful link: https://wiki.archlinux.org/index.php/emacs#Clipboard_support_for_emacs-nox |
Well, color my surprised. I have tried defining (unless window-system
(when (getenv "DISPLAY")
(defun xclip-cut-function (text &optional push)
(with-temp-buffer
(insert text)
(call-process-region (point-min) (point-max) "xclip" nil 0 nil "-i" "-selection" "clipboard")))
(defun xclip-paste-function()
(let ((xclip-output (shell-command-to-string "xclip -o -selection clipboard")))
(unless (string= (car kill-ring) xclip-output)
xclip-output )))
(setq interprogram-cut-function 'xclip-cut-function)
(setq interprogram-paste-function 'xclip-paste-function)
)) Looking forward to see other working configs in other SOs, to bundle them in a layer. |
#3064 may as well be included here (instead of in |
+1 |
I have some custom elisp code that does just this and would be happy to make a pull request to fix this. It works across remote machines using xsel, and also works gracefully inside tmux when reattaching from different machines. Where would be the appropriate place to put such code for custom spacemacs layer? |
I'm personally glad that you are willing to share that code :), many thanks. From what I know, You can use the This will create a all the needed file templates. For the layer structure, the read is: |
Thanks, I'll put a layer together. Which spacemacs/layers/ directory should this go under? |
The X clipboard allows a user to copy and paste content between different X windows, e.g. copying text from Chrome into a Terminal. Copy/pasting with the X clipboard it well supported in GUI Emacs, but not so well in terminal Emacs (i.e `emacs -nw` or `emacsclient -t`) without resorting to using the mouse, since terminal Emacs has no awareness of X. There are several incomplete Elisp solutions out that work for the most part, but may not have cross-platform support, or may fail over SSH with X forwarding or within a `tmux` session. This layer adds support for OSX, Linux, Windows, and Cygwin using the relevant binary on each system. For example on Linux, it uses `xsel` or `xclip` to interface with the clipboard, depending which one is available. It also adds support for ssh'ing into a different OS with X forwarding via `ssh -Y hostname`, and copy/pasting to and from a remote terminal Emacs. It also supports an edge case of continuing to work in an Emacs instance running inside a `tmux` session which may have been started by a different ssh session, which relies on explicitly reseting the `$DISPLAY` environment variable before calling the relevant binary. Yank code inspired by https://github.com/tmux-plugins/tmux-yank. Fix syl20bnr#4662.
Any updates on this? Looking forward to see it merged eventually. |
👍 I want convenient access to this too |
I've just updated the PR to resolve the comments. PTAL. |
This post on hacker news today is relevant to this topic. Maybe it will be useful for someone else here. |
The X clipboard allows a user to copy and paste content between different X windows, e.g. copying text from Chrome into a Terminal. Copy/pasting with the X clipboard it well supported in GUI Emacs, but not so well in terminal Emacs (i.e `emacs -nw` or `emacsclient -t`) without resorting to using the mouse, since terminal Emacs has no awareness of X. There are several incomplete Elisp solutions out that work for the most part, but may not have cross-platform support, or may fail over SSH with X forwarding or within a `tmux` session. This layer adds support for OSX, Linux, Windows, and Cygwin using the relevant binary on each system. For example on Linux, it uses `xsel` or `xclip` to interface with the clipboard, depending which one is available. It also adds support for ssh'ing into a different OS with X forwarding via `ssh -Y hostname`, and copy/pasting to and from a remote terminal Emacs. It also supports an edge case of continuing to work in an Emacs instance running inside a `tmux` session which may have been started by a different ssh session, which relies on explicitly reseting the `$DISPLAY` environment variable before calling the relevant binary. Yank code inspired by https://github.com/tmux-plugins/tmux-yank. Fix #4662. Tried to add xclip support but removed it since it freezes.
Oops wrongly closed it. |
The X clipboard allows a user to copy and paste content between different X windows, e.g. copying text from Chrome into a Terminal. Copy/pasting with the X clipboard it well supported in GUI Emacs, but not so well in terminal Emacs (i.e `emacs -nw` or `emacsclient -t`) without resorting to using the mouse, since terminal Emacs has no awareness of X. There are several incomplete Elisp solutions out that work for the most part, but may not have cross-platform support, or may fail over SSH with X forwarding or within a `tmux` session. This layer adds support for OSX, Linux, Windows, and Cygwin using the relevant binary on each system. For example on Linux, it uses `xsel` or `xclip` to interface with the clipboard, depending which one is available. It also adds support for ssh'ing into a different OS with X forwarding via `ssh -Y hostname`, and copy/pasting to and from a remote terminal Emacs. It also supports an edge case of continuing to work in an Emacs instance running inside a `tmux` session which may have been started by a different ssh session, which relies on explicitly reseting the `$DISPLAY` environment variable before calling the relevant binary. Yank code inspired by https://github.com/tmux-plugins/tmux-yank. Fix syl20bnr#4662. Tried to add xclip support but removed it since it freezes.
@syl20bnr: My pleasure. Thank you for your review. |
The X clipboard allows a user to copy and paste content between different X windows, e.g. copying text from Chrome into a Terminal. Copy/pasting with the X clipboard it well supported in GUI Emacs, but not so well in terminal Emacs (i.e `emacs -nw` or `emacsclient -t`) without resorting to using the mouse, since terminal Emacs has no awareness of X. There are several incomplete Elisp solutions out that work for the most part, but may not have cross-platform support, or may fail over SSH with X forwarding or within a `tmux` session. This layer adds support for OSX, Linux, Windows, and Cygwin using the relevant binary on each system. For example on Linux, it uses `xsel` or `xclip` to interface with the clipboard, depending which one is available. It also adds support for ssh'ing into a different OS with X forwarding via `ssh -Y hostname`, and copy/pasting to and from a remote terminal Emacs. It also supports an edge case of continuing to work in an Emacs instance running inside a `tmux` session which may have been started by a different ssh session, which relies on explicitly reseting the `$DISPLAY` environment variable before calling the relevant binary. Yank code inspired by https://github.com/tmux-plugins/tmux-yank. Fix syl20bnr#4662. Tried to add xclip support but removed it since it freezes.
Any way to make this work on macOS? I have |
@syl20bnr https://github.com/joddie/osx-clipboard-mode works great. I think it should be added to the osx layer. |
I think the correct OS X commands to use instead of Edit: just my 2 cents, in the spirit of code deduplication. I don't actually use OS X, so I don't really care that much. |
The mode makes copy-paste just wor. Using those commands is very
cumbersome. The mode is just a wrapper around them anyways.
…On Tue, Sep 11, 2018 at 4:18 AM Moritz Wilhelmy ***@***.***> wrote:
I think the correct OS X commands to use instead of xclip (which is X11
specific) are pbcopy and pbpaste, there's no need for a separate mode.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4662 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/Aii--gglGIXGzBMvkl4yasG1goz_6Pgtks5uZuqOgaJpZM4HG7hj>
.
|
The X clipboard allows a user to copy and paste content between different X windows, e.g. copying text from Chrome into a Terminal. Copy/pasting with the X clipboard it well supported in GUI Emacs, but not so well in terminal Emacs (i.e `emacs -nw` or `emacsclient -t`) without resorting to using the mouse, since terminal Emacs has no awareness of X. There are several incomplete Elisp solutions out that work for the most part, but may not have cross-platform support, or may fail over SSH with X forwarding or within a `tmux` session. This layer adds support for OSX, Linux, Windows, and Cygwin using the relevant binary on each system. For example on Linux, it uses `xsel` or `xclip` to interface with the clipboard, depending which one is available. It also adds support for ssh'ing into a different OS with X forwarding via `ssh -Y hostname`, and copy/pasting to and from a remote terminal Emacs. It also supports an edge case of continuing to work in an Emacs instance running inside a `tmux` session which may have been started by a different ssh session, which relies on explicitly reseting the `$DISPLAY` environment variable before calling the relevant binary. Yank code inspired by https://github.com/tmux-plugins/tmux-yank. Fix syl20bnr#4662. Tried to add xclip support but removed it since it freezes.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid! |
Is it possible to have this layer support cygwin terminal like https://github.com/ArthurTu/cygwin-terminal-clipboard |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid! |
Right now, there doesn't seem to be clipboard support with spacemacs TUI on Linux, and from the gitter chat I get that it doesn't work on other systems too.
Maybe is a good idea to gather here together the relevant configs to make a layer with them, with some layer docs on external dependencies.
The text was updated successfully, but these errors were encountered: