Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

"I have not the slightest confidence in 'spiritual manifestations.'" -- Robert G. Ingersoll


devel / comp.unix.shell / mini-project: cdlog.

SubjectAuthor
* mini-project: cdlog.Kaz Kylheku
+* Re: mini-project: cdlog.Janis Papanagnou
|`* Re: mini-project: cdlog.Janis Papanagnou
| `* Re: mini-project: cdlog.Kaz Kylheku
|  +- Re: mini-project: cdlog.Kaz Kylheku
|  `- Re: mini-project: cdlog.Janis Papanagnou
+- Re: mini-project: cdlog.Julieta Shem
+* Re: mini-project: cdlog.Kaz Kylheku
|`* Re: mini-project: cdlog.Janis Papanagnou
| `* Re: mini-project: cdlog.Kaz Kylheku
|  +- Re: mini-project: cdlog.Kaz Kylheku
|  `- Re: mini-project: cdlog.Janis Papanagnou
`- Re: mini-project: cdlog.Kaz Kylheku

1
mini-project: cdlog.

<20240125135917.811@kylheku.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7615&group=comp.unix.shell#7615

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!rocksolid2!news.neodome.net!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 433-929-6894@kylheku.com (Kaz Kylheku)
Newsgroups: comp.unix.shell
Subject: mini-project: cdlog.
Date: Thu, 25 Jan 2024 22:26:01 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 30
Message-ID: <20240125135917.811@kylheku.com>
Injection-Date: Thu, 25 Jan 2024 22:26:01 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="64d741b4aedd1f2c9b80077e3ef47e46";
logging-data="2622261"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+v1tEbCpMIbUTSfrLBWhYuzIv++KWnLyM="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:3MBsYLKClvlP4YBLhEpEZGh2hcs=
 by: Kaz Kylheku - Thu, 25 Jan 2024 22:26 UTC

You know how Bash has that directory stack feature: pushd, popd, dirs.

I used that for a couple of decades on and off but never fully warmed
fup to it.

Recently I made an alternative system.

https://www.kylheku.com/cgit/cdlog/about/

- The cd alias always pushes the current directory, into a
9 element FIFO.

- FIFO is available as $c1, $c2, ... $c9.

- First four entries also as $x, $y, $z and $w: two character
referencing.

- pd command pops back from FIFO: changes to $c1 and removes it.

- cs command switches (or rotates through explicitly specified elems):
- cs 2 # exchange: current <--> c2
- cs 2 4 # rotate: current <--- c2 <--- c4
# `--------------^

- cl lists first four FIFO entries

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Re: mini-project: cdlog.

<uour0o$2gj2j$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7616&group=comp.unix.shell#7616

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!rocksolid2!news.neodome.net!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: mini-project: cdlog.
Date: Fri, 26 Jan 2024 00:31:35 +0100
Organization: A noiseless patient Spider
Lines: 49
Message-ID: <uour0o$2gj2j$1@dont-email.me>
References: <20240125135917.811@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 25 Jan 2024 23:31:36 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="5f313c2ddb3d78962b0536ef126cc20d";
logging-data="2640979"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+8cm1jfeGrhHfDrOUOGNzU"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:EB7rk8JVjDmbqUZHlvtITg38Mio=
X-Enigmail-Draft-Status: N1110
In-Reply-To: <20240125135917.811@kylheku.com>
 by: Janis Papanagnou - Thu, 25 Jan 2024 23:31 UTC

On 25.01.2024 23:26, Kaz Kylheku wrote:
> You know how Bash has that directory stack feature: pushd, popd, dirs.

(Probably the ones that were inherited from Csh.)

>
> I used that for a couple of decades on and off but never fully warmed
> fup to it.

Understandably.

>
> Recently I made an alternative system.
>
> https://www.kylheku.com/cgit/cdlog/about/
>
> - The cd alias always pushes the current directory, into a
> 9 element FIFO.

A FIFO, not a stack?

>
> - FIFO is available as $c1, $c2, ... $c9.
>
> - First four entries also as $x, $y, $z and $w: two character
> referencing.
>
> - pd command pops back from FIFO: changes to $c1 and removes it.
>
> - cs command switches (or rotates through explicitly specified elems):
> - cs 2 # exchange: current <--> c2
> - cs 2 4 # rotate: current <--- c2 <--- c4
> # `--------------^
>
> - cl lists first four FIFO entries

