{"id":16854607,"url":"https://github.com/philpennock/zsh-functions","last_synced_at":"2026-04-17T07:31:53.667Z","repository":{"id":145532831,"uuid":"147454769","full_name":"philpennock/zsh-functions","owner":"philpennock","description":"A few of the zsh functions I've written. Caveat lector.","archived":false,"fork":false,"pushed_at":"2020-06-14T07:08:18.000Z","size":36,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-05-16T22:08:51.398Z","etag":null,"topics":["aws","kerberos","prompt","pyenv","ssh","vagrant","zsh","zsh-functions","zshrc"],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/philpennock.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2018-09-05T03:32:04.000Z","updated_at":"2022-09-19T18:21:48.000Z","dependencies_parsed_at":null,"dependency_job_id":"48e62bee-e6ba-4878-9ebb-2cbeefe96c9d","html_url":"https://github.com/philpennock/zsh-functions","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/philpennock/zsh-functions","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philpennock%2Fzsh-functions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philpennock%2Fzsh-functions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philpennock%2Fzsh-functions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philpennock%2Fzsh-functions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/philpennock","download_url":"https://codeload.github.com/philpennock/zsh-functions/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philpennock%2Fzsh-functions/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31919921,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-16T18:22:33.417Z","status":"online","status_checked_at":"2026-04-17T02:00:06.879Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["aws","kerberos","prompt","pyenv","ssh","vagrant","zsh","zsh-functions","zshrc"],"created_at":"2024-10-13T13:56:06.175Z","updated_at":"2026-04-17T07:31:53.648Z","avatar_url":"https://github.com/philpennock.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"zsh-functions\n=============\n\nMy shell prompt is hideous and grotesque, with warts from compatibility hacks\nfor ancient versions of zsh.  Every time I think \"I can drop that hack\" I end\nup cloning my `~/.personal` repo onto a box with an even more ancient version\nof zsh and crying a little inside, before restoring compatibility hacks.\n\nNonetheless, various friends and former co-workers have asked for my prompt\nsetup.  So I threw together this repo to hold a few zsh functions which are\n_potentially_ useful to others.\n\nWith the above in mind, complaints about the grotesqueness of the code will be\nfiled in the circular filing cabinet on the floor.  Bug-fixes without snark\ngratefully received.\n\nNote that zstyle is needed to turn some prompt features on or off, or invoking\nwith options to toggle features.\n\nLicensed per [LICENSE.txt](LICENSE.txt).  \nNote: the first copyright year is my best guess of when this version of the\nshell prompt started growing.  It might be a year or two off.  I don't want to\nhave to resurrect svn or ask around for old CVS repos to be sure.  If this is\never seriously an issue, I'll cry a little more.\n\n\n## Setup\n\nIn `~/.zshrc` or equivalent:\n\n```sh\n# zstyle ':prompt:pdp*:*' use-cache on\nautoload promptinit\npromptinit\nprompt pdp\n\nsetopt transient_rprompt\n```\n\nI actually have setup to maintain a per-host cache in an OS-specific cache\nlocation, so that `~/Library/Caches/zsh/osmium` is correct for my current\nlaptop; this then feeds into uncommenting the `use-cache` above.\n\nMy macOS laptop had:\n\n```sh\nzstyle ':prompt:pdp*:*' employer-domain pennock-tech.net\nzstyle ':prompt:pdp*:*' employer-prompt $'@%{\\e[38;2;0;180;222m%}PennockTech%{\\e[0m%}'\nzstyle ':prompt:pdp*:*' show-domain off\nzstyle ':prompt:pdp*:*' auto-kerberos on\nzstyle ':prompt:pdp*:*' show-awscreds on\n```\n\nMy Linux laptop, unable to use the aws-vault info sub-command to get rotation\ntimes, skips `show-awscreds` but does have:\n\n```sh\nzstyle ':prompt:pdp*:*' show-awsprofile on\nzstyle ':prompt:pdp*:*' show-pyenv on\n```\n\nAnother box just has:\n\n```sh\nzstyle ':prompt:pdp*:*' show-sshkeys on\nzstyle ':prompt:pdp*:*' show-gpgagent on\n```\n\nThere is now support for displaying the current `pyenv version-name` in the\nright-hand-side prompt `RPS1`; it also supports being auto-enabled via setting\nan environment variable, to integrate with [`direnv(1)`](https://direnv.net/).\nTo use it, wherever you `export PYENV_VERSION=...` also\n`export _prompt_pdp_pyenv='!'` as a trigger.  The prompt functions will spot\nthat the internal variable is exported and unexport it, before turning on its\nown pyenv mode.  This support doesn't handle arbitrary \"something assigned to\n`PYENV_VERSION`, unfortunately.  We'd need watches on variables for that.\n\nI now display by default a rendering of `$KUBE_CONTEXT` and `$KUBE_NAMESPACE`\nin my RHS prompt, used by my wrappers around `kubectl` and `helm` so that I\ncan change into a directory with a `.envrc` containing something like\n`export KUBE_NAMESPACE=top-www` and be automatically pointed to the right bit\nof a Kubernetes cluster for a given app.\n\nWhen setting authentication credentials or the like into variables, it's handy\nto be able to tell apart the tabs and know which variables are available to\nme.  Arbitrary content can be assigned to `PDP_LABEL` (non-exported) just to\nget a convenient red tag.\n\nWith this expansion in the use of `$RPS1`, setting the zsh `transient_rprompt`\noption makes it much easier to copy/paste commands without the RHS prompt\ngetting in the way.\n\n## Functions\n\nSet up autoload for these and most of them will help with tab-completion.\n\n* `_aws` — wrapper around bash completion, this one actually works\n* `_aws_profiles` — let `AWS_PROFILE=` tab-complete usefully\n* `_aws-vault` — completion for `aws-vault`\n* `_docker_contexts` — let `DOCKER_CONTEXT=` tab-complete usefully\n* `_pyenv_versions` — let `PYENV_VERSION=` tab-complete usefully\n* `_ssh-kube-gcloud` — completion for `bin/ssh-kube-gcloud` which is a wrapper\n  around `gcloud compute ssh`; gcloud's tab-completion hits a remote end-point\n  every time you press tab, so is hideously slow.  This completion caches,\n  making it occasionally slow but usually fast.\n* `_vagrant` — decent fast tab-completion for Vagrant\n* `_kube_contexts` \u0026 `_kube_namespaces` — completion for\n  `KUBE_CONTEXT=` \u0026 `KUBE_NAMESPACE=`\n* `_nodenv_versions`, `_pyenv_versions`, `_rbenv_versions` — completion for\n  shell variables for controlling the respective interpreter dispatchers.\n* `prompt_pdp_setup` — invoked by zsh's prompt framework when told to use the\n  `pdp` prompt\n* `kerb_remaining_time` — cached invocation of `klist(1)` to determine\n  remaining kerberos ticket lifetime, for prompt display\n* `iterm_tabcolor_rgb` — setting tab colors for iTerm without another\n  fork/exec\n\nI also use some items in `zfuncs.zsh` which are not auto-loaded but are\ndirectly in-line, typically to avoid defining them unless some command is\ninstalled.\n\n## See Also\n\nI use \u003chttps://github.com/nnao45/zsh-kubectl-completion\u003e for completing\n`kubectl`.  This is compatible with compdef aliasing so that I can have `k`\ntab-complete too (either add `k=kubectl` to the `#compdef` line at the start\nof the file, or run `compdef _kubectl k=kubectl` after loading).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphilpennock%2Fzsh-functions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphilpennock%2Fzsh-functions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphilpennock%2Fzsh-functions/lists"}