From bbc0e67eebc15342e73b146a50d9b52e6148161b Mon Sep 17 00:00:00 2001 From: Kevin Traver Date: Mon, 3 Jun 2024 12:02:01 -0600 Subject: [PATCH] feat: add copy filename action (#391) --- doc/oil.txt | 3 +++ lua/oil/actions.lua | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/doc/oil.txt b/doc/oil.txt index 11043ff..056dc52 100644 --- a/doc/oil.txt +++ b/doc/oil.txt @@ -456,6 +456,9 @@ change_sort *actions.change_sor close *actions.close* Close oil and restore original buffer +copy_entry_filename *actions.copy_entry_filename* + Yank the filename of the entry under the cursor to a register + copy_entry_path *actions.copy_entry_path* Yank the filepath of the entry under the cursor to a register diff --git a/lua/oil/actions.lua b/lua/oil/actions.lua index 7b75505..887f793 100644 --- a/lua/oil/actions.lua +++ b/lua/oil/actions.lua @@ -268,6 +268,17 @@ M.copy_entry_path = { end, } +M.copy_entry_filename = { + desc = "Yank the filename of the entry under the cursor to a register", + callback = function() + local entry = oil.get_cursor_entry() + if not entry then + return + end + vim.fn.setreg(vim.v.register, entry.name) + end, +} + M.open_cmdline_dir = { desc = "Open vim cmdline with current directory as an argument", callback = function()