最新消息:

spacemacs: 不能粘贴到系统粘贴板clipboard

未分类 niuge678 716浏览 0评论

现象

1、yank后,在sublime或者Alfred里 cmd+v,粘贴不上。

解决

参考:https://github.com/syl20bnr/spacemacs/issues/2222

把下面这段代码,粘贴到.spacemacs最后面,用space+o+y就可以凑合用了。

(cond
 ;; OS X
 ((string-equal system-type "darwin") ; Mac OS X
  (progn
    (setq save-to-clipboard-cmd "pbcopy")
    (setq paste-from-clipboard-cmd "pbpaste")
    )
  )
 ;; Linux
 ((string-equal system-type "gnu/linux") ; linux
  (progn
    (setq save-to-clipboard-cmd "xsel -i -b")
    (setq paste-from-clipboard-cmd "xsel -o -b")
    )
  )
 )

(defun copy-to-clipboard ()
  "Copies selection to x-clipboard."
  (interactive)
  (if (display-graphic-p)
      (progn
        (message "Yanked region to x-clipboard!")
        (call-interactively 'clipboard-kill-ring-save)
        )
    (if (region-active-p)
        (progn
          (shell-command-on-region (region-beginning) (region-end) save-to-clipboard-cmd)
          (message "Yanked region to clipboard!")
          (deactivate-mark))
      (message "No region active; can't yank to clipboard!")))
  )

(defun paste-from-clipboard ()
  "Pastes from x-clipboard."
  (interactive)
  (if (display-graphic-p)
      (progn
        (clipboard-yank)
        (message "graphics active")
        )
    (insert (shell-command-to-string paste-from-clipboard-cmd))
    )
  )
(evil-leader/set-key "o y" 'copy-to-clipboard)
(evil-leader/set-key "o p" 'paste-from-clipboard)

转载请注明:牛哥678 » spacemacs: 不能粘贴到系统粘贴板clipboard

与本文相关的文章

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址