Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 20 Apr 2014 20:08:50 +0200 (CEST)
From:      =?ISO-8859-1?Q?Trond_Endrest=F8l?= <Trond.Endrestol@fagskolen.gjovik.no>
To:        Polytropon <freebsd@edvax.de>
Cc:        FreeBSD Questions <freebsd-questions@freebsd.org>
Subject:   Re: History file for dialog C shell (t)csh
Message-ID:  <alpine.BSF.2.00.1404202005290.1327@mail.fig.ol.no>
In-Reply-To: <20140420194037.629437f3.freebsd@edvax.de>
References:  <20140420194037.629437f3.freebsd@edvax.de>

next in thread | previous in thread | raw e-mail | index | archive | help
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)

It saves the 200,000 last commands, and merges the new commands with 
the previously saved ones.

-- 
+-------------------------------+------------------------------------+
| Vennlig hilsen,               | Best regards,                      |
| Trond Endrestøl,              | Trond Endrestøl,                   |
| IT-ansvarlig,                 | System administrator,              |
| Fagskolen Innlandet,          | Gjøvik Technical College, Norway,  |
| tlf. mob.   952 62 567,       | Cellular...: +47 952 62 567,       |
| sentralbord 61 14 54 00.      | Switchboard: +47 61 14 54 00.      |
+-------------------------------+------------------------------------+
From owner-freebsd-questions@FreeBSD.ORG  Sun Apr 20 18:18:19 2014
Return-Path: <owner-freebsd-questions@FreeBSD.ORG>
Delivered-To: freebsd-questions@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))
 (No client certificate requested)
 by hub.freebsd.org (Postfix) with ESMTPS id EC7C3BA6
 for <freebsd-questions@freebsd.org>; Sun, 20 Apr 2014 18:18:19 +0000 (UTC)
Received: from wonkity.com (wonkity.com [67.158.26.137])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
 (Client CN "wonkity.com", Issuer "wonkity.com" (not verified))
 by mx1.freebsd.org (Postfix) with ESMTPS id EFBB71694
 for <freebsd-questions@freebsd.org>; Sun, 20 Apr 2014 18:18:18 +0000 (UTC)
Received: from wonkity.com (localhost [127.0.0.1])
 by wonkity.com (8.14.8/8.14.8) with ESMTP id s3KIGvY7002303
 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO);
 Sun, 20 Apr 2014 12:16:57 -0600 (MDT)
 (envelope-from wblock@wonkity.com)
Received: from localhost (wblock@localhost)
 by wonkity.com (8.14.8/8.14.8/Submit) with ESMTP id s3KIGtgW002300;
 Sun, 20 Apr 2014 12:16:57 -0600 (MDT)
 (envelope-from wblock@wonkity.com)
Date: Sun, 20 Apr 2014 12:16:55 -0600 (MDT)
From: Warren Block <wblock@wonkity.com>
To: =?ISO-8859-15?Q?Trond_Endrest=F8l?= <Trond.Endrestol@fagskolen.gjovik.no>
Subject: Re: History file for dialog C shell (t)csh
In-Reply-To: <alpine.BSF.2.00.1404202005290.1327@mail.fig.ol.no>
Message-ID: <alpine.BSF.2.00.1404201210410.1762@wonkity.com>
References: <20140420194037.629437f3.freebsd@edvax.de>
 <alpine.BSF.2.00.1404202005290.1327@mail.fig.ol.no>
User-Agent: Alpine 2.00 (BSF 1167 2008-08-23)
MIME-Version: 1.0
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3
 (wonkity.com [127.0.0.1]); Sun, 20 Apr 2014 12:16:57 -0600 (MDT)
Content-Type: TEXT/PLAIN; charset=iso-8859-1; format=flowed
Content-Transfer-Encoding: 8BIT
X-Content-Filtered-By: Mailman/MimeDel 2.1.17
Cc: Polytropon <freebsd@edvax.de>,
 FreeBSD Questions <freebsd-questions@freebsd.org>
