Sometimes it's useful to get the current directory of the buffer that you are currently editing. For me, it's usually when I edit a file, and I want to go to that directory in a shell buffer.
I solve this problem using the following function:
(defun em-copy-path-of-buffer ()
(interactive)
(kill-new default-directory)
(message "Copied '%s'" default-directory))
By calling this function (either by using
M-x em-copy-path-to-buffer or by binding it to a key) the path is copied to the kill ring, and I can paste it using C-y into the shell buffer.
No comments:
Post a Comment