[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Saving/Recalling Shell Commands History?
From: |
Peter Dyballa |
Subject: |
Re: Saving/Recalling Shell Commands History? |
Date: |
Wed, 23 Aug 2006 01:13:04 +0200 |
Am 21.08.2006 um 23:32 schrieb Kevin Rodgers:
So leave it commented out, and put this in your ~/.emacs file:
(add-hook 'shell-mode-hook
(lambda ()
(setq comint-input-ring-file-name ; buffer-local
(expand-file-name "history" desktop-dirname))))
The code above works, but it only works for GNU Emacs. The shell
never gets knowledge of this!
I think the meaning of comint-input-ring-file-name is to let GNU
Emacs know directly, for whatever reason or use, what the shell's
history file is. Maybe it's useful in dumb shells that cannot provide
their own history, maybe it's useful in TRAMP, i.e. working in a
remote shell.
For my purpose I extended your hook to make the shell know where the
actual history file of the Emacs *shell* buffer is. Since I want to
separate the different Emacs versions I am using I have created an
intermediate and temporary file, ~/.emacs_tcsh-init, which contains a
line that tells the shell which file to use for a history. For tcsh
the file ~/.emacs_tcsh is executed in *shell* buffer. So
~/.emacs_tcsh needs to be extended by one line that loads the
intermediate file – and removes it!
Here is my extended hook:
(add-hook 'shell-mode-hook
(lambda ()
(setq comint-input-ring-file-name
(expand-file-name "history" desktop-dirname))
(setq histfile_cmd (format
"echo \"set histfile = %s\" > .emacs_tcsh-init"
comint-input-ring-file-name))
(shell-command histfile_cmd)
))
~/.emacs_tcsh-init will have a line like:
set histfile = <some path name>
The extended version of ~/.emacs_tcsh has two more lines:
sleep 1
if (-e ~/.emacs_tcsh-init) source ~/.emacs_tcsh-init && rm
~/.emacs_tcsh-init
The sleep is needed, otherwise the file's removal fails with an error
message in *shell*. One cannot feel this one more second in GNU
Emacs's start-up.
For bash the history file is addressed by the environment variable
$HISTFILE. It's probably OK to use the syntax
HISTFILE=<some path name>
without 'export.' The syntax for the ~/.emacs_bash file would be:
if [ -e ~/.emacs_bash-init ]; then . ~/.emacs_bash-init && rm
~/.emacs_bash-init; fi
There is one more disadvantage: an empty buffer *Shell Command
Output* is created because of executing (shell-command
histfile_cmd) ... Could be a kill-buffer in the hook removes it!
--
Greetings
Pete
The day Microsoft makes something that doesn't suck
is the day they start selling vacuum cleaners.
Ernest Jan Plugge
- Saving/Recalling Shell Commands History?, gamename, 2006/08/21
- RE: Saving/Recalling Shell Commands History?, Drew Adams, 2006/08/21
- Re: Saving/Recalling Shell Commands History?, Peter Dyballa, 2006/08/21
- RE: Saving/Recalling Shell Commands History?, Drew Adams, 2006/08/21
- Re: Saving/Recalling Shell Commands History?, Peter Dyballa, 2006/08/21
- RE: Saving/Recalling Shell Commands History?, Drew Adams, 2006/08/21
- Re: Saving/Recalling Shell Commands History?, Kevin Rodgers, 2006/08/21
- Re: Saving/Recalling Shell Commands History?, Peter Dyballa, 2006/08/21
- Re: Saving/Recalling Shell Commands History?,
Peter Dyballa <=
- Re: Saving/Recalling Shell Commands History?, Kevin Rodgers, 2006/08/23
- Re: Saving/Recalling Shell Commands History?, Peter Dyballa, 2006/08/23
Re: Saving/Recalling Shell Commands History?, Jesse Alama, 2006/08/21