Skip to content

Commit

Permalink
fix: update cross-platform system open commands
Browse files Browse the repository at this point in the history
  • Loading branch information
ttytm committed Sep 19, 2024
1 parent c26cbe3 commit 27eee1e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions lua/nxvim/keymaps.lua
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,10 @@ nx.map({
{ "<leader>fW", "<Cmd>w !sudo -A tee > /dev/null %<CR>", desc = "Write!" },
{
"<leader>fo",
jit.os == "OSX" and "<Cmd>silent execute '!open ' . '%:p:h'<CR>"
or "<Cmd>silent execute '!xdg-open ' . '%:p:h'<CR>",
function()
local cmd = jit.os == "OSX" and "open " or "xdg-open "
vim.fn.system(cmd .. vim.fn.expand("%"))
end,
desc = "Open File with System App",
wk_label = "System Open",
},
Expand Down
3 changes: 2 additions & 1 deletion lua/nxvim/plugins/neo-tree.lua
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ local config = {
commands = {
system_open = function(state)
local node = state.tree:get_node()
vim.cmd("silent execute '!xdg-open \"" .. node.path .. "\"'")
local cmd = jit.os == "OSX" and "open " or "xdg-open "
vim.fn.system(cmd .. node.path)
end,
-- Overwrite default `delete` commands to use trash instead of rm
delete = function(state)
Expand Down

0 comments on commit 27eee1e

Please sign in to comment.