I'm trying to print the path of $HISTFILE in emacs, but it doesn't work with (getenv "HISTFILE")
or (shell-command-to-string "echo $HISTFILE")
. It is working with $PATH and every other variable I've tried.
Asked
Active
Viewed 610 times
1 Answers
3
I'm assuming you're using the bash-shell. The HISTFILE environment variable is either set implicitly by the shell or by setting it in some script file, e.g. ~/.bashrc.
Emacs inherits the environment from the process that started it, which is usually some X-window-manager, while shell-command-to-string
starts a non-interactive shell.
So, either there is no shell involved, or it is, but neither does it set this variable implicitly, nor does it read any initialization scripts, where it may have been set.

politza
- 3,336
- 16
- 16
-
Is it possible to read HISTFILE somehow or do I have to set it manually ? – bertfred Mar 08 '17 at 19:16
-
2
sh
session. To check, just launch two terminals, one underbash
, and the other undersh
. In every of the two terminals, type:echo $HISTFILE
. – Nsukami _ Mar 08 '17 at 14:05M-x shell
it will set HISTFILE, so it will be in its environment (but still not in the environment of emacs). – NickD Mar 08 '17 at 15:24shell
also tries(getenv "HISTFILE")
and otherwise sets it with ...(string-equal shell "bash") "~/.bash_history")
... – bertfred Mar 08 '17 at 16:43