{"id":21926583,"url":"https://github.com/astzweig/zshlib","last_synced_at":"2026-04-10T23:09:27.092Z","repository":{"id":118758855,"uuid":"450958600","full_name":"astzweig/zshlib","owner":"astzweig","description":"🐣 Awesome functions for zsh CLI tools","archived":false,"fork":false,"pushed_at":"2024-07-04T02:02:17.000Z","size":127,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-03-22T11:49:03.202Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"eupl-1.2","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/astzweig.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-22T23:18:20.000Z","updated_at":"2024-07-04T02:02:22.000Z","dependencies_parsed_at":null,"dependency_job_id":"86b648b8-c48c-4793-b716-1cd79894822e","html_url":"https://github.com/astzweig/zshlib","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/astzweig/zshlib","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/astzweig%2Fzshlib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/astzweig%2Fzshlib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/astzweig%2Fzshlib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/astzweig%2Fzshlib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/astzweig","download_url":"https://codeload.github.com/astzweig/zshlib/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/astzweig%2Fzshlib/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261841960,"owners_count":23217914,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-28T22:08:57.710Z","updated_at":"2026-04-10T23:09:27.044Z","avatar_url":"https://github.com/astzweig.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Zsh Lib\nAwesome functions that make writing Z shell CLI applications easier.\n\n## Install\n### Automated install\nTo install this library for the current user run:\n\n```zsh\n/bin/zsh -c \"$(curl -fsSL https://raw.githubusercontent.com/astzweig/zshlib/main/bootstrap.sh)\"\n```\n\nTo install this library system wide run that as root.\n\n### Using release version\nYou can also just download the latest release and put in in your `$fpath`.\n\n### Using in development\nTo use this library in you own project add it as a [`git-submodule`][git-submodule]\nto your repository.\n\n```zsh\n# Run inside your project directory\ngit submodule add https://github.com/astzweig/zshlib\n```\n\n### Using on the command line\nJust add the zshlib directory to the beginning of your `PATH` variable and you\ncan call the commands from the command line. Alternatively you can enter the\nwhole path e.g. `/path/to/repo/hio --help`.\n\n\u003e **Caveat**: Remember that `sudo` does not inherit all environment variables.\n\u003e To pass your modified `PATH` variable run `sudo --preserve-env=PATH`.\n\n### Using as a library\nJust source the specific commands that you want inside your script. Alternatively\nyou can enable Zsh autoload:\n\n```zsh\n  # This will register all commands to autoload\n  FPATH=\"/path/to/zshlib:${FPATH}\"\n  local funcNames=(\"${(@f)$(find ./zshlib -type f -perm +u=x | awk -F/ '{ print $NF }')}\")\n  autoload -Uz \"${funcNames[@]}\"\n```\nOr if you want to autoload only specific commands:\n\n```zsh\n  # This will register only hio and getPrefDir to autoload\n  FPATH=\"/path/to/zshlib:${FPATH}\"\n  autoload -Uz hio getPrefDir\n```\n\n## What's included\n\n| name | description | dependencies | supported platforms |\n| ---- | ----------- | ------------ | ------------------- |\n| pf | Convenience function for highlighted output, combining print and tput. | [`tput`][tput], [`docopts`][docopts][^docopts] | all |\n| hio | Highlighted output for predefined text styles for `pf`. | `pf`[^zshlib], `isTerminalBackgroundDark`[^zshlib], [`docopts`][docopts][^docopts] | all |\n| lop | Log messages to syslog, file or print to command line with highlight. | `hio`[^zshlib], `pf`[^zshlib], `isTerminalBackgroundDark`[^zshlib], [`docopts`][docopts][^docopts] | all |\n| indicateActivity | Show a spinner during run of a function if output is to a terminal else print three dots and done or failed afterwards. | `lop`[^zshlib], `hio`[^zshlib], `pf`[^zshlib], `isTerminalBackgroundDark`[^zshlib], [`docopts`][docopts][^docopts] | all |\n| trim | Remove leading and trailing whitespace from string. | [`docopts`][docopts][^docopts] | all |\n| loadModules | Find executable modules in module search paths and allow user to filter or inverse the list. | [`docopts`][docopts][^docopts] | all |\n| askUserModuleQuestions | Ask user questions on behalf of modules with possibility to cache (or store) answers for future calls, e.g. using config. | [`docopts`][docopts][^docopts] | all |\n| showSpinner | Show a loading animation during execution of a function. | `traps`[^zshlib], [`docopts`][docopts][^docopts] | all |\n| askUser | Ask user for input. Supports questions, password, selections or confirmations. | `hio`[^zshlib], `traps`[^zshlib], [`docopts`][docopts][^docopts] | all |\n| getPrefDir | Get system specific preferences directory. | [`docopts`][docopts][^docopts] | macOS, Linux, Windows Subsystem for Linux |\n| traps | A trap handler for zsh scripts. | [`docopts`][docopts][^docopts] | macOS, Linux, Windows Subsystem for Linux |\n| config | Config file writer and reader. | `getPrefDir`[^zshlib], `PlistBuddy`[^plistbuddy], [`docopts`][docopts][^docopts] | macOS, Linux, Windows Subsystem for Linux |\n| abbreviatePaths | Truncate the passed paths so that they are minimal in length and pairwise distinct. Useful to save the user long path specifications. | [`docopts`][docopts][^docopts] | all |\n| isTerminalBackgroundDark | Queries the terminal for its background color and returns zero if the color is rather dark or 1 otherwise. If the output is not connected to a terminal, code 10 will be returned. | `traps`[^zshlib] | all |\n\n\n[^zshlib]: A command of Zsh Lib (this library).\n[^docopts]: `docopts` with `-f, --function` option needed. See the\n  [Astzweig fork][astzweig-docopts] for example.\n[^plistbuddy]: `/usr/libexec/PlistBuddy` is a utility found on macOS systems.\n  Apple does not provide any documentation besides the man page and the programs\n  `--help` output.\n\n## Usage\nRun any command with the `--help` option to read about its usage. e.g.\n`/path/to/zshlib/hio --help`.\n\n[git-submodule]: https://git-scm.com/docs/git-submodule\n[docopts]: https://github.com/docopt/docopts\n[tput]: https://www.gnu.org/software/termutils/manual/termutils-2.0/html_chapter/tput_1.html\n[astzweig-docopts]: https://github.com/astzweig/docopts\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fastzweig%2Fzshlib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fastzweig%2Fzshlib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fastzweig%2Fzshlib/lists"}