fix: Fixes typo in readme, strip quotes from output for all commands for consistency.
This commit is contained in:
@@ -7,7 +7,7 @@ dotfiles repo.
|
||||
|
||||
```lua
|
||||
vim.pack.add({
|
||||
{ src = "https://git.housh.dev/michael/shortenurl.nvm" },
|
||||
{ src = "https://git.housh.dev/michael/shortenurl.nvim" },
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
@@ -49,16 +49,24 @@ shortenurl.prompt = function(s)
|
||||
return cmd
|
||||
end
|
||||
|
||||
-- Run the command and return the short url as a string.
|
||||
local function runCmd(cmd)
|
||||
local output = trimNewline(vim.fn.system(cmd))
|
||||
if not output or output == "" then
|
||||
return
|
||||
end
|
||||
return trimQuotes(output)
|
||||
end
|
||||
|
||||
-- Convert url on the current line.
|
||||
shortenurl.convertUrl = function()
|
||||
local url = get_url()
|
||||
local cmd = shortenurl.prompt(url)
|
||||
local output = trimNewline(vim.fn.system(cmd))
|
||||
if output == "" then
|
||||
local output = runCmd(cmd)
|
||||
if not output or output == "" then
|
||||
print("Got empty output")
|
||||
return
|
||||
end
|
||||
output = trimQuotes(output)
|
||||
-- Replace occurence of the url with the shortened url.
|
||||
vim.cmd(":%s/" .. vim.fn.escape(url, "/") .. "/" .. vim.fn.escape(output, "/"))
|
||||
end
|
||||
@@ -67,7 +75,7 @@ end
|
||||
shortenurl.convertFromClipboard = function()
|
||||
local url = trimNewline(vim.fn.system("wl-paste"))
|
||||
local cmd = shortenurl.prompt(url)
|
||||
local output = trimNewline(vim.fn.system(cmd))
|
||||
local output = runCmd(cmd)
|
||||
if not output or output == "" then
|
||||
print("Got empty output")
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user