The Kornshell book provides two versions for such additional 'cd'
functionality (as ksh code). One of it supports also a menu based
'mcd' (that works on the built up directory stack). I think it's
a very useful function. (Maybe a sensible extension for your lib?)
(A slight problem for some folks may be that it uses the same name
as "mcd(1) - change MSDOS directory".)

BTW, I noticed that the functions are provided by my Linux systems,
the 'mcd' can be found in file /usr/share/ksh/functions/dirs (so
no need to copy/paste the source from the book.).

Janis

Re: mini-project: cdlog.

<uour72$2gk03$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7617&group=comp.unix.shell#7617

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!rocksolid2!news.neodome.net!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: mini-project: cdlog.
Date: Fri, 26 Jan 2024 00:34:57 +0100
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <uour72$2gk03$1@dont-email.me>
References: <20240125135917.811@kylheku.com> <uour0o$2gj2j$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 25 Jan 2024 23:34:58 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="5f313c2ddb3d78962b0536ef126cc20d";
logging-data="2641923"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Jga/00RBsBlX9cXogc4xP"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:t8TSmgK9pmbnhTgh6pncwmY4eDc=
In-Reply-To: <uour0o$2gj2j$1@dont-email.me>
 by: Janis Papanagnou - Thu, 25 Jan 2024 23:34 UTC

On 26.01.2024 00:31, Janis Papanagnou wrote:
> On 25.01.2024 23:26, Kaz Kylheku wrote:
>> You know how Bash has that directory stack feature: pushd, popd, dirs.
>
> (Probably the ones that were inherited from Csh.)
>
>>[...]
>
> The Kornshell book provides two versions for such additional 'cd'
> functionality (as ksh code). [...]

That formulation may have been misleading. I meant not your logic but
the Csh one mentioned above, and one with the 'mcd' menu extension.

Janis

Re: mini-project: cdlog.

<20240125160121.326@kylheku.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7618&group=comp.unix.shell#7618

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!rocksolid2!news.neodome.net!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 433-929-6894@kylheku.com (Kaz Kylheku)
Newsgroups: comp.unix.shell
Subject: Re: mini-project: cdlog.
Date: Fri, 26 Jan 2024 00:03:05 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <20240125160121.326@kylheku.com>
References: <20240125135917.811@kylheku.com> <uour0o$2gj2j$1@dont-email.me>
<uour72$2gk03$1@dont-email.me>
Injection-Date: Fri, 26 Jan 2024 00:03:05 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="96ca4eb75b4703d7855e1ee0c9e2d747";
logging-data="2645974"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19vWAdoVvqjnit+xDPlMT8sK9ktnWdSZYc="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:JvtVSjSfLotabJC2nCtuRoqWS50=
 by: Kaz Kylheku - Fri, 26 Jan 2024 00:03 UTC

On 2024-01-25, Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
> On 26.01.2024 00:31, Janis Papanagnou wrote:
>> On 25.01.2024 23:26, Kaz Kylheku wrote:
>>> You know how Bash has that directory stack feature: pushd, popd, dirs.
>>
>> (Probably the ones that were inherited from Csh.)
>>
>>>[...]
>>
>> The Kornshell book provides two versions for such additional 'cd'
>> functionality (as ksh code). [...]
>
> That formulation may have been misleading. I meant not your logic but
> the Csh one mentioned above, and one with the 'mcd' menu extension.

A simple mcd could just print out the directories (either the most
recent 4 or all 9), and let the user pick by number. Then, when
the selection is made, jump back to the start of the first line of the
output, and "clear to end of screen" using the right ANSI escape.

We don't need a highlighted bar that can be moved with arrow keys
or mouse protcool support or anything.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Re: mini-project: cdlog.

<87il3hc5n6.fsf@yaxenu.org>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7619&group=comp.unix.shell#7619

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!nntp.comgw.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: jshem@yaxenu.org (Julieta Shem)
Newsgroups: comp.unix.shell
Subject: Re: mini-project: cdlog.
Date: Thu, 25 Jan 2024 21:14:37 -0300
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <87il3hc5n6.fsf@yaxenu.org>
References: <20240125135917.811@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="eb4a46808ad66f84147b74186054ce59";
logging-data="2650688"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+u4wZJcUQdKFGz+iCmRTFxkAaiG0FdDOo="
Cancel-Lock: sha1:AcjDxkwZ2MgtP5WNl63ZwhGqAN0=
sha1:uDGojxLTY3QCVstZwSvMeBu88CQ=
 by: Julieta Shem - Fri, 26 Jan 2024 00:14 UTC

