]> git.eshelyaron.com Git - emacs.git/commitdiff
Support showing directory in shell command prompt
authorStefan Kangas <stefankangas@gmail.com>
Fri, 11 Oct 2019 11:01:13 +0000 (13:01 +0200)
committerStefan Kangas <stefankangas@gmail.com>
Fri, 11 Oct 2019 11:01:13 +0000 (13:01 +0200)
* lisp/simple.el (shell-command-prompt-show-cwd): New defcustom.
(async-shell-command, shell-command): Show current directory in prompt
when above option is non-nil.  (Bug#4987)
* etc/NEWS: Announce it.

etc/NEWS
lisp/simple.el

index a3a7ff28e807c029a49292eb08653a3ae19c3294..4e7843ced85dc1142cced533accaa6c1c8b35362 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1568,6 +1568,10 @@ variable for remote shells.  It still defaults to "/bin/sh".
 *** 'async-shell-command-width' defines the number of display columns
 available for output of asynchronous shell commands.
 
++++
+*** Prompt for shell commands can now show the current directory.
+Customize 'shell-command-prompt-show-cwd' to enable it.
+
 ** Pcomplete
 
 *** The 'pcomplete' command is now obsolete
index 597278ae2b4d9f4377f5287f5e20486ae137202c..44ab8e125d6ec74e65996bb40ccef01cbe72a0c9 100644 (file)
@@ -3384,6 +3384,13 @@ command output."
   :group 'shell
   :version "27.1")
 
+(defcustom shell-command-prompt-show-cwd nil
+  "If non-nil, show current directory when prompting for a shell command.
+This affects `shell-command' and `async-shell-command'."
+  :type 'boolean
+  :group 'shell
+  :version "27.1")
+
 (defcustom shell-command-dont-erase-buffer nil
   "If non-nil, output buffer is not erased between shell commands.
 Also, a non-nil value sets the point in the output buffer
@@ -3473,7 +3480,12 @@ directly, since it offers more control and does not impose the use of
 a shell (with its need to quote arguments)."
   (interactive
    (list
-    (read-shell-command "Async shell command: " nil nil
+    (read-shell-command (if shell-command-prompt-show-cwd
+                            (format-message "Async shell command in `%s': "
+                                            (abbreviate-file-name
+                                             default-directory))
+                          "Async shell command: ")
+                        nil nil
                        (let ((filename
                               (cond
                                (buffer-file-name)
@@ -3546,7 +3558,12 @@ impose the use of a shell (with its need to quote arguments)."
 
   (interactive
    (list
-    (read-shell-command "Shell command: " nil nil
+    (read-shell-command (if shell-command-prompt-show-cwd
+                            (format-message "Shell command in `%s': "
+                                            (abbreviate-file-name
+                                             default-directory))
+                          "Shell command: ")
+                        nil nil
                        (let ((filename
                               (cond
                                (buffer-file-name)