How do I execute a shell command (eg, git gui ) from a specific directory? I'd prefer a cross-platform approach that doesn't depend shell operators like && or ; because I need this to run on Windows and unix. (For example, calling cd /path/to/dir && git gui won't work on Windows because && is not valid.)

I tried:

(async-shell-command (concat "cd \"" (replace-regexp-in-string "/" "\\\\" (file-name-directory (buffer-file-name))) "\" ; git gui"))

That fails because for whatever reason the shell thinks ; git gui is part of the path, and it reports: The system cannot find the path specified.

So, I'd rather not deal with shell quirks and I'm hoping there's an elisp function that sets the directory for shell-command or async-shell-command . I tried:

(shell-process-pushd (file-name-directory (buffer-file-name))) (shell-command "git gui") (shell-process-popd nil)

That had no effect: git gui always opens in my home directory. (Also, shell-process-pushd/popd are not documented.)

This also doesn't work:

(start-process "gitgui" nil "git" "gui")

Neither does this: