feat: `:CopyFilepathWithTilde` (#34)

remotes/origin/HEAD
Chris Grieser 2024-02-10 20:41:47 +01:00
parent b045df8264
commit d057d47164
3 changed files with 17 additions and 17 deletions

View File

@ -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

View File

@ -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
--------------------------------------------------------------------------------

View File

@ -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, {})