Kaz Kylheku <433-929-6894@kylheku.com> writes:

> You know how Bash has that directory stack feature: pushd, popd, dirs.
>
> I used that for a couple of decades on and off but never fully warmed
> fup to it.
>
> Recently I made an alternative system.
>
> https://www.kylheku.com/cgit/cdlog/about/

That's nice. The shell I use the most is ESHELL. I couldn't take
advantage of your cdlog. ESHELL has a cd- feature. I never stopped to
understand it. I inferred that cd = means list the directories. Then
cd-<integer> sets the shell to that directory.

%cd =
0: c:/whatever/somewhere0
1: c:/whatever/somewhere1
2: c:/whatever/somewhere2
[...]
29: c:/whatever/somewhere29

%cd -29

%pwd
c:/whatever/somewhere29

Re: mini-project: cdlog.

<20240125165231.427@kylheku.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7620&group=comp.unix.shell#7620

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 433-929-6894@kylheku.com (Kaz Kylheku)
Newsgroups: comp.unix.shell
Subject: Re: mini-project: cdlog.
Date: Fri, 26 Jan 2024 00:53:19 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <20240125165231.427@kylheku.com>
References: <20240125135917.811@kylheku.com> <uour0o$2gj2j$1@dont-email.me>
<uour72$2gk03$1@dont-email.me> <20240125160121.326@kylheku.com>
Injection-Date: Fri, 26 Jan 2024 00:53:19 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="96ca4eb75b4703d7855e1ee0c9e2d747";
logging-data="2661474"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18KK3Wltp5F9j5k9QeImsjlD7EQFStYy7w="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:m4Hbu4ZcJsptfcfEoHGRIvzHOR4=
 by: Kaz Kylheku - Fri, 26 Jan 2024 00:53 UTC

On 2024-01-26, Kaz Kylheku <433-929-6894@kylheku.com> wrote:
> A simple mcd could just print out the directories (either the most
> recent 4 or all 9), and let the user pick by number. Then, when
> the selection is made, jump back to the start of the first line of the
> output, and "clear to end of screen" using the right ANSI escape.
>
> We don't need a highlighted bar that can be moved with arrow keys
> or mouse protcool support or anything.

I shipped the feature. mcs lets you swap the current directory with
one from the menu. mcd will change to it, and push the current into
the FIFO.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Re: mini-project: cdlog.

<uov279$2hh8n$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7621&group=comp.unix.shell#7621

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: mini-project: cdlog.
Date: Fri, 26 Jan 2024 02:34:33 +0100
Organization: A noiseless patient Spider
Lines: 10
Message-ID: <uov279$2hh8n$1@dont-email.me>
References: <20240125135917.811@kylheku.com> <uour0o$2gj2j$1@dont-email.me>
<uour72$2gk03$1@dont-email.me> <20240125160121.326@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 26 Jan 2024 01:34:33 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="5f313c2ddb3d78962b0536ef126cc20d";
logging-data="2671895"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+LWMbNo36H8cuextYEh0/k"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:/mkM9T1/Rlf//rh9o74p0NpYAM4=
In-Reply-To: <20240125160121.326@kylheku.com>
 by: Janis Papanagnou - Fri, 26 Jan 2024 01:34 UTC

On 26.01.2024 01:03, Kaz Kylheku wrote:
> [cd menu]
>
> We don't need a highlighted bar that can be moved with arrow keys
> or mouse protcool support or anything.

I didn't expect (nor wanted) such fancy stuff. :-)

Janis

Re: mini-project: cdlog.

<20240208131716.155@kylheku.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7622&group=comp.unix.shell#7622

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 433-929-6894@kylheku.com (Kaz Kylheku)
Newsgroups: comp.unix.shell
Subject: Re: mini-project: cdlog.
Date: Thu, 8 Feb 2024 21:21:24 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <20240208131716.155@kylheku.com>
References: <20240125135917.811@kylheku.com>
Injection-Date: Thu, 8 Feb 2024 21:21:24 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="163263dc92baed57fd9aed84cf1a8c15";
logging-data="2254376"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+2Ns4gUVtxv+cxwufR4iqi89FfruxMHvs="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:7K5cVN7VfLjeKfNFA5j5YxXfGcw=
 by: Kaz Kylheku - Thu, 8 Feb 2024 21:21 UTC

