aboutsummaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorJonas Bernoulli <jonas@bernoul.li>2015-08-15 14:36:04 +0200
committerJonas Bernoulli <jonas@bernoul.li>2015-08-15 14:36:04 +0200
commit6b2931f57e5514fe565fd4608e60c6f91c97fb6d (patch)
tree456962e00a9cc13b2a7ec1adc348353572de6815 /lisp
parentf6f3e3bbfed0b250170d5d682e25f4ad7c5c511b (diff)
magit-shell-command{,-topdir}: new commands
Diffstat (limited to 'lisp')
-rw-r--r--lisp/magit.el52
1 files changed, 39 insertions, 13 deletions
diff --git a/lisp/magit.el b/lisp/magit.el
index c541a74..08f7f9e 100644
--- a/lisp/magit.el
+++ b/lisp/magit.el
@@ -1987,20 +1987,22 @@ Currently this only adds the following key bindings.
(magit-define-popup magit-run-popup
"Popup console for running raw Git commands."
'magit-commands nil nil
- :actions '((?! "Git Subcommand (from root)" magit-git-command-topdir)
- (?: "Git Subcommand (from pwd)" magit-git-command)
- (?g "Git Gui" magit-run-git-gui)
- (?k "Gitk" magit-run-gitk))
- :default-action 'magit-git-command)
+ :actions '((?! "Git Subcommand (in topdir)" magit-git-command-topdir)
+ (?k "Gitk" magit-run-gitk)
+ (?p "Git Subcommand (in pwd)" magit-git-command)
+ (?g "Git Gui" magit-run-git-gui)
+ (?s "Shell command (in topdir)" magit-shell-command-topdir)
+ nil
+ (?S "Shell command (in pwd)" magit-shell-command))
+ :default-action 'magit-git-command
+ :max-action-columns 2)
;;;###autoload
(defun magit-git-command (args directory)
"Execute a Git subcommand asynchronously, displaying the output.
With a prefix argument run Git in the root of the current
-repository, otherwise in `default-directory'.
-
-Non-interactively run Git in DIRECTORY with ARGS."
- (interactive (magit-git-command-read-args))
+repository, otherwise in `default-directory'."
+ (interactive (magit-read-shell-command "Git subcommand (pwd: %s)"))
(require 'eshell)
(with-temp-buffer
(insert args)
@@ -2011,20 +2013,44 @@ Non-interactively run Git in DIRECTORY with ARGS."
(magit-mode-display-buffer (magit-process-buffer directory t)
'magit-process-mode 'pop-to-buffer))
+;;;###autoload
(defun magit-git-command-topdir (args directory)
"Execute a Git subcommand asynchronously, displaying the output.
Run Git in the top-level directory of the current repository.
\n(fn)" ; arguments are for internal use
- (interactive (magit-git-command-read-args t))
+ (interactive (magit-read-shell-command "Git subcommand (pwd: %s)" t))
+ (magit-git-command args directory))
+
+;;;###autoload
+(defun magit-shell-command (args directory)
+ "Execute a shell command asynchronously, displaying the output.
+With a prefix argument run the command in the root of the current
+repository, otherwise in `default-directory'."
+ (interactive (magit-read-shell-command "Shell command (pwd: %s)"))
+ (require 'eshell)
+ (with-temp-buffer
+ (insert args)
+ (setq args (mapcar 'eval (eshell-parse-arguments (point-min)
+ (point-max))))
+ (setq default-directory directory)
+ (apply #'magit-start-process (car args) nil (cdr args)))
+ (magit-mode-display-buffer (magit-process-buffer directory t)
+ 'magit-process-mode 'pop-to-buffer))
+
+;;;###autoload
+(defun magit-shell-command-topdir (args directory)
+ "Execute a shell command asynchronously, displaying the output.
+Run the command in the top-level directory of the current repository.
+\n(fn)" ; arguments are for internal use
+ (interactive (magit-read-shell-command "Shell command (pwd: %s)" t))
(magit-git-command args directory))
-(defun magit-git-command-read-args (&optional root)
+(defun magit-read-shell-command (prompt &optional root)
(let ((dir (if (or root current-prefix-arg)
(or (magit-toplevel)
(user-error "Not inside a Git repository"))
(expand-file-name default-directory))))
- (list (magit-read-string (format "Git subcommand (in %s)"
- (abbreviate-file-name dir))
+ (list (magit-read-string (format prompt (abbreviate-file-name dir))
nil 'magit-git-command-history)
dir)))