X-BeenThere: freebsd-questions@freebsd.org
X-Mailman-Version: 2.1.17
Precedence: list
List-Id: User questions <freebsd-questions.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/options/freebsd-questions>, 
 <mailto:freebsd-questions-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/freebsd-questions/>;
List-Post: <mailto:freebsd-questions@freebsd.org>
List-Help: <mailto:freebsd-questions-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-questions>, 
 <mailto:freebsd-questions-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Sun, 20 Apr 2014 18:18:20 -0000

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.

> 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.

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.)
From owner-freebsd-questions@FreeBSD.ORG  Sun Apr 20 18:46:18 2014
Return-Path: <owner-freebsd-questions@FreeBSD.ORG>
Delivered-To: freebsd-questions@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))
 (No client certificate requested)
 by hub.freebsd.org (Postfix) with ESMTPS id 840A82F7
 for <freebsd-questions@freebsd.org>; Sun, 20 Apr 2014 18:46:18 +0000 (UTC)
Received: from mx02.qsc.de (mx02.qsc.de [213.148.130.14])
 (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
 (Client did not present a certificate)
 by mx1.freebsd.org (Postfix) with ESMTPS id 32C0018DA
 for <freebsd-questions@freebsd.org>; Sun, 20 Apr 2014 18:46:18 +0000 (UTC)
Received: from r56.edvax.de (port-92-195-108-40.dynamic.qsc.de [92.195.108.40])
 (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
 (No client certificate requested)
 by mx02.qsc.de (Postfix) with ESMTPS id 9F7F327685;
 Sun, 20 Apr 2014 20:46:09 +0200 (CEST)
Received: from r56.edvax.de (localhost [127.0.0.1])
 by r56.edvax.de (8.14.5/8.14.5) with SMTP id s3KIj1xO002913;
 Sun, 20 Apr 2014 20:45:01 +0200 (CEST)
 (envelope-from freebsd@edvax.de)
Date: Sun, 20 Apr 2014 20:45:01 +0200
From: Polytropon <freebsd@edvax.de>
To: Warren Block <wblock@wonkity.com>
Subject: Re: History file for dialog C shell (t)csh
Message-Id: <20140420204501.5d7d9746.freebsd@edvax.de>
In-Reply-To: <alpine.BSF.2.00.1404201210410.1762@wonkity.com>
References: <20140420194037.629437f3.freebsd@edvax.de>
 <alpine.BSF.2.00.1404202005290.1327@mail.fig.ol.no>
 <alpine.BSF.2.00.1404201210410.1762@wonkity.com>
Organization: EDVAX
X-Mailer: Sylpheed 3.1.1 (GTK+ 2.24.5; i386-portbld-freebsd8.2)
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Cc: FreeBSD Questions <freebsd-questions@freebsd.org>,
 Trond =?ISO-8859-1?Q?Endrest=F8l?= <Trond.Endrestol@fagskolen.gjovik.no>
X-BeenThere: freebsd-questions@freebsd.org
X-Mailman-Version: 2.1.17
Precedence: list
Reply-To: Polytropon <freebsd@edvax.de>
List-Id: User questions <freebsd-questions.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/options/freebsd-questions>, 
 <mailto:freebsd-questions-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/freebsd-questions/>;
List-Post: <mailto:freebsd-questions@freebsd.org>
List-Help: <mailto:freebsd-questions-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-questions>, 
 <mailto:freebsd-questions-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Sun, 20 Apr 2014 18:46:18 -0000

On Sun, 20 Apr 2014 12:16:55 -0600 (MDT), Warren Block wrote:
> On Sun, 20 Apr 2014, Trond Endrest=F8l wrote:
>=20
> > 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 =3D 200000
> > set savehist =3D (200000 merge)
>=20
> The merged history is shared by all new shells.  It would not be hard to=
=20
> load or save particular history files based on a variable, then set the=20
> terminal title to a name.  That name would have to be preset somehow,=20
> though... like different icons or key commands to start the different=20
> 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.
>=20
> 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=
=20
> as part of the prompt, so that each session shares the history=20
> 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 =3D '<something>'") if this should be needed.



--=20
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?alpine.BSF.2.00.1404202005290.1327>