From: Peter Dyballa <Peter_Dyballa@web.DE>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Saving/Recalling Shell Commands History?
Date: Wed, 23 Aug 2006 01:13:04 +0200 [thread overview]
Message-ID: <85A5A4F0-4577-4C65-B855-C776F96FA6E3@web.DE> (raw)
In-Reply-To: <ecd8rd$dot$1@sea.gmane.org>
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
next prev parent reply other threads:[~2006-08-22 23:13 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-21 15:07 Saving/Recalling Shell Commands History? gamename
2006-08-21 16:35 ` Drew Adams
2006-08-21 20:09 ` Peter Dyballa
2006-08-21 20:17 ` Drew Adams
2006-08-21 21:08 ` Peter Dyballa
2006-08-21 21:30 ` Drew Adams
2006-08-21 21:32 ` Kevin Rodgers
2006-08-21 22:14 ` Peter Dyballa
2006-08-22 23:13 ` Peter Dyballa [this message]
2006-08-23 14:20 ` Kevin Rodgers
2006-08-23 15:20 ` Peter Dyballa
2006-08-21 20:19 ` Jesse Alama
2006-08-21 21:11 ` Peter Dyballa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=85A5A4F0-4577-4C65-B855-C776F96FA6E3@web.DE \
--to=peter_dyballa@web.de \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).