commit
b440657495
3 changed files with 23 additions and 3 deletions
11
lua/telescope/_extensions/getOS.lua
Normal file
11
lua/telescope/_extensions/getOS.lua
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
return function()
|
||||
-- ask LuaJIT first
|
||||
-- will return "Windows", "Linux", "OSX", "BSD", "POSIX" or "Other"
|
||||
if jit then return jit.os end
|
||||
|
||||
-- Unix, Linux variants
|
||||
local fh, _ = assert(io.popen('uname -o 2>/dev/null', 'r'))
|
||||
if fh then return fh:read() end
|
||||
|
||||
return 'Windows'
|
||||
end
|
||||
|
|
@ -5,8 +5,15 @@ if not ok then
|
|||
end
|
||||
|
||||
local list = require 'telescope._extensions.http.list'
|
||||
local osname = require 'telescope._extensions.getOS'
|
||||
|
||||
local default_opts = { open_url = 'xdg-open %s' }
|
||||
local open_url_os = {
|
||||
['OSX'] = { open_url = 'open %s' },
|
||||
['Windows'] = { open_url = 'start %s' },
|
||||
}
|
||||
|
||||
local default_opts = open_url_os[osname()]
|
||||
if not default_opts then default_opts = { open_url = 'xdg-open %s' } end
|
||||
local opts = {}
|
||||
|
||||
return telescope.register_extension {
|
||||
|
|
|
|||
|
|
@ -31,8 +31,10 @@ require('telescope').load_extension 'http'
|
|||
require('telescope').setup {
|
||||
extensions = {
|
||||
http = {
|
||||
-- How the mozilla url is opened. By default:
|
||||
open_url = 'xdg-open %s'
|
||||
-- How the mozilla url is opened. By default will be configured based on OS:
|
||||
open_url = 'xdg-open %s' -- UNIX
|
||||
-- open_url = 'open %s' -- OSX
|
||||
-- open_url = 'start %s' -- Windows
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue