Development-related notes, not really a CHANGELOG.
The goal of this project is to deepen my understanding of shell scripting, specifically Bash and Zsh, by building something useful. While I recognize there are excellent existing solutions for directory navigation, this project serves as a creative opportunity to experiment and learn.
Maybe I'll get around to learning POSIX-compliant scripting for portability later.
- Features:
_UP_EXCLUDED_PATHSenvironment variable that defines an array of exact paths to exclude from history log. - Other: Feature complete, minus minor changes such as adding
_UP_PAGERenvironment variable.
- Refactoring: Changed sub-function names from
up::and_up::to_up::and__up::to obscure from Bash completion._up::denotes sub-functions forupand__up::for_uptab completion. - Changes:
- Hiding sub-functions from Zsh autocompletion with `zstyle ':completion:' ignored-patterns '_up::|__up::*'. Could not figure out how to do the same with Bash.
- Skipping tab completion for most flags such as
-h,-f,--list-hist, etc.
- Features: Added verbose mode output to
-c/--clearto display and confirm history removal. Note: The verbose flag must be passed before the clear flag for this to work, e.g.,up -vc 1d.
- Fixes:
- Tab completion properly escapes multiple whitespace characters in a row, e.g.,
a dir_name 2 spacesshould bea\ dir_name\ \2\ spaces/. Directory names with more than one space were collapsed. - Properly handle paths with multiple whitespace characters in a row for
-m/--fzf-freq,-F/--fzf-hist, and-R/--fzf-recentflags, i.e., options usingfzf. Paths with spaces were not being shown; mostly incorrectawkinvocations.
- Tab completion properly escapes multiple whitespace characters in a row, e.g.,
- Changes:
- Added header and history line numbers of removed paths for verbose mode output with the
-p/--pruneflag. - Generalized
up::pluralize_dirtoup::pluralize; moved fromup.bashtoup_lib/up_utils.bash.
- Added header and history line numbers of removed paths for verbose mode output with the
- Fixes:
- Changed
awk '{print $3}' "$LOG_FILE"toawk '{print substr($0, index($0, $3))}'inup::print_paths_by_frequencyandup::filter_most_frequent_pathswithinup_history.bash.{print $3}truncates path names with whitespace. - Changed
awk '{print $3 " " $4 " " $5}')tocut -d' ' -f3-to avoid truncating path names with whitespace inup::jump_from_historywithinup_history.bash.
- Changed
- Documentation: Fixed improperly escaped characters of examples of
fzfoptions in man page. - Features: Added verbose mode output to
-p/--pruneshowing removed paths. Note: The verbose flag must be passed before the prune flag for this to work, e.g.up -vp.
- Documentation:
- Added dynamic check for config file in
-h/--helpoutput. - Fixed minor errors in man page.
- Added dynamic check for config file in
- Fixes: Parsing comments in arrays (
up::load_config_file).
- Fixes: Updated all instances of
cdinup.bashandup_lib/up_history.bashto usecd --, ensuring compatibility with directory names that begin with a hyphen (e.g.,-exampleDir). This change is now documented under the EDGE CASES subsection within the EXAMPLES section of the man page. - Features: Introduced support for a centralized configuration file to define environment variables in one location.
_UP_CONFIG_FILE: A new environment variable allowing users to specify a custom path to the configuration file (default:~/.config/up/up_settings.conf).- To avoid external parsers such as
tomlq, the configuration file format defines environment variables using simple key-value pairs, such as:_UP_ENVIRONMENT_VARIABLE_NAME=value
- Changes: Set
-i/--ignore-caseflag to use standard regex matching (-r) when not combined with other regex flags. It used to require explicit use of other regex flags. - Documentation: More additions and refinements to man page.
- Documentation:
- Created
up.1man page ingroffderived from the--helpoutput and available Markdown.- README for
manpage installation instructions. - The simple
install_up_man_page.bashscript automates installation of the manual.
- README for
- Created
- Features: Modified the
-c/--clearfunction to take<integer>(min|h|d|m)argument.
- Refactoring: Modularized pagination code from
up::show_historyintoup::run_with_pagination. - Features:
L/--list-freqflags display the history sorted by frequency of paths visited.m/--fzf-freqopensfzfwith the most frequently visited list, sorted by most to least visited; only displays existing paths.
- Refactoring: Path history functions only sourced when
_UP_ENABLE_HIST=true.up.bashhistory flags displays message when using and logging disabled.
- Features: Added
-R,--fzf-recentto openfzffor recent paths by<integer>[min|h|d|m]for timeframes representing hours, days, and months. - Documentation:
- Updated
-h/--helptext by organizing flags by sections "PWD Navigation" and "Path History Management".
- Updated
- Refactoring:
- Modularized monolithic
up.bashinto multiple files (1200+ raw lines).up_lib/up_environment_vars.bash: Definitions of constants defined by environment variables, etc.up_lib/up_wrappers.bash: Definitions of wrapper functions such asphandup_passthru.up_lib/up_history.bash: Definitions of path history functions.up_lib/up_utils.bash: Definitions of miscellanous helper functions.
- Moved
batstest files intotests/directory. - Linting: Turned on Bash LSP support for Neovim by using
bash-language-serverandshellcheck; fixing basic mistakes and closing most warnings, e.g., missing quotes, etc.
- Modularized monolithic
- Changes: Added checks for
ustatandgstatforfzfoptions defaults; the macOS BSD version ofstatis harder to visually parse. - Features: Added
-p/--prune-histto remove dead paths in history file.
- Fixes: Flag processing behavior for
upandphon arbitrary combinations of flag ordering. Issues around flags that should not immediately return an exit value such asfzf-related commands. - Documentation: Added programmatic
vhsanimated demo source code atassets/up_vhs_demo.tape; the file isasset/up_vhs_demo_animation.gif. - Changes: Dynamically check for
ezainstallation for use withfzf; default tolsandtreewhen not available.
Regular commits to main branch.
- Fixes: Verbose flag handling for wrapper function
ph -v. - Refactoring: Minor changes to
up-completion.bash. - Documentation:
- Added
ph -helpscreenshot toREADME.md. - Moved contributing section in
README.mdtoCONTRIBUTING.md.
- Added
- Features:
- History features must be enabled by setting
export _UP_ENABLE_HIST=truein shell config.- Display message when history-related flags used and history not enabled.
- Added
-H/--hist-statusflags to check whether history logging is on/off.
- History features must be enabled by setting
- Changes:
up::filter_history_with_fzfomits missing/deleted paths; only valid paths listed byfzf.
- Documentation: Fixed typos and inaccuracies.
- Fixes: Added rudimentary file locking code for writing path history; possible race conditions on multiple shell instances.
- Refactor:
up::construct_dotted_path:- Swapped for loop to
printf "../%.0s" $(seq 1 "$jump_index"). - Check to see if the passed index value is not larger than possible for
PWD.
- Swapped for loop to
if $verbose_mode; ...->if [[ "$verbose_mode" == true ]] ...for Boolean checks (best practice).
- Features:
- Added
up::filter_ancestors_with_fzf(-f/--fzf) to jump to ancestor paths withinPWDonly. _UP_FZF_HISTOPTS: Environment variable for settingfzfoptions for path history._UP_FZF_PWDOPTS: Environment variable for settingfzfoptions forPWD.
- Added
- Changes:
up::filter_history_with_fzfnow uses-F/--fzf-histflags.
- Features:
ph(path history): Added convenience function for printing and jumping history log.- Added
up::print_history_sizeto show current size/percent in history log. - Added
fzfpreview toggle for-f/--fzf,^Pto toggle; PGDN/PGUP in preview window^J/^K.
- Documentation:
- Help
-h/--helpflags display information forph,up_passthru - More general verbiage polishing in help output.
- Moved TODOs and Known Issues sections to this
DEVLOG.mdfile. - Updated help screenshot.
- Help
- Fixes:
returnstatements now returning numeric values, forgot to prefix variables with$—this is not C! 🙈
- Documentation:
- Corrected directory terminology within the project; removed words "subdirectory" and "subdirectories".
- The proper terminology is "parent", "ancestor", and "directory".
- Added examples section for
up --helpoutput; simplified usage section.
- Corrected directory terminology within the project; removed words "subdirectory" and "subdirectories".
- Changes: Updated tab completion script to check for
sedaccess, along with some minor refactoring.- Now using the previous character-escaping code as a fallback. However, this code will only properly escape ASCII directory names, losing Unicode support.
- Refactor: Using
local -rwhere possible for immutable variables. - Features: Started writing code for history log file. New flags and environment variables:
-l/--list-hist: List the content of history log file.-j/--jump-hist: Jump to path in history by most recent index, i.e,1is the previous, etc.-f/--fzf: Supports fuzzy search if user hasfzfinstalled; drop down menu appears below command prompt.-c/--clear: Clears all history in log file._UP_HISTFILE: Environment variable for the path of the history log file, default: ~/.cache/up_history.zsh`_UP_HISTSIZE: Environment variable for the maximum number of history entries, i.e., the number of lines in the log file.up_passthru: Function to use with aliases to track directory changes universally in the shell.alias cd='up_passthru cd'for shell buitincdsupport.alias z='up_passthru z'for zoxide support.
- Fixes: Removed
returnfromup::num_of_dirs_changed; now a call to "return"echoinstead.returnonly handles unsigned 8-bit integers.
- Features: Added support for regular expressions. Need to add tests.
- Added
-r/--regex,-s/--starts-with,-e/--ends-with, and-i/--ignore-caseflags.
- Added
- Features: Added
_UP_REGEX_STYLE,_UP_REGEX_DEFAULT,_UP_ALWAY_IGNORE_CASEenvironment varibles for regex support. - Changes: Removed naked (non-tack) flags. All flags must have one or two dashes.
- Committed initial version of project to GitHub.
There may be skill-related limitations: I’m not a Bash scripting expert.
- No color support for tab completion list
- I could not get Zsh to use
LS_COLORSviazstylesettings.
- I could not get Zsh to use
- Tab completion list not in order of
PWD- There’s no guarantee of the completion list order.
- Add pager environment variable.
- Clean and refactor
up.bashto make it more readable and maintainable. - Add
batstests forup.bashrelated to:- Regex flags
- History tracking and navigation
- Add more styling examples in
README.md, e.g., Dracula, gruvbox.
- Write a fish-compatible version.
- I'm not using fish as my primary shell.
- Write a binary version of
up.bashin a language like Go or Rust for universal shell compatibility. (Better idea than this script?)- Only completion scripts for target shells would need to be created.
- History session management.
- Bookmarking paths.
Thanks to the original script writers and public shell configs!
Originally, I used Derek Taylor's up function unmodified within his .zshrc:
up () {
local d=""
local limit="$1"
# Default to limit of 1
if [ -z "$limit" ] || [ "$limit" -le 0 ]; then
limit=1
fi
for ((i=1;i<=limit;i++)); do
d="../$d"
done
# perform cd. Show error if cd fails
if ! cd "$d"; then
echo "Couldn't go up $limit dirs.";
fi
}This minimalist function works well for navigating up by the number of directories.
I later found this simple up Bash script to navigate by directory name, complete with tab completion and bats scripts.
up() {
(($# == 0)) && cd .. && return
[[ $1 == / ]] && cd / && return
# shellcheck disable=SC2164
cd "${PWD%"${PWD##*/"$1"/}"}"
}My modifications are a result of combining the functionalities of these two up functions.
Instead of writing ANSI escape codes manually, use this simple list of 15 colors and a reset value in your shell config.