]> git.rmz.io Git - dotfiles.git/blobdiff - wezterm/wezterm.lua
wezterm: follow 'stm.[#!]NNN' links to gitlab website
[dotfiles.git] / wezterm / wezterm.lua
index a4627b1db1355b2fad42d912b159e0e615b395fc..a3483a6633e31aed7eacb44ca460ace9aef5534a 100644 (file)
@@ -17,4 +17,41 @@ config.tab_bar_at_bottom            = true
 
 config.quick_select_alphabet = "aoeuisnthd"
 
 
 config.quick_select_alphabet = "aoeuisnthd"
 
+config.keys = {
+  {
+    key = 'F',
+    mods = 'CTRL',
+    action = wezterm.action.QuickSelectArgs {
+      label = 'open url',
+      patterns = {
+        'https?://\\S+',
+        'stm\\.[#!]\\d+',
+      },
+      action = wezterm.action_callback(function (win, pane)
+        local url = win:get_selection_text_for_pane(pane)
+        wezterm.log_info('selected: ' .. url)
+        local found, _, proj, type, num = string.find(url, "^(stm)%.([#!])(%d+)$")
+        wezterm.log_info('selected: ' .. url)
+        if found ~= nil then
+          if     type == "#" then type = "issues"
+          elseif type == "!" then type = "merge_requests"
+          else   return
+          end
+          if     proj == "stm" then proj = "springfield"
+          else   proj = proj
+          end
+          url = string.format("https://gitlab.com/fppnt/sgnss/%s/-/%s/%d", proj, type, num)
+        end
+        wezterm.log_info('opening: ' .. url)
+        wezterm.open_with(url, "rifle")
+      end),
+    },
+  },
+  {
+    key = 'Enter',
+    mods = 'ALT',
+    action = wezterm.action.DisableDefaultAssignment,
+  },
+}
+
 return config
 return config