diff --git a/eat.el b/eat.el index 3ca1c8f..2dd436d 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 a7ca74c..a364ddd 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