From 9493e51b4d04f975a189749902e620e8ff2d29ae Mon Sep 17 00:00:00 2001 From: Sander Date: Sat, 30 Aug 2025 22:31:40 +0200 Subject: [PATCH 1/3] feat: do not store home directory in desktop entry when `git-dev-open` is installed in `~/.local/bin`, the `.desktop` file can reference the binary name directly. This avoids embedding user-specific home directory paths in dotfiles or repos --- lua/git-dev/xdg.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lua/git-dev/xdg.lua b/lua/git-dev/xdg.lua index aa61d9c..a19834f 100644 --- a/lua/git-dev/xdg.lua +++ b/lua/git-dev/xdg.lua @@ -40,11 +40,15 @@ end XDG.enable = function(opts) utils.overwrite_if_changed(opts.script.path, opts.script.content, utils.o700) + local script_path = vim.fn.expand(opts.script.path) local desktop_entry = { name = "GitDev", - exec = vim.fn.expand(opts.script.path) .. " %u", + exec = script_path .. " %u", mime_type = "x-scheme-handler/nvim-gitdev", } + if script_path == vim.fn.expand "~/.local/bin/git-dev-open" then + desktop_entry.exec = "git-dev-open %u" + end utils.overwrite_if_changed( opts.desktop_entry_path, From 15162e62f3a98a8db7db2d91740d551591d5cabf Mon Sep 17 00:00:00 2001 From: Sander Date: Sat, 30 Aug 2025 22:41:53 +0200 Subject: [PATCH 2/3] chore: do not hardcode script name --- lua/git-dev/xdg.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lua/git-dev/xdg.lua b/lua/git-dev/xdg.lua index a19834f..041bcca 100644 --- a/lua/git-dev/xdg.lua +++ b/lua/git-dev/xdg.lua @@ -46,8 +46,9 @@ XDG.enable = function(opts) exec = script_path .. " %u", mime_type = "x-scheme-handler/nvim-gitdev", } - if script_path == vim.fn.expand "~/.local/bin/git-dev-open" then - desktop_entry.exec = "git-dev-open %u" + local script_name = script_path:match "([^/]+)$" + if script_path == vim.fn.expand("~/.local/bin/" .. script_name) then + desktop_entry.exec = script_name .. " %u" end utils.overwrite_if_changed( From e1257f5ccd041dc1e30455833f4d234ca5c34588 Mon Sep 17 00:00:00 2001 From: Sander Date: Thu, 4 Sep 2025 17:38:40 +0200 Subject: [PATCH 3/3] chore: use binary name instead of full path when the binary is in $PATH --- lua/git-dev/xdg.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lua/git-dev/xdg.lua b/lua/git-dev/xdg.lua index 041bcca..5ab5408 100644 --- a/lua/git-dev/xdg.lua +++ b/lua/git-dev/xdg.lua @@ -40,16 +40,16 @@ end XDG.enable = function(opts) utils.overwrite_if_changed(opts.script.path, opts.script.content, utils.o700) + local script_path = vim.fn.expand(opts.script.path) + local binary_name = vim.fn.fnamemodify(script_path, ":t") + local exe_path = vim.fn.exepath(binary_name) + local desktop_entry = { name = "GitDev", - exec = script_path .. " %u", + exec = ((exe_path ~= "" and binary_name) or script_path) .. " %u", mime_type = "x-scheme-handler/nvim-gitdev", } - local script_name = script_path:match "([^/]+)$" - if script_path == vim.fn.expand("~/.local/bin/" .. script_name) then - desktop_entry.exec = script_name .. " %u" - end utils.overwrite_if_changed( opts.desktop_entry_path,