On 2024-01-25, Kaz Kylheku <433-929-6894@kylheku.com> wrote:
> You know how Bash has that directory stack feature: pushd, popd, dirs.
>
> I used that for a couple of decades on and off but never fully warmed
> fup to it.
>
> Recently I made an alternative system.
>
> https://www.kylheku.com/cgit/cdlog/about/

I've extended cdlog here and there.

- It has the menu selection we talked about, in the form of
mcd and mcs commands. When you umake a menu selection, the
menu is erased from the screen and the cursor retraces.

- pd (pop directory) can take a number to pop from that point
rather than the top (delete that entry and change to it).

- cll (cd log long) lists all nine entries, unlike cl.

- peristence: whenever the state changes, the current working
directory and the 9 element FIFO are saved to ~/.cdlog.dirs.
On startup, this state is recovered.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Re: mini-project: cdlog.

<uq3ok4$276iq$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7623&group=comp.unix.shell#7623

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: mini-project: cdlog.
Date: Fri, 9 Feb 2024 00:37:39 +0100
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <uq3ok4$276iq$1@dont-email.me>
References: <20240125135917.811@kylheku.com> <20240208131716.155@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 8 Feb 2024 23:37:40 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="d5ab79ea28b8917e965d428c55bcd1e4";
logging-data="2333274"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+0sEiNEeL23TJxSz9CGLip"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:Cy8P7PoGM5NLactpLgP1CZYyZkU=
In-Reply-To: <20240208131716.155@kylheku.com>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Thu, 8 Feb 2024 23:37 UTC

On 08.02.2024 22:21, Kaz Kylheku wrote:
>
> - peristence: whenever the state changes, the current working
> directory and the 9 element FIFO are saved to ~/.cdlog.dirs.
> On startup, this state is recovered.

Is it possible to have or define individual .cdlog.dirs files?

(I'm asking because I'm using shell functions to persist the
current working directory _for each terminal instance_, so that
on reopening of any terminal I am again in the same tty specific
working directory context.)

Janis

Re: mini-project: cdlog.

<20240208161302.701@kylheku.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7624&group=comp.unix.shell#7624

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!news.hispagatos.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 433-929-6894@kylheku.com (Kaz Kylheku)
Newsgroups: comp.unix.shell
Subject: Re: mini-project: cdlog.
Date: Fri, 9 Feb 2024 00:17:51 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 31
Message-ID: <20240208161302.701@kylheku.com>
References: <20240125135917.811@kylheku.com>
<20240208131716.155@kylheku.com> <uq3ok4$276iq$1@dont-email.me>
Injection-Date: Fri, 9 Feb 2024 00:17:51 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="f0d9c4d56e1bf3d087a60d362bc7520c";
logging-data="2357374"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/NLiXApHqezs/iYPOqGwBlD/xbIgsiHPI="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:GrLiwUqy1GX1I06hg7qVmTqS5eU=
 by: Kaz Kylheku - Fri, 9 Feb 2024 00:17 UTC

On 2024-02-08, Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
> On 08.02.2024 22:21, Kaz Kylheku wrote:
>>
>> - peristence: whenever the state changes, the current working
>> directory and the 9 element FIFO are saved to ~/.cdlog.dirs.
>> On startup, this state is recovered.
>
> Is it possible to have or define individual .cdlog.dirs files?

Well, yes; just a good set of requirement have to be identified
for that.

> (I'm asking because I'm using shell functions to persist the
> current working directory _for each terminal instance_, so that
> on reopening of any terminal I am again in the same tty specific
> working directory context.)

If you just have one session and bail out, and log in on a different
tty, then what?

One way is to have recovery workflow. Show the user what saved contexts
exist, including the date when they were saved, and let them pick the
one to use.

These contexts could be in some LRU list, so they don't proliferate.
If there are eight, the oldest one is deleted.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Re: mini-project: cdlog.

