aboutsummaryrefslogtreecommitdiff
path: root/config.dot/luakit.link/keys.lua
diff options
context:
space:
mode:
Diffstat (limited to 'config.dot/luakit.link/keys.lua')
-rw-r--r--config.dot/luakit.link/keys.lua86
1 files changed, 86 insertions, 0 deletions
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 = '<a href="' .. uri .. '">' .. title .. '</a>'
+ 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},
+})