Created
July 2, 2015 08:51
-
-
Save sjrmanning/02c6536923c13871ce53 to your computer and use it in GitHub Desktop.
Start magit or monky depending on repository found in buffer-local working directory.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun process-exit-code-and-output (program &rest args) | |
"Run PROGRAM with ARGS and return the exit code and output in a list." | |
(with-temp-buffer | |
(list (apply 'call-process program nil (current-buffer) nil args) | |
(buffer-string)))) | |
(defun magit-or-monky-status () | |
"Call `magit-status' or `monky-status' depending on whether a | |
git or hg repository is found in the buffer-local working dir." | |
(interactive) | |
(cond | |
((eq (car (process-exit-code-and-output "hg" "status")) 0) | |
(monky-status)) | |
((eq (car (process-exit-code-and-output "git" "status")) 0) | |
(call-interactively 'magit-status)) | |
(t (message "No hg or git repository found at %s" default-directory)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment