emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/eat 77bc6d7acc: Allow customizing the default shell


From: ELPA Syncer
Subject: [nongnu] elpa/eat 77bc6d7acc: Allow customizing the default shell
Date: Thu, 4 Jan 2024 03:59:34 -0500 (EST)

branch: elpa/eat
commit 77bc6d7acc8e6d26905310ad9e9ca09469a7ef1c
Author: Akib Azmain Turja <akib@disroot.org>
Commit: Akib Azmain Turja <akib@disroot.org>

    Allow customizing the default shell
    
    * eat.el (eat-default-shell-function, eat-shell)
    (eat-tramp-shells): New user option.
    * eat.el (eat-default-shell): New function.
    * eat.el (eat--1, eat): Call the function specified in
    'eat-default-shell-function' to get the default shell.
    * eat.texi (Changing Shell): New chapter.
---
 eat.el   | 37 +++++++++++++++++++++++++++++++------
 eat.texi | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 65 insertions(+), 6 deletions(-)

diff --git a/eat.el b/eat.el
index 3ca1c8fea2..2dd436d67e 100644
--- a/eat.el
+++ b/eat.el
@@ -89,6 +89,8 @@
 (require 'shell)
 (require 'term)
 (require 'url)
+(require 'tramp)
+(require 'term/xterm)
 
 ;; Needed by `eat-reload'.
 (defvar eat--being-loaded nil
@@ -117,6 +119,26 @@
   "Eat Eshell integration."
   :group 'eat)
 
+(defcustom eat-default-shell-function #'eat-default-shell
+  "Function to call to get the default shell to run."
+  :type 'function
+  :group 'eat-ui)
+
+(defcustom eat-shell (or explicit-shell-file-name
+                         (getenv "ESHELL")
+                         shell-file-name)
+  "Default shell to run."
+  :type 'string
+  :group 'eat-ui)
+
+(defcustom eat-tramp-shells '(("docker" "/bin/sh"))
+  "Alist specifying the shells to run in Tramp.
+
+Each element of form (TRAMP-METHOD SHELL), where SHELL corresponds to
+the default shell for remote directories using TRAMP-METHOD."
+  :type '(alist :key-type string :value-type string)
+  :group 'eat-ui)
+
 (defcustom eat-buffer-name "*eat*"
   "The basename used for Eat buffers.
 
@@ -7043,14 +7065,19 @@ PROGRAM."
       (eat-exec buffer name program startfile switches))
     buffer))
 
+(defun eat-default-shell ()
+  "Return a shell to run."
+  (or (and (file-remote-p default-directory)
+           (with-parsed-tramp-file-name default-directory nil
+             (alist-get method eat-tramp-shells)))
+      eat-shell))
+
 (defun eat--1 (program arg display-buffer-fn)
   "Start a new Eat terminal emulator in a buffer.
 
 PROGRAM and ARG is same as in `eat' and `eat-other-window'.
 DISPLAY-BUFFER-FN is the function to display the buffer."
-  (let ((program (or program (or explicit-shell-file-name
-                                 (getenv "ESHELL")
-                                 shell-file-name)))
+  (let ((program (or program (funcall eat-default-shell-function)))
         (buffer
          (cond
           ((numberp arg)
@@ -7089,9 +7116,7 @@ PROGRAM can be a shell command."
   (interactive
    (list (when (equal current-prefix-arg '(16))
            (read-shell-command "Run program: "
-                               (or explicit-shell-file-name
-                                   (getenv "ESHELL")
-                                   shell-file-name)))
+                               (funcall eat-default-shell-function)))
          current-prefix-arg))
   (eat--1 program arg #'pop-to-buffer-same-window))
 
diff --git a/eat.texi b/eat.texi
index a7ca74cc42..a364ddd625 100644
--- a/eat.texi
+++ b/eat.texi
@@ -67,6 +67,7 @@ Basic Operations
 Advanced Customizations
 * Shell Integration::   Getting the most from Eat and your shell.
 * Querying Before Kill::  Confirming before you kill your terminal.
+* Changing Shell::      Changing the default shell.
 * Display::             The region where everything is shown.
 * Scrollback::          Region for things that went out of display.
 * Cursor Types::        Cursor can displayed in many forms.
@@ -676,6 +677,39 @@ integration code is executed on shell); before that it is 
essentially
 same as @code{t}, and Eat will always query.
 @end defopt
 
+@node Changing Shell
+@cindex changing default shell
+@cindex changing shell
+@cindex shell, default, changing
+@cindex default, shell changing
+@cindex shell, changing shell
+@chapter Changing the Default Shell
+
+Eat automatically uses a reasonable shell by default.  However you can
+customize it.
+
+@vindex eat-shell
+@defopt eat-shell
+The default shell to run.
+@end defopt
+
+@vindex eat-tramp-shells
+@defopt eat-tramp-shells
+This user options allows you to customize default shell for each Tramp
+method.  It's an alist and it's elements are of form (TRAMP-METHOD
+SHELL).
+@end defopt
+
+@vindex eat-default-shell-function
+@defopt eat-default-shell-function
+This user options gives more control on the default shell.  It
+specifies a function to call without any argument, whose return value
+is used as the default shell.
+
+If you change this from the default value, @code{eat-shell} and
+@code{eat-tramp-shells} won't work.
+@end defopt
+
 @node Display
 @cindex display
 @chapter Display



reply via email to

[Prev in Thread] Current Thread [Next in Thread]