help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

cdlog: alternative to using the pushd stuff.


From: Kaz Kylheku
Subject: cdlog: alternative to using the pushd stuff.
Date: Thu, 18 Jan 2024 18:41:36 -0800
User-agent: Roundcube Webmail/1.4.15

Hi all,

I came up with a very simple, ergonomic system for recording directories
where you "cd" to, and reference them.

This shows we don't need dedicated code in the shell executable to
have this kind of feature.

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

Summary:

- A 9 element FIFO log is maintained of recent directories.
- This is stored in variables c1 through c9.
- Registers c1 to c4 are also known as x, y, z, w.
- The cd alias pushes new item through these registers.
- Except when you cd to "$c1": then you get swapping behavior.
- The "cs" alias does the above swap
- The "pd" (pop dir) alias changes to "$c1", deleting it
  from the log.
- The command cdlog lists contents of c1 through c4.

Variables enjoy good tab completion; better than ~-n syntax:

- $x is shorter than ~-1
- $x[Tab] will complete the slash for you. (~-1[Tab] will not).
- with direxpand enabled, $x/[Tab] will expand the variable contents.
  (~-1/[Tab] will not). 
- Variables can be exported, so a subshell easily sees the stack.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]