From 49c05a4f1b369675883d8037312a26ead4893a5c Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Thu, 21 Sep 2017 16:14:31 -0300 Subject: Major update compatible with current upstream --- config.dot/luakit.link/keys.lua | 86 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 config.dot/luakit.link/keys.lua (limited to 'config.dot/luakit.link/keys.lua') diff --git a/config.dot/luakit.link/keys.lua b/config.dot/luakit.link/keys.lua new file mode 100644 index 0000000..d1f16c7 --- /dev/null +++ b/config.dot/luakit.link/keys.lua @@ -0,0 +1,86 @@ +-- +-- Custom keybindings +-- + +-- Requirements +local modes = require "modes" +local window = require "window" + +-- Remove some default bindings +modes.remove_binds("normal", { "y" }) + +-- Add custom binds +modes.add_binds("normal", { + { "h", "New blank tab", function (w) + w:new_tab('luakit://newtab') + end}, +}) + +-- Add custom Yank bindings +modes.add_binds("normal", { + -- Yank URL + { "^yy$", function (w) + local uri = string.gsub(w.view.uri or "", " ", "%%20") + luakit.selection.primary = uri + luakit.selection.clipboard = uri + w:notify("Yanked uri: " .. uri) + end}, + + -- Yank title + { "^yt$", function (w) + local title = w.view.title + luakit.selection.primary = title + luakit.selection.clipboard = uri + w:notify("Yanked title: " .. title) + end}, + + -- Yank URL and title as a Markdown link + { "^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 as markdown link: " .. link) + end}, + + -- Yank URL and title as a reStructuredText link + { "^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 as reStructuredText link: " .. link) + end}, + + -- Yank URL and title as a Trac link + { "^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 as Trac link: " .. link) + end}, + + -- Yank URL and title as an HTML link + { "^yh$", function (w) + local title = w.view.title + local uri = string.gsub(w.view.uri or "", " ", "%%20") + local link = '' .. title .. '' + luakit.selection.primary = link + luakit.selection.clipboard = link + w:notify("Yanked as HTML link: " .. link) + end}, + + -- Yank URL and title as a shareable link + { "^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 as shareable link: " .. link) + end}, +}) -- cgit v1.2.3