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). [...]
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
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.
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/
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.
[cd menu]
We don't need a highlighted bar that can be moved with arrow keys
or mouse protcool support or anything.
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/
- 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.
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.)
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.
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.
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
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 498 |
Nodes: | 16 (2 / 14) |
Uptime: | 49:20:18 |
Calls: | 9,808 |
Calls today: | 10 |
Files: | 13,754 |
Messages: | 6,190,179 |