diff options
| author | Akshay Nair <phenax5@gmail.com> | 2025-04-12 10:09:22 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2025-04-12 10:09:22 +0530 |
| commit | 8c5e75578b063a4fb64dc7ecef4851a860d7674d (patch) | |
| tree | 0cc849cc6710a06a4ab1158913b3691a234d33d3 /config.lua | |
| parent | 762ac5a2bc8902fb22fa7005a136ed07c2e2cdfc (diff) | |
| download | null-browser-8c5e75578b063a4fb64dc7ecef4851a860d7674d.tar.gz null-browser-8c5e75578b063a4fb64dc7ecef4851a860d7674d.zip | |
Respect cli args for main instance
Diffstat (limited to 'config.lua')
| -rw-r--r-- | config.lua | 21 |
1 files changed, 14 insertions, 7 deletions
@@ -5,11 +5,6 @@ web = web --- @type table uv = uv -local function trim(s) - local res, _ = string.gsub(s, '^%s*(.-)%s*$', '%1') - return res -end - local function get_current_tab_index() local currentTab = web.tabs.current(); for index, tab in ipairs(web.tabs.list()) do @@ -29,18 +24,30 @@ web.event.add_listener('UrlChanged', { end }) +local function trim(s) + local res, _ = string.gsub(s, '^%s*(.-)%s*$', '%1') + return res +end + +local function to_url(url) + if string.match(url, "^https?://") then + return trim(url) + end + return "https://" .. trim(url) +end + -- Open in new tab web.keymap.set('n', 'o', function() dmenu.select(history.list(), { prompt = 'Open tab:' }, function(err, result) if err or not result then return end - web.tabs.new(trim(result)) + web.tabs.new(to_url(result)) end) end) -- Open in current tab web.keymap.set('n', '<s-o>', function() dmenu.select(history.list(), { prompt = 'Open:' }, function(err, result) if err or not result then return end - web.tabs.set_url(trim(result)) + web.tabs.set_url(to_url(result)) end) end) -- Delete from history |
