]> gitweb.fluxo.info Git - rhatto/dotfiles/luakit.git/commitdiff
More yanking
authorSilvio Rhatto <rhatto@riseup.net>
Mon, 18 Sep 2017 22:55:13 +0000 (19:55 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Tue, 19 Sep 2017 11:18:18 +0000 (08:18 -0300)
config.dot/luakit.link/binds.lua

index 4ec70ec34559489cd58dbd1669ba590f3db2876d..b2b10d4d7b59abbe065e61e89839d88e744ea123 100644 (file)
@@ -186,6 +186,56 @@ add_binds("normal", {
                                         w:notify("Yanked title: " .. title)
                                     end),
 
+    -- Yank URL and title as a Markdown link
+    buf("^ym$",                     function (w)
+                                        local title = w.view.title
+                                        local uri   = string.gsub(w.view.uri or "", " ", "%%20")
+                                        local link  = '[' .. title .. '](' .. uri .. ')'
+                                        luakit.selection.primary = link
+                                        luakit.selection.clipboard = link
+                                        w:notify("Yanked link: " .. link)
+                                    end),
+
+    -- Yank URL and title as a reStructuredText link
+    buf("^yr$",                     function (w)
+                                        local title = w.view.title
+                                        local uri   = string.gsub(w.view.uri or "", " ", "%%20")
+                                        local link  = '`' .. title .. '` <' .. uri .. '>`_'
+                                        luakit.selection.primary = link
+                                        luakit.selection.clipboard = link
+                                        w:notify("Yanked link: " .. link)
+                                    end),
+
+    -- Yank URL and title as a Trac link
+    buf("^yc$",                     function (w)
+                                        local title = w.view.title
+                                        local uri   = string.gsub(w.view.uri or "", " ", "%%20")
+                                        local link  = '[' .. uri .. ' ' .. title .. ']'
+                                        luakit.selection.primary = link
+                                        luakit.selection.clipboard = link
+                                        w:notify("Yanked link: " .. link)
+                                    end),
+
+    -- Yank URL and title as an HTML link
+    buf("^yh$",                     function (w)
+                                        local title = w.view.title
+                                        local uri   = string.gsub(w.view.uri or "", " ", "%%20")
+                                        local link  = '<a href="' .. uri .. '">' .. title .. '</a>'
+                                        luakit.selection.primary = link
+                                        luakit.selection.clipboard = link
+                                        w:notify("Yanked link: " .. link)
+                                    end),
+
+    -- Yank URL and title as a shareable link
+    buf("^ys$",                     function (w)
+                                        local title = w.view.title
+                                        local uri   = string.gsub(w.view.uri or "", " ", "%%20")
+                                        local link  = title .. ' - ' .. uri
+                                        luakit.selection.primary = link
+                                        luakit.selection.clipboard = link
+                                        w:notify("Yanked link: " .. link)
+                                    end),
+
     -- Commands
     key({"Control"}, "a",           function (w)    w:navigate(w:inc_uri(1)) end),
     key({"Control"}, "x",           function (w)    w:navigate(w:inc_uri(-1)) end),