aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* cdunalias: improve test for undefined alias.HEADmasterKaz Kylheku2025-02-211-1/+1
| | | | | | * cdlog.sh (cdlog.unalias); Improve the test for undefined alias, which is wrongly treating empty as undefined.
* cdalias: take zero, one or two args.Kaz Kylheku2025-02-202-6/+31
| | | | | | | | | * cdlog.sh (cdlog.alias): Behave like cdlog.aliases in the zero argument case, and in the one argument case list the specified alias, if it exists. * README.md: Updated. The cdaliases command becomes deprecated.
* Issue successful status out of cdlog.recover.Kaz Kylheku2025-02-121-0/+1
| | | | | | * cdlog.sh (cdlog.recover): return 0, because the [ $print ] test in the previous line can fail, leaving the function with a failed termination status.
* New feature: auto recovery.Kaz Kylheku2025-02-042-4/+42
| | | | | | | | | | | | * README.md: Describe the cdlog_autorecovery variable. * cdlog.sh (cdlog_autorecover): New variable. (cdlog.init): When there is only one saved session, then call cdlog.recover with the secret new __auto argument. (cdlog.recover): When there is only one saved session and the __auto argument has been given, then make the selection 1 for the user. In this case we print the current working directory.
* README: numerous changes upon careful proof-reading.Kaz Kylheku2025-01-261-23/+29
|
* README: no longer just three commands.Kaz Kylheku2025-01-261-1/+1
|
* Make the directory holding session files configurableKaz Kylheku2025-01-142-8/+29
| | | | | | | | | | | * cdlog.sh (cdlog_sess_dir): New variable. (cdlog.init, cdlog.recover): Create the session directory, if necessary. Interpolate the variable into all the places where we previously referenced the home directory ~. In cdlog.recover print that directory so the user knows where the sessions are coming from. * README.md: Documented.
* Add n command to cdr.Kaz Kylheku2025-01-142-5/+15
| | | | | | | | | * cdlog.sh (cdlog.init): Keep the identity of the freshly allocated session in the variable cdlog_new_dirs. (cdlog.recover): Allow the user to use 'n' to select the newly allocated session. * README.md: Documented.
* Copyright year bump to 2025.Kaz Kylheku2025-01-011-1/+1
|
* Bail if not interactive.Kaz Kylheku2024-12-191-0/+3
| | | | | * cdlog.sh (mainline): If Bash is not interactive, then we exit from the script.
* bug: cd history not working when not in cdlog_lru mode.Kaz Kylheku2024-12-171-2/+2
| | | | | | * cdlog.sh (cdlog.chdir): The loop which shifts entries into the log must terminate at 1 not 2. The loop body must expand the d[] variable properly.
* once more: fix broken cd when cdlog_lru is not enabledKaz Kylheku2024-12-161-1/+1
| | | | | | * cdlog.sh (cdlog.chdir): Remove stray character after array index expansion syntax, in the case when we don't have cdlog_lru.
* fix broken cd when cdlog_lru is not enabled.Kaz Kylheku2024-12-111-1/+1
| | | | | * cdlog.sh (cdlog.chdir): Fix bad array index expansion syntax in the case when we don't have cdlog_lru.
* Add c command for lookup.Kaz Kylheku2024-04-102-0/+29
| | | | | | | * cdlog.sh (cdlog.lookup): new function. (c): New alias. * README.md: Documented.
* Allow cdalias by number or @ search.Kaz Kylheku2024-04-102-2/+30
| | | | | | | | * cdlog.sh (cdlog.alias): Remove unused local variable ali. Check for a digit or argument starting with @ and expand accordingly, checking for failure. * README.md: Documented.
* New: search feature.Kaz Kylheku2024-04-102-27/+109
| | | | | | | | * cdlog.sh (cdlog.at2index, cdlog.at2path): New functions. (cdlog.chdir, cdlog.rot, cdlog.mcd): Support searches as way of specifying the target path or entry. * README.md: Document searches.
* cd: when using alias or number, print new PWD.Kaz Kylheku2024-03-251-1/+5
| | | | | | | | | | | | | * cdlog.sh (cdlog.chdir): New local variale print indicates whether we should print the new $PWD after a successful cd. We set this when resolving a numeric argument, or cdalias. Some other commands already print. The purpose of this to leave a visible trail in the terminal confirming where the directory was change, for those users who don't have the directory in the shell prompt. Note that "cd -" in Bash has this behavior built in: it prints the path, for the same reason we are doing.
* cdr: indicate the current context.Kaz Kylheku2024-03-141-4/+6
| | | | | * cdlog.sh (cdlog.recover): Indicate the current context with the string [current].
* cdr: delete unwanted contexts with d prefix.Kaz Kylheku2024-03-142-2/+11
| | | | | | | * cdlog.sh (cdlog.recover): Support d prefix. We only mention it in the prompt if there are two or more contexts. * README.md: Documented.
* cd: support 1-9 argument, like mcd.Kaz Kylheku2024-03-142-4/+8
| | | | | | | | | * cdlog.sh (cdlog.chdir): Check for the directory argument being a value 1 to 9, and substitue the indicated cdlog_hist entry. * README.md: Document. Also correct reference to cdlog_fifo which should be cdlog_hist.
* pd: implement -f option.Kaz Kylheku2024-03-142-2/+10
| | | | | | | | | | | | Problem: when the cdlog contains a directory that cannot be entered, for instance due to not existing any more, we would like to delete it with "pd", but cannot. * cdlog.sh (cdlog.pop): Implement -f (force) option which will ignore the failing cd command and delete the entry anyway. Fix typo in header comment. * README.md: Mention -f in description of `pd` alias.
* Commands for listing and deleting cd aliases.Kaz Kylheku2024-03-072-0/+33
| | | | | | | | * cdlog.sh (cdlog.alias): Check against empty alias name. (cdlog.aliases, cdlog.unalias): New functions. (cdaliases, cdunalias): New aliases. * README.md: Documented.
* completion: set nospace option.Kaz Kylheku2024-03-061-0/+2
| | | | | | | | * cdlog.sh (cdlog.complete): Set compopt -o nospace so that the completion doesn't automatically add a space. That's what we want when completing directories for cd. It's annoying to have to backspace over a space to continue completion.
* Bugfix: handle empty argument in cdlog.chdir.Kaz Kylheku2024-02-251-1/+4
| | | | | * cdlog.sh (cdlog.chdir): Do not treat an empty argument as a valid alias. In that case just return.
* Allow unlimited internal history.Kaz Kylheku2024-02-252-41/+35
| | | | | | | | | | | | | | | | * cdlog.sh (cdlog_fifo): Renamed to cdlog_hist. * README.md: All references to FIFO replaced with "history". Claims that the FIFO is nine elements long are removed. (cdlog.update): Save the entire array, not relying on the nine $c1 through $c9 variables. (cdlog.init): Reinitialize by deleting the elements of the cdlog_hist array. (cdlog.recover): Print only up to 10 entries from the files. (cdlog.chdir): Remove array limits; let it grow. (cdlog.pop): Pop the entire array, not just nine entries. Unset the array entry rather than blanking it.
* Use global array for FIFO.Kaz Kylheku2024-02-252-44/+43
| | | | | | | | | | | | | | | | | | | | | | | The $c1 to $c9 variables are now just derived items. * cdlog.sh (cdlog_fifo): New array variable. (cdlog.args): Now all this function does is copy from the array to the short variables. (cdlog.update): Now calls cdlog.args to copy ${cdlog_fifo[@]} to $c1 to $c9. (cdlog.init): Initialize dclog_fifo via ${d[]} alias, and call cdlog.args to also init the short variables. (cdlog.recover): Map from file directly into cdlog_fifo array, and call cdlog.update instead of cdlog.args. (cdlog.chdir, cdlog.rot, cdlog.pop): Local array d is alias for cdlog_fifo. Use cdlog.update instead of cdlog.args. (cdlog.mcd): Local array d is alias for cdlog_fifo. * README.md: Don't say that the FIFO is stored in variables c1 through c9 but in in the cdlog_fifo array. The variables are now for convenience only.
* Add tab completion for cd aliases.Kaz Kylheku2024-02-232-0/+35
| | | | | | | | | * README.md: Documented. * cdlog.sh (cdlog.complete): Completion function that completes on directories, including CDPATH, as well as cdlog's cd aliases. (toplevel): Register the completion function.
* New, LRU mode; better than removed autocs feature.Kaz Kylheku2024-02-232-6/+45
| | | | | | | | | * cdlog.sh (cdlog_lru): New Boolean configuration variable, blank/false by default. (cdlog.chdir): If cdlog_lru is true, perform the rotation through to the most recent occurrence of the new directory. * README.md: Documented.
* Revert "Implement autocs mode."Kaz Kylheku2024-02-232-27/+0
| | | | This reverts commit efcc4b981d2a10ac3b10522c596f8bf9ddff6ff9.
* New cd alias feature.Kaz Kylheku2024-02-232-2/+48
| | | | | | | | | * cdlog.sh (cdlog_alias): New global array. * README.md: Documented. (cdlog.chdir): Check for and expand alias. (cdlog.alias): New function. (cdalias): New alias.
* Implement autocs mode.Kaz Kylheku2024-02-222-0/+29
| | | | | | | | | | | * cdlog.sh (cdlog_autocs): New variable. (cdlog.chdir): Implement autocs logic, if enabled. (cdlog.mcd): Use Bash dynamic scoping to override the cdlog_autocs variable false; we don't want mcd to have swapping semantics regardless of autocs mode; the user must use the distinct command mcs. * README.md: Documented.
* bug: path 8 duplicated into 9.Kaz Kylheku2024-02-131-1/+1
| | | | * cdlog.sh (cdlog.args): c9 wrongly assigned $8.
* Split off recovery from initialization.Kaz Kylheku2024-02-132-8/+24
| | | | | | | | | | | | | | Prompting the user on startup can be a nuisance. For instance, each time I make a new shell out of a text editor, I get the prompt. Let's just leave the user in a new context, and make it an explicit command to switch context. * cdlog.sh (cdlog.init): Remove logic for selecting a new context, leaving only the allocation of a new context. (cdlog.recover): New function, split off from cdlog.init. (cdr): New alias. * README.md: Documented.
* Implement context cloning.Kaz Kylheku2024-02-081-3/+15
| | | | | | | | | | The user can copy a given context into the newly allocated one, rather than switch to a given context. * cdlog.sh (cdlog.init): Allow the user to input a context number prefixed by c. In that case, we copy the specified context file into the $cdlog_dirs file, leaving that variable alone.
* bugfix: don't let user select invalid context number.Kaz Kylheku2024-02-081-1/+2
| | | | | | * cdlog.sh (cdlog.get_param): Only produce output if shift succeeds. If shift fails, it means that many shifts are not possible and the parameters are unaffected.
* Implement multiple persisted sessions.Kaz Kylheku2024-02-082-9/+79
| | | | | | | | | | | * cdlog.sh (cdlog.update): Name of file is now in $cdlog_dirs. (cdlog.get_param): New function. (cdlog.init): Implement the LRU session selection and optional recovery. The variable $cdlog_dirs is established, pointing to the selected session file. (mainline): Run cdlog.init if $cdlog_dirs is empty. * README.md: Documented.
* Persist state in ~/.cdlog.dirs.Kaz Kylheku2024-02-082-14/+56
| | | | | | | | | | | | | | | | | * cdlog.sh (cdlog.nicks): Function removed. (cdlog.update): New function, performing task of cdlog.nicks as well as persistence to ~/.cdlog.dirs file. (cdlog.init): New function that initializes the c1-c9 variables. (mainline): Call cdlog.init. This is now done later in the file after the function definitions. (cdlog.args, cdlog.chdir): Call cdlog.update instead of cdlog.nicks. This is also how the variables $x to $w will be set the first time when recovering state, because cdlog.init calls cdlog.args to install the FIFO, and cdlog.args will call cdlog.update. * README.md: Documented.
* pd: support optional argument about which entry to pop.Kaz Kylheku2024-02-032-11/+28
| | | | | | | * cdlog.sh (cdlog.pop): Rewritten to take argument 1-9, and iterate from there. * README.md: Documented.
* cll command to list all nine.Kaz Kylheku2024-02-012-2/+11
| | | | | | | | * cdlog.sh (cdlog): Take -l option to print all nine directories in the FIFO. (cll): New alias, for cdlog -l. * README.md: Documented.
* Don't use global x for looping.Kaz Kylheku2024-02-011-2/+2
| | | | | | * cdlog.sh (cdlog.mcd): Oh boy; we have used our own $x variable as a loop dummy. Switch to i which is set up as local.
* mcd: scroll-region-friendly line clearing.Kaz Kylheku2024-02-011-1/+4
| | | | | | | | | * cdlog.sh (cdlog.mcd): Going up ten lines with \e[10A and then clearing to the end of screen with \e[J is unfriendly when the user has a scroll-protected region at the bottom showing a status line. Instead, let us go up one line at a time ten times with \e[A, and clear each line to end of line with \e[K.
* Use range expansion.Kaz Kylheku2024-02-011-1/+1
| | | | * cdlog.sh (cdlog.mcd): Replace 1 2 3 ... 9 with {1..9}.
* New: mcd, mcs: menu-based cd and cs.Kaz Kylheku2024-01-252-0/+43
| | | | | | | * cdlog.sh (cdlog.mcd): New function. (mcd, mcs): New aliases. * README.md: Documented.
* cdlog: simplify prefixes.Kaz Kylheku2024-01-251-5/+6
| | | | | * cdlog.sh (cdlog): Just print numeric indices before the paths.
* print new PWD in pd and cs.Kaz Kylheku2024-01-251-0/+3
| | | | | * cdlog.sh (cdlog.rot, cdlog.pop): Print new current directory if change successful.
* Add cl alias for cdlog.Kaz Kylheku2024-01-232-2/+3
|
* Improve initialization.Kaz Kylheku2024-01-191-8/+6
| | | | | | * cdlog.sh (toplevel): Ensure that c1 exists, so that the init code doesn't access a nonexistent c1. Condense the assignments in the init block.
* Reduce repeated code.Kaz Kylheku2024-01-191-13/+7
| | | | | | * cdlog.sh (cdlog.rot): Eliminate repeated code, distinguishing different parts with a flag indicating the first loop iteration.
* README update.Kaz Kylheku2024-01-191-2/+5
|
* Generalize swap to rotate.Kaz Kylheku2024-01-192-19/+33
| | | | | | | | * cdlog.sh (cdlog.swap): Function removed. (cdlog.rot): New function. (cs): Alias now points to cdlog.rot. * README.md: Updated.