aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorMichael Albinus2024-06-02 19:30:12 +0200
committerMichael Albinus2024-06-02 19:30:12 +0200
commitbffe73b562f4065bfa99095a46f1bdb731bebc13 (patch)
treeb672a57850df3c20816856328cc89db2d618f1ae /doc
parent2849c0cda3785124465806134b316f95231a67a5 (diff)
downloademacs-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.texi20
-rw-r--r--doc/misc/tramp.texi120
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
1331that these commands access. 1331that 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
1335refer to commands from previous shell sessions. Emacs reads 1337refer to commands from previous shell sessions. Emacs reads the command
1336the command history file for your chosen shell, to initialize its own 1338history file for your chosen shell, to initialize its own command
1337command history. The file name is @file{~/.bash_history} for bash, 1339history. 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 1341command history is not read. If the value is @code{nil}, the command
1340@vindex tramp-histfile-override 1342history 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,
1342overwritten by the variable @code{tramp-histfile-override}. It is 1344@file{~/.sh_history} for ksh, @file{~/.zsh_history"} for zsh, or
1343recommended 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
979The following methods allow to access containers in different ways: 979The following methods allow to access running containers in different
980ways:
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
1017the default Toolbox container for the host will be used. There is no 1018the default Toolbox container for the host will be used. There is no
1018such default for Distrobox. 1019such default for Distrobox.
1019 1020
1021Contrary to the other container-based methods, these two methods start
1022a created container, if it isn't running yet.
1023
1020These are optional methods, @pxref{Optional methods}. They do not 1024These are optional methods, @pxref{Optional methods}. They do not
1021support user names. 1025support user names.
1022 1026
@@ -4080,8 +4084,59 @@ host. Furthermore, set @code{tramp-use-connection-share} to
4080unwanted side effects. 4084unwanted 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
4095Due 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
4099variable @env{HISTFILE} is unset, and environment variables
4100@env{HISTFILESIZE} and @env{HISTSIZE} are set to 0. Don't use this
4101with @command{bash} 5.0.0. There is a bug in @command{bash} which
4102lets @command{bash} die.
4103
4104Alternatively, @code{tramp-histfile-override} could be a string.
4105Environment variable @env{HISTFILE} is set to this file name then. Be
4106careful when setting to @file{/dev/null}; this might result in
4107undesired results when using @command{bash} as remote shell.
4108
4109Another 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
4112putting this shell code in @file{.bashrc} or @file{.kshrc}:
4113
4114@example
4115@group
4116if [ -f $HOME/.sh_history ] ; then
4117 /bin/rm $HOME/.sh_history
4118fi
4119if [ "$@{HISTFILE-unset@}" != "unset" ] ; then
4120 unset HISTFILE
4121fi
4122if [ "$@{HISTSIZE-unset@}" != "unset" ] ; then
4123 unset HISTSIZE
4124fi
4125@end group
4126@end example
4127
4128For @option{ssh}-based method, add the following line to your
4129@file{~/.ssh/environment}:
4130
4131@example
4132HISTFILE=/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
4086Set @code{explicit-shell-file-name} to the appropriate shell name 4141Set @code{explicit-shell-file-name} to the appropriate shell name
4087when using @value{tramp} between two hosts with different operating 4142when 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
4184The command @code{shell} reads the remote history file in order to to
4185initialize the history input ring. You can set the user option
4186@code{shell-history-file-name} in order to specify which remote
4187history file is taken, or whether to suppress this at all. It accepts
4188the same values as @code{tramp-histfile-override}, see @pxref{Managing
4189remote shell history}. @code{shell-history-file-name} accepts also
4190connection-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
5237Use direct asynchronous processes if possible.
5238
5239@item
5240Suppress reading the remote history file in @code{shell}. Set
5241@code{shell-history-file-name} to @code{t}.
5242
5243@item
5174Disable excessive traces. Set @code{tramp-verbose} to 3 or lower, 5244Disable excessive traces. Set @code{tramp-verbose} to 3 or lower,
5175default being 3. Increase trace levels temporarily when hunting for 5245default being 3. Increase trace levels temporarily when hunting for
5176bugs. 5246bugs.
@@ -5477,54 +5547,6 @@ as follows:
5477 5547
5478 5548
5479@item 5549@item
5480Why 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}
5486Due 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
5490variable @env{HISTFILE} is unset, and environment variables
5491@env{HISTFILESIZE} and @env{HISTSIZE} are set to 0. Don't use this
5492with @command{bash} 5.0.0. There is a bug in @command{bash} which
5493lets @command{bash} die.
5494
5495Alternatively, @code{tramp-histfile-override} could be a string.
5496Environment variable @env{HISTFILE} is set to this file name then. Be
5497careful when setting to @file{/dev/null}; this might result in
5498undesired results when using @command{bash} as remote shell.
5499
5500Another 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
5503putting this shell code in @file{.bashrc} or @file{.kshrc}:
5504
5505@example
5506@group
5507if [ -f $HOME/.sh_history ] ; then
5508 /bin/rm $HOME/.sh_history
5509fi
5510if [ "$@{HISTFILE-unset@}" != "unset" ] ; then
5511 unset HISTFILE
5512fi
5513if [ "$@{HISTSIZE-unset@}" != "unset" ] ; then
5514 unset HISTSIZE
5515fi
5516@end group
5517@end example
5518
5519For @option{ssh}-based method, add the following line to your
5520@file{~/.ssh/environment}:
5521
5522@example
5523HISTFILE=/dev/null
5524@end example
5525
5526
5527@item
5528Where are remote files trashed to? 5550Where 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