History file for dialog C shell (t)csh
Polytropon
freebsd at edvax.de
Sun Apr 20 18:46:18 UTC 2014
On Sun, 20 Apr 2014 12:16:55 -0600 (MDT), Warren Block wrote:
> On Sun, 20 Apr 2014, Trond Endrestøl wrote:
>
> > On Sun, 20 Apr 2014 19:40+0200, Polytropon wrote:
> >
> >> I have a question regarding shell history when running several
> >> shell instances. The C shell (still) is my primary interactive
> >> shell. It stores commands in ~/.history. But as I'm using more
> >> than one shell instance (in fact, 5+ shells is the norm here,
> >> called inside X terminals), I find that the history file only
> >> contains commands from one of those shells, even though the history
> >> of each indivual shell can recall previous commands. At the end,
> >> only one shell's commands are stored in the history file, so
> >> after a reboot for example, all shells have _that_ specific
> >> history.
> >>
> >> My question sounds stupid, even to me: Is there a way to have
> >> individual shell history files for each shell instance? I don't
> >> even have an idea of how to make the association shell<->history
> >> for later re-identification... it already sounds confusing...
> >>
> >> Or on the other hand, is it possible to have all shells send
> >> their history to a common history file?
> >>
> >> Or should I simply switch over to a different shell? ;-)
> >
> > Could this be what you need?
> >
> > set history = 200000
> > set savehist = (200000 merge)
>
> The merged history is shared by all new shells. It would not be hard to
> load or save particular history files based on a variable, then set the
> terminal title to a name. That name would have to be preset somehow,
> though... like different icons or key commands to start the different
> sessions.
This sounds possible. The requires parts are part of
the shell, if I remember correctly, and you can ivoke
them with "predefined settings", maybe derived from
some X-related ID (-class parameter for Xterms for
example, or examining the parent xterm's properties
with the "xprop" command).
> > It saves the 200,000 last commands, and merges the new commands with
> > the previously saved ones.
>
> Yes, along with adding 'history -S' to .logout.
This seems to be exactly what I need. I've made those
settings and will check.
Additional background: Sometimes you want to check a
user's history because he claimed "I've tried it, but
it doesn't work", of course without providing commands
and output. So you're checking his shell history file.
The problem: The file that is present could be the one
related to the shell from what he did _not_ execute
the command. With a merged approach, you could review
all commands.
> I'm starting to wonder about adding some history commands to be executed
> as part of the prompt, so that each session shares the history
> immediately rather than only adding to it on logout. Maybe
> 'history -S; history -L'? (Untested.)
For interactive shells, ~/.cshrc could contain a
if ($?prompt) then
... settings for interactive shells here ...
endif
block. As if someone would _script_ with the C shell! ;-)
Additionally, there's a mechanism to take actions before and
after the prompt is written ("between commands"): You can
set up those in .cshrc as well:
alias precmd '<happend prior to executing a command>'
alias postcmd '<happend prior to printing the prompt>'
They can also effect the setting of the prompt itself (by
calling "set prompt = '<something>'") if this should be needed.
--
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
More information about the freebsd-questions
mailing list