Add SPC f y n and SPC f y N to copy the name of a file

This commit is contained in:
syl20bnr 2018-09-11 14:55:00 -04:00
parent ba93316939
commit 9f8b867af1
3 changed files with 19 additions and 0 deletions

View File

@ -2395,6 +2395,8 @@ Files manipulation commands (start with ~f~):
| ~SPC f y c~ | show and copy current file absolute path with line and column number in the minibuffer |
| ~SPC f y d~ | show and copy current directory absolute path in the minibuffer |
| ~SPC f y l~ | show and copy current file absolute path with line number in the minibuffer |
| ~SPC f y n~ | show and copy current file name with extensionin the minibuffer |
| ~SPC f y N~ | show and copy current file name without extensionin the minibuffer |
| ~SPC f y y~ | show and copy current file absolute path in the minibuffer |
**** Frame manipulation key bindings

View File

@ -565,6 +565,21 @@ ones created by `magit' and `dired'."
(message "%s" (kill-new file-path))
(message "WARNING: Current buffer is not attached to a file!")))
(defun spacemacs/copy-file-name ()
"Copy and show the file name of the current buffer."
(interactive)
(if-let (file-name (file-name-nondirectory (spacemacs--file-path)))
(message "%s" (kill-new file-name))
(message "WARNING: Current buffer is not attached to a file!")))
(defun spacemacs/copy-file-name-base ()
"Copy and show the file name without its final extension of the current
buffer."
(interactive)
(if-let (file-name (file-name-base (spacemacs--file-path)))
(message "%s" (kill-new file-name))
(message "WARNING: Current buffer is not attached to a file!")))
(defun spacemacs/copy-file-path-with-line ()
"Copy and show the file path of the current buffer, including line number."
(interactive)

View File

@ -228,6 +228,8 @@
"fyc" 'spacemacs/copy-file-path-with-line-column
"fyd" 'spacemacs/copy-directory-path
"fyl" 'spacemacs/copy-file-path-with-line
"fyn" 'spacemacs/copy-file-name
"fyN" 'spacemacs/copy-file-name-base
"fyy" 'spacemacs/copy-file-path)
;; frame ----------------------------------------------------------------------
(spacemacs/set-leader-keys