File path to clipboard in Emacs

前端 未结 7 939
闹比i
闹比i 2021-01-31 02:40

What is the most simple way to send current full file name with file path to clipboard?

What I am using now is messages buffer: I copy file name that appears there after

7条回答
  •  孤街浪徒
    2021-01-31 03:04

    In Emacs Prelude I use:

    (defun prelude-copy-file-name-to-clipboard ()
      "Copy the current buffer file name to the clipboard."
      (interactive)
      (let ((filename (if (equal major-mode 'dired-mode)
                          default-directory
                        (buffer-file-name))))
        (when filename
          (kill-new filename)
          (message "Copied buffer file name '%s' to the clipboard." filename))))
    

提交回复
热议问题