diff options
| author | Michael Albinus | 2024-06-02 19:30:12 +0200 |
|---|---|---|
| committer | Michael Albinus | 2024-06-02 19:30:12 +0200 |
| commit | bffe73b562f4065bfa99095a46f1bdb731bebc13 (patch) | |
| tree | b672a57850df3c20816856328cc89db2d618f1ae /doc | |
| parent | 2849c0cda3785124465806134b316f95231a67a5 (diff) | |
| download | emacs-bffe73b562f4065bfa99095a46f1bdb731bebc13.tar.gz emacs-bffe73b562f4065bfa99095a46f1bdb731bebc13.zip | |
New user option 'shell-history-file-name'
* doc/emacs/misc.texi (Shell Ring): Explain shell-history-file-name.
* doc/misc/tramp.texi (Inline methods): Be more specific with containers.
(Remote processes): New subsection "Managing remote shell history".
Explain shell-history-file-name.
(Frequently Asked Questions): Add items to Tramp speedup. Remove
entry about history file.
* etc/NEWS: New user option 'shell-history-file-name'.
* lisp/shell.el (shell-history-file-name): New defcustom.
(shell-mode): Use it. (Bug#71049)
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/emacs/misc.texi | 20 | ||||
| -rw-r--r-- | doc/misc/tramp.texi | 120 |
2 files changed, 82 insertions, 58 deletions
diff --git a/doc/emacs/misc.texi b/doc/emacs/misc.texi index 3bee88bca86..68ea030e219 100644 --- a/doc/emacs/misc.texi +++ b/doc/emacs/misc.texi | |||
| @@ -1331,16 +1331,18 @@ buffer, or even killing large parts of it, does not affect the history | |||
| 1331 | that these commands access. | 1331 | that these commands access. |
| 1332 | 1332 | ||
| 1333 | @vindex comint-input-ring-file-name | 1333 | @vindex comint-input-ring-file-name |
| 1334 | @vindex shell-history-file-name | ||
| 1335 | @cindex @env{HISTFILE} environment variable | ||
| 1334 | Some shells store their command histories in files so that you can | 1336 | Some shells store their command histories in files so that you can |
| 1335 | refer to commands from previous shell sessions. Emacs reads | 1337 | refer to commands from previous shell sessions. Emacs reads the command |
| 1336 | the command history file for your chosen shell, to initialize its own | 1338 | history file for your chosen shell, to initialize its own command |
| 1337 | command history. The file name is @file{~/.bash_history} for bash, | 1339 | history. The history file name is the string specified in |
| 1338 | @file{~/.sh_history} for ksh, and @file{~/.history} for other shells. | 1340 | @code{shell-history-file-name}. If that user option is @code{t}, the |
| 1339 | 1341 | command history is not read. If the value is @code{nil}, the command | |
| 1340 | @vindex tramp-histfile-override | 1342 | history is read from the file specified in environment variable |
| 1341 | If you run the shell on a remote host, this setting might be | 1343 | @env{HISTFILE}, or from @file{~/.bash_history} for bash, |
| 1342 | overwritten by the variable @code{tramp-histfile-override}. It is | 1344 | @file{~/.sh_history} for ksh, @file{~/.zsh_history"} for zsh, or |
| 1343 | recommended to set this variable to @code{nil}. | 1345 | @file{~/.history} for other shells. |
| 1344 | 1346 | ||
| 1345 | @node Shell History Copying | 1347 | @node Shell History Copying |
| 1346 | @subsubsection Shell History Copying | 1348 | @subsubsection Shell History Copying |
diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi index 74081767caa..ec8a8d5c3eb 100644 --- a/doc/misc/tramp.texi +++ b/doc/misc/tramp.texi | |||
| @@ -976,7 +976,8 @@ session. | |||
| 976 | @end table | 976 | @end table |
| 977 | 977 | ||
| 978 | @noindent | 978 | @noindent |
| 979 | The following methods allow to access containers in different ways: | 979 | The following methods allow to access running containers in different |
| 980 | ways: | ||
| 980 | 981 | ||
| 981 | @table @asis | 982 | @table @asis |
| 982 | @item @option{docker} | 983 | @item @option{docker} |
| @@ -1017,6 +1018,9 @@ The host name may be either a container's name or ID, as returned by | |||
| 1017 | the default Toolbox container for the host will be used. There is no | 1018 | the default Toolbox container for the host will be used. There is no |
| 1018 | such default for Distrobox. | 1019 | such default for Distrobox. |
| 1019 | 1020 | ||
| 1021 | Contrary to the other container-based methods, these two methods start | ||
| 1022 | a created container, if it isn't running yet. | ||
| 1023 | |||
| 1020 | These are optional methods, @pxref{Optional methods}. They do not | 1024 | These are optional methods, @pxref{Optional methods}. They do not |
| 1021 | support user names. | 1025 | support user names. |
| 1022 | 1026 | ||
| @@ -4080,8 +4084,59 @@ host. Furthermore, set @code{tramp-use-connection-share} to | |||
| 4080 | unwanted side effects. | 4084 | unwanted side effects. |
| 4081 | 4085 | ||
| 4082 | 4086 | ||
| 4087 | @anchor{Managing remote shell history} | ||
| 4088 | @subsection Managing remote shell history | ||
| 4089 | @cindex shell history | ||
| 4090 | @vindex tramp-histfile-override | ||
| 4091 | @vindex HISTFILE@r{, environment variable} | ||
| 4092 | @vindex HISTFILESIZE@r{, environment variable} | ||
| 4093 | @vindex HISTSIZE@r{, environment variable} | ||
| 4094 | |||
| 4095 | Due to the remote shell saving tilde expansions triggered by | ||
| 4096 | @value{tramp}, the shell history file is probably growing rapidly. | ||
| 4097 | @value{tramp} can suppress this behavior with the user option | ||
| 4098 | @code{tramp-histfile-override}. When set to @code{t}, environment | ||
| 4099 | variable @env{HISTFILE} is unset, and environment variables | ||
| 4100 | @env{HISTFILESIZE} and @env{HISTSIZE} are set to 0. Don't use this | ||
| 4101 | with @command{bash} 5.0.0. There is a bug in @command{bash} which | ||
| 4102 | lets @command{bash} die. | ||
| 4103 | |||
| 4104 | Alternatively, @code{tramp-histfile-override} could be a string. | ||
| 4105 | Environment variable @env{HISTFILE} is set to this file name then. Be | ||
| 4106 | careful when setting to @file{/dev/null}; this might result in | ||
| 4107 | undesired results when using @command{bash} as remote shell. | ||
| 4108 | |||
| 4109 | Another approach is to disable @value{tramp}'s handling of the | ||
| 4110 | @env{HISTFILE} at all by setting @code{tramp-histfile-override} to | ||
| 4111 | @code{nil}. In this case, saving history could be turned off by | ||
| 4112 | putting this shell code in @file{.bashrc} or @file{.kshrc}: | ||
| 4113 | |||
| 4114 | @example | ||
| 4115 | @group | ||
| 4116 | if [ -f $HOME/.sh_history ] ; then | ||
| 4117 | /bin/rm $HOME/.sh_history | ||
| 4118 | fi | ||
| 4119 | if [ "$@{HISTFILE-unset@}" != "unset" ] ; then | ||
| 4120 | unset HISTFILE | ||
| 4121 | fi | ||
| 4122 | if [ "$@{HISTSIZE-unset@}" != "unset" ] ; then | ||
| 4123 | unset HISTSIZE | ||
| 4124 | fi | ||
| 4125 | @end group | ||
| 4126 | @end example | ||
| 4127 | |||
| 4128 | For @option{ssh}-based method, add the following line to your | ||
| 4129 | @file{~/.ssh/environment}: | ||
| 4130 | |||
| 4131 | @example | ||
| 4132 | HISTFILE=/dev/null | ||
| 4133 | @end example | ||
| 4134 | |||
| 4135 | |||
| 4083 | @subsection Running @code{shell} on a remote host | 4136 | @subsection Running @code{shell} on a remote host |
| 4084 | @cindex @code{shell} | 4137 | @cindex @code{shell} |
| 4138 | @vindex explicit-shell-file-name | ||
| 4139 | @vindex shell-history-file-name | ||
| 4085 | 4140 | ||
| 4086 | Set @code{explicit-shell-file-name} to the appropriate shell name | 4141 | Set @code{explicit-shell-file-name} to the appropriate shell name |
| 4087 | when using @value{tramp} between two hosts with different operating | 4142 | when using @value{tramp} between two hosts with different operating |
| @@ -4126,6 +4181,14 @@ of @code{explicit-shell-file-name} for different remote hosts. | |||
| 4126 | @end group | 4181 | @end group |
| 4127 | @end lisp | 4182 | @end lisp |
| 4128 | 4183 | ||
| 4184 | The command @code{shell} reads the remote history file in order to to | ||
| 4185 | initialize the history input ring. You can set the user option | ||
| 4186 | @code{shell-history-file-name} in order to specify which remote | ||
| 4187 | history file is taken, or whether to suppress this at all. It accepts | ||
| 4188 | the same values as @code{tramp-histfile-override}, see @pxref{Managing | ||
| 4189 | remote shell history}. @code{shell-history-file-name} accepts also | ||
| 4190 | connection-local values in @code{shell} buffers. | ||
| 4191 | |||
| 4129 | 4192 | ||
| 4130 | @subsection Running @code{shell-command} on a remote host | 4193 | @subsection Running @code{shell-command} on a remote host |
| 4131 | @cindex @code{shell-command} | 4194 | @cindex @code{shell-command} |
| @@ -5171,6 +5234,13 @@ connections, apply the following code. | |||
| 5171 | @end lisp | 5234 | @end lisp |
| 5172 | 5235 | ||
| 5173 | @item | 5236 | @item |
| 5237 | Use direct asynchronous processes if possible. | ||
| 5238 | |||
| 5239 | @item | ||
| 5240 | Suppress reading the remote history file in @code{shell}. Set | ||
| 5241 | @code{shell-history-file-name} to @code{t}. | ||
| 5242 | |||
| 5243 | @item | ||
| 5174 | Disable excessive traces. Set @code{tramp-verbose} to 3 or lower, | 5244 | Disable excessive traces. Set @code{tramp-verbose} to 3 or lower, |
| 5175 | default being 3. Increase trace levels temporarily when hunting for | 5245 | default being 3. Increase trace levels temporarily when hunting for |
| 5176 | bugs. | 5246 | bugs. |
| @@ -5477,54 +5547,6 @@ as follows: | |||
| 5477 | 5547 | ||
| 5478 | 5548 | ||
| 5479 | @item | 5549 | @item |
| 5480 | Why is @file{~/.sh_history} on the remote host growing? | ||
| 5481 | |||
| 5482 | @vindex tramp-histfile-override | ||
| 5483 | @vindex HISTFILE@r{, environment variable} | ||
| 5484 | @vindex HISTFILESIZE@r{, environment variable} | ||
| 5485 | @vindex HISTSIZE@r{, environment variable} | ||
| 5486 | Due to the remote shell saving tilde expansions triggered by | ||
| 5487 | @value{tramp}, the history file is probably growing rapidly. | ||
| 5488 | @value{tramp} can suppress this behavior with the user option | ||
| 5489 | @code{tramp-histfile-override}. When set to @code{t}, environment | ||
| 5490 | variable @env{HISTFILE} is unset, and environment variables | ||
| 5491 | @env{HISTFILESIZE} and @env{HISTSIZE} are set to 0. Don't use this | ||
| 5492 | with @command{bash} 5.0.0. There is a bug in @command{bash} which | ||
| 5493 | lets @command{bash} die. | ||
| 5494 | |||
| 5495 | Alternatively, @code{tramp-histfile-override} could be a string. | ||
| 5496 | Environment variable @env{HISTFILE} is set to this file name then. Be | ||
| 5497 | careful when setting to @file{/dev/null}; this might result in | ||
| 5498 | undesired results when using @command{bash} as remote shell. | ||
| 5499 | |||
| 5500 | Another approach is to disable @value{tramp}'s handling of the | ||
| 5501 | @env{HISTFILE} at all by setting @code{tramp-histfile-override} to | ||
| 5502 | @code{nil}. In this case, saving history could be turned off by | ||
| 5503 | putting this shell code in @file{.bashrc} or @file{.kshrc}: | ||
| 5504 | |||
| 5505 | @example | ||
| 5506 | @group | ||
| 5507 | if [ -f $HOME/.sh_history ] ; then | ||
| 5508 | /bin/rm $HOME/.sh_history | ||
| 5509 | fi | ||
| 5510 | if [ "$@{HISTFILE-unset@}" != "unset" ] ; then | ||
| 5511 | unset HISTFILE | ||
| 5512 | fi | ||
| 5513 | if [ "$@{HISTSIZE-unset@}" != "unset" ] ; then | ||
| 5514 | unset HISTSIZE | ||
| 5515 | fi | ||
| 5516 | @end group | ||
| 5517 | @end example | ||
| 5518 | |||
| 5519 | For @option{ssh}-based method, add the following line to your | ||
| 5520 | @file{~/.ssh/environment}: | ||
| 5521 | |||
| 5522 | @example | ||
| 5523 | HISTFILE=/dev/null | ||
| 5524 | @end example | ||
| 5525 | |||
| 5526 | |||
| 5527 | @item | ||
| 5528 | Where are remote files trashed to? | 5550 | Where are remote files trashed to? |
| 5529 | 5551 | ||
| 5530 | @vindex remote-file-name-inhibit-delete-by-moving-to-trash | 5552 | @vindex remote-file-name-inhibit-delete-by-moving-to-trash |