<20240208165753.811@kylheku.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7625&group=comp.unix.shell#7625

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 433-929-6894@kylheku.com (Kaz Kylheku)
Newsgroups: comp.unix.shell
Subject: Re: mini-project: cdlog.
Date: Fri, 9 Feb 2024 01:01:26 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 79
Message-ID: <20240208165753.811@kylheku.com>
References: <20240125135917.811@kylheku.com>
<20240208131716.155@kylheku.com> <uq3ok4$276iq$1@dont-email.me>
<20240208161302.701@kylheku.com>
Injection-Date: Fri, 9 Feb 2024 01:01:26 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="f0d9c4d56e1bf3d087a60d362bc7520c";
logging-data="2387820"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/xaRL1eKGKBb/pu3v4ipe647dJqdGgAHE="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:0gVN0MaLlwymCi8MtRAnU6jePuk=
 by: Kaz Kylheku - Fri, 9 Feb 2024 01:01 UTC

On 2024-02-09, Kaz Kylheku <433-929-6894@kylheku.com> wrote:
> On 2024-02-08, Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
>> On 08.02.2024 22:21, Kaz Kylheku wrote:
>>>
>>> - peristence: whenever the state changes, the current working
>>> directory and the 9 element FIFO are saved to ~/.cdlog.dirs.
>>> On startup, this state is recovered.
>>
>> Is it possible to have or define individual .cdlog.dirs files?
>
> Well, yes; just a good set of requirement have to be identified
> for that.
>
>> (I'm asking because I'm using shell functions to persist the
>> current working directory _for each terminal instance_, so that
>> on reopening of any terminal I am again in the same tty specific
>> working directory context.)
>
> If you just have one session and bail out, and log in on a different
> tty, then what?
>
> One way is to have recovery workflow. Show the user what saved contexts
> exist, including the date when they were saved, and let them pick the
> one to use.

I have it prototyped:

Example of choosing a context:

$ bash
These cdlog contexts exist:
[1]: Thu Feb 8 16:49:41 PST 2024
/home/kaz
/home/kaz/cdlog
[2]: Thu Feb 8 16:56:58 PST 2024
/home/kaz/junk
/home/kaz/cdlog
Make a selection or press Enter for new context: 2
$ pwd
/home/kaz/junk
$ cl
1: /home/kaz/cdlog
2:
3:
4:

We picked 2. And so it changd to the /home/kaz/junk directory (first
line of the file), and stuffed the rest of the file into the cdlog FIFO.

Example of creating a new context:

$ bash
These cdlog contexts exist:
[1]: Thu Feb 8 16:49:41 PST 2024
/home/kaz
/home/kaz/cdlog
[2]: Thu Feb 8 16:57:17 PST 2024
/home/kaz/junk
/home/kaz/cdlog
Make a selection or press Enter for new context:
$ echo $cdlog_dirs
/home/kaz/.cdlog.3.dirs
$ cl
1:
2:
3:
4:
$

The $cdlog_dirs variable shows us it is assigned the 3 slot,
namely ~/.cdlog.3.dirs.

When the slots fill up, the initialization code will find the oldest one
and nuke it, then use that number. (Code not yet tested.)

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Re: mini-project: cdlog.

<uq4kd8$2hfti$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7626&group=comp.unix.shell#7626

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: mini-project: cdlog.
Date: Fri, 9 Feb 2024 08:31:51 +0100
Organization: A noiseless patient Spider
Lines: 61
Message-ID: <uq4kd8$2hfti$1@dont-email.me>
References: <20240125135917.811@kylheku.com> <20240208131716.155@kylheku.com>
<uq3ok4$276iq$1@dont-email.me> <20240208161302.701@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 9 Feb 2024 07:31:52 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="d5ab79ea28b8917e965d428c55bcd1e4";
logging-data="2670514"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19ZnlfvDO+MiFcRj7LCOBVs"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:QkuYnoXF99a6qTrWoiGmiNcVY+Y=
X-Enigmail-Draft-Status: N1110
In-Reply-To: <20240208161302.701@kylheku.com>
 by: Janis Papanagnou - Fri, 9 Feb 2024 07:31 UTC

On 09.02.2024 01:17, Kaz Kylheku wrote:
> On 2024-02-08, Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
>> On 08.02.2024 22:21, Kaz Kylheku wrote:
>>>
>>> - peristence: whenever the state changes, the current working
>>> directory and the 9 element FIFO are saved to ~/.cdlog.dirs.
>>> On startup, this state is recovered.
>>
>> Is it possible to have or define individual .cdlog.dirs files?
>
> Well, yes; just a good set of requirement have to be identified
> for that.

Yes, there's various behaviors that people might expects. Below
are mine described. (It's coupled to the tty device number, as
I've similarly set up my shell history files to depend on the tty
number. - Other folks may certainly have differing requirements.)

