I use Git on my 2 Macs, which each have a different executable path (one is homebrew, one is make/install’d). I also use Git via Tramp mode.
So basically I want this, in pseudo code:
if home mac:
(setq magit-git-executable "~/Projects/homebrew/bin/git")
else if work mac:
(setq magit-git-executable "/usr/local/git/bin/git")
else [if in tramp mode]:
(setq magit-git-executable "git") ;; Linux can work this out so don't need a full path
This would all work fine as the last clause if Emacs would respect my setenv("PATH") configuration, but it doesn’t seem to.
Is there a good way to solve this in Elisp so my emacs.d can remain portable between machines? Failing that, is it possible to set a variable just when I’m editing a file via tramp?
It’s going to be tricky if you insist on
magit-git-executabletaking one value if you’re in a Tramp buffer and another value if not. It would be easier to leavemagit-git-executableat its default value of"git", and adjust yourexec-pathdepending on which machine you’re on.How do you distinguish your machines? By name? If so, then maybe something like this: