diff --git a/README.md b/README.md index 769b12b..47ad88d 100644 --- a/README.md +++ b/README.md @@ -92,25 +92,21 @@ The following applies to all commands above: subdirectory, creating any non-existing folders. ### File Utility Commands -- `.copyFilename` or `:CopyFilename`: Copy the file name. When -`clipboard="unnamed[plus]"` has been set, copies to the `+` register, otherwise -to `"`. -- `.copyFilepath` or `:CopyFilepath`: Copy the absolute file path. When -`clipboard="unnamed[plus]"` has been set, copies to the `+` register, otherwise -to `"`. -- `.copyRelativePath` or `:CopyRelativePath`: Copy the relative file path. When -`clipboard="unnamed[plus]"` has been set, copies to the `+` register, otherwise -to `"`. +- `.copyFilename` or `:CopyFilename`: Copy the file name. +- `.copyFilepath` or `:CopyFilepath`: Copy the absolute file path. +- `.copyFilepathWithTilde` or `:CopyFilepathWithTilde`: Copy the absolute file + path, replacing the home directory with `~`. +- `.copyRelativePath` or `:CopyRelativePath`: Copy the relative file path. - `.copyDirectoryPath` or `:CopyDirectoryPath`: Copy the absolute directory -path. When `clipboard="unnamed[plus]"` has been set, copies to the `+` register, -otherwise to `"`. +path. - `.copyRelativeDirectoryPath` or `:CopyRelativeDirectoryPath`: Copy the -relative directory path. When `clipboard="unnamed[plus]"` has been set, copies -to the `+` register, otherwise to `"`. +relative directory path. - `.chmodx` or `:Chmodx`: Makes current file executable. Equivalent to `chmod +x`. -To always use system clipboard put this in your configuration file: +When `clipboard="unnamed[plus]"` has been set, copies to the `+` register, +otherwise to `"`. To always use system clipboard, put this in your configuration +file: ```lua -- lua diff --git a/lua/genghis/init.lua b/lua/genghis/init.lua index 094a533..9c2584f 100644 --- a/lua/genghis/init.lua +++ b/lua/genghis/init.lua @@ -190,12 +190,15 @@ local function copyOp(expandOperation) vim.notify(toCopy, vim.log.levels.INFO, { title = "Copied" }) end --- DOCS for the available modifiers: https://neovim.io/doc/user/builtin.html#expand() +-- DOCS for the modifiers +-- https://neovim.io/doc/user/builtin.html#expand() +-- https://neovim.io/doc/user/cmdline.html#filename-modifiers function M.copyFilepath() copyOp("%:p") end +function M.copyFilepathWithTilde() copyOp("%:~") end function M.copyFilename() copyOp("%:t") end -function M.copyRelativePath() copyOp("%:~:.") end +function M.copyRelativePath() copyOp("%:.") end function M.copyDirectoryPath() copyOp("%:p:h") end -function M.copyRelativeDirectoryPath() copyOp("%:~:.:h") end +function M.copyRelativeDirectoryPath() copyOp("%:.:h") end -------------------------------------------------------------------------------- diff --git a/plugin/setup-commands.lua b/plugin/setup-commands.lua index a47dbbb..6a6d4dd 100644 --- a/plugin/setup-commands.lua +++ b/plugin/setup-commands.lua @@ -11,6 +11,7 @@ command("Move", function() genghis.moveAndRenameFile() end, {}) command("MoveToFolderInCwd", function() genghis.moveToFolderInCwd() end, {}) command("CopyFilename", function() genghis.copyFilename() end, {}) command("CopyFilepath", function() genghis.copyFilepath() end, {}) +command("copyFilepathWithTilde", function() genghis.copyFilepathWithTilde() end, {}) command("CopyRelativePath", function() genghis.copyRelativePath() end, {}) command("CopyDirectoryPath", function() genghis.copyDirectoryPath() end, {}) command("CopyRelativeDirectoryPath", function() genghis.copyRelativeDirectoryPath() end, {})