Skip to content

Commit 1084d79

Browse files
authored
feat(xdg): do not store home directory in desktop entry (#32)
* 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 * chore: do not hardcode script name * chore: use binary name instead of full path when the binary is in $PATH
1 parent f889434 commit 1084d79

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

lua/git-dev/xdg.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,14 @@ end
4040

4141
XDG.enable = function(opts)
4242
utils.overwrite_if_changed(opts.script.path, opts.script.content, utils.o700)
43+
44+
local script_path = vim.fn.expand(opts.script.path)
45+
local binary_name = vim.fn.fnamemodify(script_path, ":t")
46+
local exe_path = vim.fn.exepath(binary_name)
47+
4348
local desktop_entry = {
4449
name = "GitDev",
45-
exec = vim.fn.expand(opts.script.path) .. " %u",
50+
exec = ((exe_path ~= "" and binary_name) or script_path) .. " %u",
4651
mime_type = "x-scheme-handler/nvim-gitdev",
4752
}
4853

0 commit comments

Comments
 (0)