I have noticed that opening a tramp connection on remote hosts sometimes created a .tramp_history file in the user's directory. Is there any way to disable such a behavior? I have to log in to many boxes and that's a lot of cleanup to do. No such options seem to be available in the tramp customization group.

The solution might certainly involve some lisp, but my skills are so far very limited... Thanks for your help!

PS: the same question was asked in 2011, see http://lists.gnu.org/archive/html/help-gnu-emacs/2011-01/msg00875.html...


In recent Tramp versions, there is the variable tramp-histfile-override. You can override its default value.

  • How about elaborating a bit? How does this help answer the question? – Drew Jun 6 '15 at 22:16
  • 4
    The docstring explains this a little bit. (setq tramp-histfile-override "/dev/null") would avoid writing Tramp specific entries in a remote history file. However, there is an error in some bash versions which would give undesired results. Therefore, Tramp uses the default value ".tramp_history". – Michael Albinus Jun 7 '15 at 13:26
  • Is there anything else we need to do besides changing this value in tramp/lisp/tramp-sh.el and reloading init.el? Do we need to recompile anything? – Andrew Mar 16 '17 at 16:56
  • Setting tramp-histfile-override shall be sufficient. It will be taken for every new connection. – Michael Albinus Mar 18 '17 at 8:23

The value of the variable tramp-persistency-file-name is used by tramp-dump-connection-properties and is also hard-coded into settings that load initially with tramp-cache.el. I would suggest changing the name/location to /tmp/.tramp or something of that nature if you don't want to ever see it. There is no user option to turn it off completely. Of course, the /tmp directory on some operating systems is emptied out each time the computer is started -- so bear that in mind when choosing a location. A better idea is to set up folders for certain files that Emacs needs and store them in there.

(require 'tramp-cache)
(setq tramp-persistency-file-name "/tmp/.tramp")
  • Thanks for your comment. I'm wondering if this file is absolutly necessary for tramp to function correctly (will be able to test later this weekend)... and if it could be redirected to /dev/null. – KookieMonster Jun 5 '15 at 16:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.