>
>> (I'm asking because I'm using shell functions to persist the
>> current working directory _for each terminal instance_, so that
>> on reopening of any terminal I am again in the same tty specific
>> working directory context.)
>
> If you just have one session and bail out, and log in on a different
> tty, then what?

In my case I memorize the cd context for each shell with own tty.
That means a new shell instance in the same tty will initially
operate on the same directory. If I close a shell terminal and
then open a new one it gets the same tty device number assigned
and thus the same (previous) working directory for that shell.
I couple the dot-file it with the terminal tty info from tty(1)
On a 'cd' I do pwd > "${HOME}/.sh_pwdstat_${TTYNR}" that gets
reloaded when a new shell is initialized. (There's a rare hangup
case I've observed that a shell plus its window gets closed but
the tty is still connected to the closed (zombie?) shell; here I
have to identify and kill the invisible shell process explicitly
so that the device number can be reassigned). But normally the
previous context is available (as desired by me) in the reopened
shell.

>
> One way is to have recovery workflow. Show the user what saved contexts
> exist, including the date when they were saved, and let them pick the
> one to use.

This is a grade of flexibility that is (for me) unnecessary (it
may be even a burden to see a menu). I'm not (not yet) using a
cd stack. But if so I'd certainly also couple it (like history
and the last working cd path) also to the tty; I'd probably just
extend my .sh_pwdstat_${TTYNR} to carry the stack of paths like
you've done in your .cdlog.dirs file.

>
> These contexts could be in some LRU list, so they don't proliferate.
> If there are eight, the oldest one is deleted.
>

Janis

Re: mini-project: cdlog.

<20240223135614.787@kylheku.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7627&group=comp.unix.shell#7627

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 433-929-6894@kylheku.com (Kaz Kylheku)
Newsgroups: comp.unix.shell
Subject: Re: mini-project: cdlog.
Date: Fri, 23 Feb 2024 22:04:20 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 67
Message-ID: <20240223135614.787@kylheku.com>
References: <20240125135917.811@kylheku.com>
Injection-Date: Fri, 23 Feb 2024 22:04:20 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="9d5cee93c573fc14a95e5eba1e4378c6";
logging-data="820387"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/u/vbHwUZuscR8hGP62FEoWEPKkGN1kZo="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:/rvT2x9JL3Nt6lweVcUFibaTPJg=
 by: Kaz Kylheku - Fri, 23 Feb 2024 22:04 UTC

On 2024-01-25, Kaz Kylheku <433-929-6894@kylheku.com> wrote:
> You know how Bash has that directory stack feature: pushd, popd, dirs.
>
> I used that for a couple of decades on and off but never fully warmed
> fup to it.
>
> Recently I made an alternative system.
>
> https://www.kylheku.com/cgit/cdlog/about/
>
> - The cd alias always pushes the current directory, into a
> 9 element FIFO.
>
> - FIFO is available as $c1, $c2, ... $c9.
>
> - First four entries also as $x, $y, $z and $w: two character
> referencing.
>
> - pd command pops back from FIFO: changes to $c1 and removes it.
>
> - cs command switches (or rotates through explicitly specified elems):
> - cs 2 # exchange: current <--> c2
> - cs 2 4 # rotate: current <--- c2 <--- c4
> # `--------------^
>
> - cl lists first four FIFO entries

cdlog now has these features:

- session recovery:
- on startup, a new session is always allocated (lowest available #)
- session recovery is now unobtrusive. On startup, an informational
message is produced advising of the existence of prior sessions,
and the use of the "cdr" (cdlog recover) command.
- user can switch to an existing session, or clone the session's
content into the current one.

- mcd: change to a FIFO entry by menu

- mcs: swap with a FIFO entry by menu

- LRU mode: (enabled by cdlog_lru variable):
- when you cd to a directory that is already in the FIFO, that FIFO
entry is deleted, so effectively a rotation takes place: e.g

PWD: /foo/bar -> cd /def -> /def

FIFO: /abc /foo/bar
/def /abc
/ghi /ghi
previous current dir /foo/bar is pushed into FIFO, but the
matching /def is removed, so the FIFO acts as a LRU cache.
The oldest entry is only evicted when there is a miss.

- cd aliases:
- using cdalias X Y you can define aliases you can use with "cd".
this is a nice alternative to using CDPATH.

- tab completion
- custom tab completion for "cd" completes the above cd aliases,
and also paths, and directories in CDPATH.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor