mirror of https://github.com/ohmyzsh/ohmyzsh.git
Compare commits
12 Commits
3243f36f09
...
0cb4e65b85
Author | SHA1 | Date |
---|---|---|
|
0cb4e65b85 | |
|
7a3695aadf | |
|
cae2e45193 | |
|
276e540eed | |
|
5c17bcd21f | |
|
d82669199b | |
|
9c8afcc3ee | |
|
f733dc340b | |
|
048e166c9e | |
|
b9e73b4481 | |
|
62e3e0b2fd | |
|
15cd818cd1 |
|
@ -36,7 +36,7 @@ dependencies:
|
||||||
plugins/z:
|
plugins/z:
|
||||||
branch: master
|
branch: master
|
||||||
repo: agkozak/zsh-z
|
repo: agkozak/zsh-z
|
||||||
version: afaf2965b41fdc6ca66066e09382726aa0b6aa04
|
version: dd94ef04acc41748ba171eb219971cb455e0040b
|
||||||
precopy: |
|
precopy: |
|
||||||
set -e
|
set -e
|
||||||
test -e README.md && mv -f README.md MANUAL.md
|
test -e README.md && mv -f README.md MANUAL.md
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
certifi==2024.8.30
|
certifi==2024.12.14
|
||||||
charset-normalizer==3.4.0
|
charset-normalizer==3.4.1
|
||||||
idna==3.10
|
idna==3.10
|
||||||
PyYAML==6.0.2
|
PyYAML==6.0.2
|
||||||
requests==2.32.3
|
requests==2.32.3
|
||||||
semver==3.0.2
|
semver==3.0.2
|
||||||
urllib3==2.2.3
|
urllib3==2.3.0
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#!/usr/bin/env zsh
|
#!/usr/bin/env zsh
|
||||||
|
|
||||||
function omz {
|
function omz {
|
||||||
|
setopt localoptions noksharrays
|
||||||
[[ $# -gt 0 ]] || {
|
[[ $# -gt 0 ]] || {
|
||||||
_omz::help
|
_omz::help
|
||||||
return 1
|
return 1
|
||||||
|
|
|
@ -5,6 +5,7 @@ files=(
|
||||||
/etc/grc.zsh # default
|
/etc/grc.zsh # default
|
||||||
/usr/local/etc/grc.zsh # homebrew darwin-x64
|
/usr/local/etc/grc.zsh # homebrew darwin-x64
|
||||||
/opt/homebrew/etc/grc.zsh # homebrew darwin-arm64
|
/opt/homebrew/etc/grc.zsh # homebrew darwin-arm64
|
||||||
|
/home/linuxbrew/.linuxbrew/etc/grc.zsh # linuxbrew
|
||||||
/usr/share/grc/grc.zsh # Gentoo Linux (app-misc/grc)
|
/usr/share/grc/grc.zsh # Gentoo Linux (app-misc/grc)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@ toggle set the `PER_DIRECTORY_HISTORY_TOGGLE` environment variable.
|
||||||
function above (default `^G`)
|
function above (default `^G`)
|
||||||
* `PER_DIRECTORY_HISTORY_PRINT_MODE_CHANGE` is a variable which toggles whether
|
* `PER_DIRECTORY_HISTORY_PRINT_MODE_CHANGE` is a variable which toggles whether
|
||||||
the current mode is printed to the screen following a mode change (default `true`)
|
the current mode is printed to the screen following a mode change (default `true`)
|
||||||
|
* `HISTORY_START_WITH_GLOBAL` is a global variable that defines how to start the plugin: global or local (default `false`)
|
||||||
|
|
||||||
## History
|
## History
|
||||||
|
|
||||||
|
|
|
@ -22,5 +22,5 @@ fi
|
||||||
rustup completions zsh >| "$ZSH_CACHE_DIR/completions/_rustup" &|
|
rustup completions zsh >| "$ZSH_CACHE_DIR/completions/_rustup" &|
|
||||||
cat >| "$ZSH_CACHE_DIR/completions/_cargo" <<'EOF'
|
cat >| "$ZSH_CACHE_DIR/completions/_cargo" <<'EOF'
|
||||||
#compdef cargo
|
#compdef cargo
|
||||||
source "$(rustc +${${(z)$(rustup default)}[1]} --print sysroot)"/share/zsh/site-functions/_cargo
|
source "$(rustup run ${${(z)$(rustup default)}[1]} rustc --print sysroot)"/share/zsh/site-functions/_cargo
|
||||||
EOF
|
EOF
|
||||||
|
|
|
@ -0,0 +1,90 @@
|
||||||
|
# Terraform plugin to display workspace in prompt
|
||||||
|
|
||||||
|
Plugin for Terraform from Hashicorp, an infrastructure as code tool that allows for multi-cloud support, modularity,
|
||||||
|
and the ability to plan and apply changes, making it easier to manage and provision infrastructure resources.
|
||||||
|
|
||||||
|
## Features:
|
||||||
|
- Completion for `terraform`
|
||||||
|
- aliases
|
||||||
|
- prompt function
|
||||||
|
- Support for agnoster template
|
||||||
|
|
||||||
|
## Structure:
|
||||||
|
```sh
|
||||||
|
.
|
||||||
|
├── README.md
|
||||||
|
├── plugins
|
||||||
|
├── _terraform
|
||||||
|
└── terraform-workspace.plugin.zsh
|
||||||
|
```
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
* [zsh](http://www.zsh.org/)
|
||||||
|
* [Terraform](https://terraform.io/)
|
||||||
|
* [oh-my-zsh](https://github.com/ohmyzsh/ohmyzsh)
|
||||||
|
* [terraform-workspace plugin](https://github.com/ocontant/terraform-workspace)
|
||||||
|
* [terraform-workspace themes](https://github.com/ocontant/terraform-agnoster)
|
||||||
|
|
||||||
|
# Installation:
|
||||||
|
## Manual
|
||||||
|
1. Clone the repository to your localspace
|
||||||
|
- `git clone https://github.com/ocontant/terraform-workspace.git`
|
||||||
|
2. Copy the plugins folder to ~/.oh-my-zsh/custom/plugins/terraform-workspace
|
||||||
|
- `cp -r plugins/terraform-workspace ~/.oh-my-zsh/custom/plugins/terraform-workspace`
|
||||||
|
3. Copy the themes folder to ~/.oh-my-zsh/custom/themes/agnoster
|
||||||
|
- `cp -r themes/agnoster ~/.oh-my-zsh/custom/themes/agnoster`
|
||||||
|
4. Add the plugin `terraform-workspace` to your plugins array section of your `~/.zshrc` file
|
||||||
|
- `plugins=(... terraform-workspace)`
|
||||||
|
5. Add the theme `terraform-agnoster` to your theme section of your `~/.zshrc` file
|
||||||
|
|
||||||
|
## With Antigen
|
||||||
|
1. Install Antigen:
|
||||||
|
- `curl -L git.io/antigen > ~/antigen.zsh`
|
||||||
|
2. Add antigen requirements to your `~/.zshrc` file
|
||||||
|
```sh
|
||||||
|
source ~/antigen.zsh
|
||||||
|
# Load Antigen configurations
|
||||||
|
antigen init ~/.antigenrc
|
||||||
|
```
|
||||||
|
3. Create the file ~/.antigenrc and add the following content (I included my favorite bundle, feel free to add/remove):
|
||||||
|
```sh
|
||||||
|
# Load oh-my-zsh library
|
||||||
|
antigen use oh-my-zsh
|
||||||
|
|
||||||
|
# Load bundles from the default repo (oh-my-zsh)
|
||||||
|
antigen bundle git
|
||||||
|
antigen bundle command-not-found
|
||||||
|
antigen bundle docker
|
||||||
|
|
||||||
|
# Load bundles from external repos
|
||||||
|
antigen bundle zsh-users/zsh-completions
|
||||||
|
antigen bundle zsh-users/zsh-autosuggestions
|
||||||
|
antigen bundle zsh-users/zsh-syntax-highlighting
|
||||||
|
antigen bundle zsh-users/zsh-history-substring-search
|
||||||
|
|
||||||
|
# Load the terraform plugins and theme
|
||||||
|
antigen bundle ocontant/terraform-workspace
|
||||||
|
antigen theme ocontant/terraform-agnoster
|
||||||
|
|
||||||
|
# Tell Antigen that you're done.
|
||||||
|
antigen apply
|
||||||
|
```
|
||||||
|
4. Add the theme `terraform-agnoster` to your theme section of your `~/.zshrc` file
|
||||||
|
5. Add the plugin `terraform-workspace` to your plugins array section of your `~/.zshrc` file
|
||||||
|
- `plugins=(... terraform-workspace)`
|
||||||
|
|
||||||
|
|
||||||
|
# Prompt function
|
||||||
|
## If you don't want to use oh-my-zsh agnoster theme, you can use this prompt to display the current Terraform workspace in your prompt.
|
||||||
|
|
||||||
|
1. Create a bloc in your `~/.zshrc` file:
|
||||||
|
```sh
|
||||||
|
# Terraform prompt
|
||||||
|
## Create 2 variables (feel free to customize the colors)
|
||||||
|
ZSH_THEME_TF_PROMPT_PREFIX="%{$fg[white]%}"
|
||||||
|
ZSH_THEME_TF_PROMPT_SUFFIX="%{$reset_color%}"
|
||||||
|
|
||||||
|
## Add the current Terraform workspace in your prompt by adding `"TF: ${__TERRAFORM_WORKSPACE_CACHE:gs/%/%%}"` to your `PROMPT` or `RPROMPT` variable.
|
||||||
|
## Example:
|
||||||
|
PROMPT="${PROMPT}>${ZSH_THEME_TF_PROMPT_PREFIX-[}${__TERRAFORM_WORKSPACE_CACHE:gs/%/%%}${ZSH_THEME_TF_PROMPT_SUFFIX-]}"
|
||||||
|
```
|
|
@ -0,0 +1,411 @@
|
||||||
|
#compdef terraform
|
||||||
|
|
||||||
|
local -a _terraform_cmds opt_args
|
||||||
|
_terraform_cmds=(
|
||||||
|
'apply:Builds or changes infrastructure'
|
||||||
|
'console:Interactive console for Terraform interpolations'
|
||||||
|
'destroy:Destroy Terraform-managed infrastructure'
|
||||||
|
'fmt:Rewrites config files to canonical format'
|
||||||
|
'force-unlock:Manually unlock the terraform state'
|
||||||
|
'get:Download and install modules for the configuration'
|
||||||
|
'graph:Create a visual graph of Terraform resources'
|
||||||
|
'import:Import existing infrastructure into Terraform'
|
||||||
|
'init:Initialize a Terraform working directory'
|
||||||
|
'login:Obtain and save credentials for a remote host'
|
||||||
|
'logout:Remove locally-stored credentials for a remote host'
|
||||||
|
'output:Read an output from a state file'
|
||||||
|
'plan:Generate and show an execution plan'
|
||||||
|
'providers:Prints a tree of the providers used in the configuration'
|
||||||
|
'refresh:Update local state file against real resources'
|
||||||
|
'show:Inspect Terraform state or plan'
|
||||||
|
'state:Advanced state management'
|
||||||
|
'taint:Manually mark a resource for recreation'
|
||||||
|
'untaint:Manually unmark a resource as tainted'
|
||||||
|
'validate:Validates the Terraform files'
|
||||||
|
'version:Prints the Terraform version'
|
||||||
|
'workspace:Workspace management'
|
||||||
|
'0.12upgrade:Rewrites pre-0.12 module source code for v0.12'
|
||||||
|
'0.13upgrade:Rewrites pre-0.13 module source code for v0.13'
|
||||||
|
)
|
||||||
|
|
||||||
|
__012upgrade() {
|
||||||
|
_arguments \
|
||||||
|
'-yes[Skip the initial introduction messages and interactive confirmation. This can be used to run this command in batch from a script.]' \
|
||||||
|
'-force[ Override the heuristic that attempts to detect if a configuration is already written for v0.12 or later. Some of the transformations made by this command are not idempotent, so re-running against the same module may change the meanings expressions in the module.]'
|
||||||
|
}
|
||||||
|
|
||||||
|
__013upgrade() {
|
||||||
|
_arguments \
|
||||||
|
'-yes[Skip the initial introduction messages and interactive confirmation. This can be used to run this command in batch from a script.]'
|
||||||
|
}
|
||||||
|
|
||||||
|
__apply() {
|
||||||
|
_arguments \
|
||||||
|
'-auto-approve[Skip interactive approval of plan before applying.]' \
|
||||||
|
'-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]:backupfile:_files -g "*.backup"' \
|
||||||
|
'-compact-warnings[If Terraform produces any warnings that are not accompanied by errors, show them in a more compact form that includes only the summary messages.]' \
|
||||||
|
'-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
|
||||||
|
'-lock-timeout=[(0s) Duration to retry a state lock.]' \
|
||||||
|
'-input=[(true) Ask for input for variables if not directly set.]' \
|
||||||
|
'-no-color[If specified, output will be colorless.]' \
|
||||||
|
'-parallelism=[(10) Limit the number of parallel resource operations.]' \
|
||||||
|
'-refresh=[(true) Update state prior to checking for differences. This has no effect if a plan file is given to apply.]' \
|
||||||
|
'-state=[(terraform.tfstate) Path to read and save state (unless state-out is specified).]:statefile:_files -g "*.tfstate"' \
|
||||||
|
'-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]:statefile:_files -g "*.tfstate"' \
|
||||||
|
'*-target=[(resource) Resource to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]:target:__statelist' \
|
||||||
|
'*-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
|
||||||
|
'*-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]:file:_files -g "*.tfvars{,.json}"'
|
||||||
|
}
|
||||||
|
|
||||||
|
__console() {
|
||||||
|
_arguments \
|
||||||
|
'-state=[(terraform.tfstate) Path to read state.]' \
|
||||||
|
'*-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
|
||||||
|
'*-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]:file:_files -g "*.tfvars{,.json}"'
|
||||||
|
}
|
||||||
|
|
||||||
|
__destroy() {
|
||||||
|
_arguments \
|
||||||
|
'-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]:backupfile:_files -g "*.backup"' \
|
||||||
|
'-auto-approve[Skip interactive approval before destroying.]' \
|
||||||
|
'-force[Deprecated: same as auto-approve.]' \
|
||||||
|
'-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
|
||||||
|
'-lock-timeout=[(0s) Duration to retry a state lock.]' \
|
||||||
|
'-no-color[If specified, output will contain no color.]' \
|
||||||
|
'-parallelism=[(10) Limit the number of concurrent operations.]' \
|
||||||
|
'-refresh=[(true) Update state prior to checking for differences. This has no effect if a plan file is given to apply.]' \
|
||||||
|
'-state=[(terraform.tfstate) Path to read and save state (unless state-out is specified).]:statefile:_files -g "*.tfstate"' \
|
||||||
|
'-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]:statefile:_files -g "*.tfstate"' \
|
||||||
|
'*-target=[(resource) Resource to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]:target:__statelist' \
|
||||||
|
'*-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
|
||||||
|
'*-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]:file:_files -g "*.tfvars{,.json}"'
|
||||||
|
}
|
||||||
|
|
||||||
|
__fmt() {
|
||||||
|
_arguments \
|
||||||
|
'-list=[(true) List files whose formatting differs (always false if using STDIN)]' \
|
||||||
|
'-write=[(true) Write result to source file instead of STDOUT (always false if using STDIN or -check)]' \
|
||||||
|
'-diff=[(false) Display diffs of formatting changes]' \
|
||||||
|
'-check=[(false) Check if the input is formatted. Exit status will be 0 if all input is properly formatted and non-zero otherwise.]' \
|
||||||
|
'-recursive=[(false) Also process files in subdirectories. By default, only the given directory (or current directory) is processed.]'
|
||||||
|
}
|
||||||
|
|
||||||
|
__force_unlock() {
|
||||||
|
_arguments \
|
||||||
|
"-force[Don't ask for input for unlock confirmation.]"
|
||||||
|
}
|
||||||
|
|
||||||
|
__get() {
|
||||||
|
_arguments \
|
||||||
|
'-update=[(false) If true, modules already downloaded will be checked for updates and updated if necessary.]' \
|
||||||
|
'-no-color[Disable text coloring in the output.]'
|
||||||
|
}
|
||||||
|
|
||||||
|
__graph() {
|
||||||
|
_arguments \
|
||||||
|
'-draw-cycles[Highlight any cycles in the graph with colored edges. This helps when diagnosing cycle errors.]' \
|
||||||
|
'-type=[(plan) Type of graph to output. Can be: plan, plan-destroy, apply, validate, input, refresh.]'
|
||||||
|
}
|
||||||
|
|
||||||
|
__import() {
|
||||||
|
_arguments \
|
||||||
|
'-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]:backupfile:_files -g "*.backup"' \
|
||||||
|
'-config=[(path) Path to a directory of Terraform configuration files to use to configure the provider. Defaults to pwd. If no config files are present, they must be provided via the input prompts or env vars.]' \
|
||||||
|
'-allow-missing-config[Allow import when no resource configuration block exists.]' \
|
||||||
|
'-input=[(true) Ask for input for variables if not directly set.]' \
|
||||||
|
'-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
|
||||||
|
'-lock-timeout=[(0s) Duration to retry a state lock.]' \
|
||||||
|
'-no-color[If specified, output will contain no color.]' \
|
||||||
|
'-state=[(PATH) Path to the source state file. Defaults to the configured backend, or "terraform.tfstate"]:statefile:_files -g "*.tfstate"' \
|
||||||
|
'-state-out=[(PATH) Path to the destination state file to write to. If this is not specified, the source state file will be used. This can be a new or existing path.]:statefile:_files -g "*.tfstate"' \
|
||||||
|
'*-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times. This is only useful with the "-config" flag.]' \
|
||||||
|
'*-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]:file:_files -g "*.tfvars{,.json}"'
|
||||||
|
}
|
||||||
|
|
||||||
|
__init() {
|
||||||
|
_arguments \
|
||||||
|
'-backend=[(true) Configure the backend for this configuration.]' \
|
||||||
|
'-backend-config=[This can be either a path to an HCL file with key/value assignments (same format as terraform.tfvars) or a 'key=value' format. This is merged with what is in the configuration file. This can be specified multiple times. The backend type must be in the configuration itself.]' \
|
||||||
|
'-force-copy[Suppress prompts about copying state data. This is equivalent to providing a "yes" to all confirmation prompts.]' \
|
||||||
|
'-from-module=[(SOURCE) Copy the contents of the given module into the target directory before initialization.]' \
|
||||||
|
'-get=[(true) Download any modules for this configuration.]' \
|
||||||
|
'-get-plugins=[(true) Download any missing plugins for this configuration.]' \
|
||||||
|
'-input=[(true) Ask for input if necessary. If false, will error if input was required.]' \
|
||||||
|
'-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
|
||||||
|
'-lock-timeout=[(0s) Duration to retry a state lock.]' \
|
||||||
|
'-no-color[If specified, output will contain no color.]' \
|
||||||
|
'-plugin-dir[Directory containing plugin binaries. This overrides all default search paths for plugins, and prevents the automatic installation of plugins. This flag can be used multiple times.]:plugin_dir:_files -/' \
|
||||||
|
'-reconfigure[Reconfigure the backend, ignoring any saved configuration.]' \
|
||||||
|
'-upgrade=[(false) If installing modules (-get) or plugins (-get-plugins), ignore previously-downloaded objects and install the latest version allowed within configured constraints.]' \
|
||||||
|
'-verify-plugins=[(true) Verify the authenticity and integrity of automatically downloaded plugins.]'
|
||||||
|
}
|
||||||
|
|
||||||
|
__login() {
|
||||||
|
_arguments \
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
__logout() {
|
||||||
|
_arguments \
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
__output() {
|
||||||
|
_arguments \
|
||||||
|
'-state=[(path) Path to the state file to read. Defaults to "terraform.tfstate".]:statefile:_files -g "*.tfstate"' \
|
||||||
|
'-no-color[If specified, output will contain no color.]' \
|
||||||
|
'-json[If specified, machine readable output will be printed in JSON format]'
|
||||||
|
}
|
||||||
|
|
||||||
|
__plan() {
|
||||||
|
_arguments \
|
||||||
|
'-compact-warnings[If Terraform produces any warnings that are not accompanied by errors, show them in a more compact form that includes only the summary messages.]' \
|
||||||
|
'-destroy[If set, a plan will be generated to destroy all resources managed by the given configuration and state.]' \
|
||||||
|
'-detailed-exitcode[() Return detailed exit codes when the command exits. This will change the meaning of exit codes to: 0 - Succeeded, diff is empty (no changes); 1 - Errored, 2 - Succeeded; there is a diff]' \
|
||||||
|
'-input=[(true) Ask for input for variables if not directly set.]' \
|
||||||
|
'-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
|
||||||
|
'-lock-timeout=[(0s) Duration to retry a state lock.]' \
|
||||||
|
'-no-color[() If specified, output will contain no color.]' \
|
||||||
|
'-out=[(path) Write a plan file to the given path. This can be used as input to the "apply" command.]' \
|
||||||
|
'-parallelism=[(10) Limit the number of concurrent operations.]' \
|
||||||
|
'-refresh=[(true) Update state prior to checking for differences.]' \
|
||||||
|
'-state=[(statefile) Path to a Terraform state file to use to look up Terraform-managed resources. By default it will use the state "terraform.tfstate" if it exists.]:statefile:_files -g "*.tfstate"' \
|
||||||
|
'*-target=[(resource) Resource to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]:target:__statelist' \
|
||||||
|
'*-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
|
||||||
|
'*-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]:file:_files -g "*.tfvars{,.json}"'
|
||||||
|
}
|
||||||
|
|
||||||
|
__providers() {
|
||||||
|
local -a __providers_cmds
|
||||||
|
__providers_cmds=(
|
||||||
|
'mirror:Mirrors the provider plugins needed for the current configuration'
|
||||||
|
'schema:Prints the schemas of the providers used in the configuration'
|
||||||
|
)
|
||||||
|
_describe -t providers "providers commands" __providers_cmds
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
__providers_mirror() {
|
||||||
|
_arguments \
|
||||||
|
'-platform=[(os_arch) Choose which target platform to build a mirror for.]' \
|
||||||
|
"*:target_dir:_files -/"
|
||||||
|
}
|
||||||
|
|
||||||
|
__providers_schema() {
|
||||||
|
_arguments \
|
||||||
|
'-json[]' \
|
||||||
|
'::'
|
||||||
|
}
|
||||||
|
|
||||||
|
__refresh() {
|
||||||
|
_arguments \
|
||||||
|
'-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]::backupfile:_files -g "*.backup"' \
|
||||||
|
'-compact-warnings[If Terraform produces any warnings that are not accompanied by errors, show them in a more compact form that includes only the summary messages.]' \
|
||||||
|
'-input=[(true) Ask for input for variables if not directly set.]' \
|
||||||
|
'-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
|
||||||
|
'-lock-timeout=[(0s) Duration to retry a state lock.]' \
|
||||||
|
'-no-color[If specified, output will not contain any color.]' \
|
||||||
|
'-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]:statefile:_files -g "*.tfstate"' \
|
||||||
|
'-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]:statefile:_files -g "*.tfstate"' \
|
||||||
|
'*-target=[(resource) A Resource Address to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]:target:__statelist' \
|
||||||
|
'*-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
|
||||||
|
'*-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]:file:_files -g "*.tfvars{,.json}"'
|
||||||
|
}
|
||||||
|
|
||||||
|
__show() {
|
||||||
|
_arguments \
|
||||||
|
'-json[If specified, output the Terraform plan or state in a machine-readable form.]' \
|
||||||
|
'-no-color[If specified, output will not contain any color.]'
|
||||||
|
}
|
||||||
|
|
||||||
|
__state() {
|
||||||
|
local -a __state_cmds
|
||||||
|
__state_cmds=(
|
||||||
|
'list:List resources in the state'
|
||||||
|
'mv:Move an item in the state'
|
||||||
|
'pull:Pull current state and output to stdout'
|
||||||
|
'push:Update remote state from a local state file'
|
||||||
|
'replace-provider:Replace provider for resources in the Terraform state'
|
||||||
|
'rm:Remove instances from the state'
|
||||||
|
'show:Show a resource in the state'
|
||||||
|
)
|
||||||
|
_describe -t state "state commands" __state_cmds
|
||||||
|
}
|
||||||
|
|
||||||
|
__state_list() {
|
||||||
|
_arguments \
|
||||||
|
'-state=[(statefile) Path to a Terraform state file to use to look up Terraform-managed resources. By default, Terraform will consult the state of the currently-selected workspace.]' \
|
||||||
|
'-id=[(id) Filters the results to include only instances whose resource types have an attribute named id whose value equals the given id string.]' \
|
||||||
|
"*:address:__statelist"
|
||||||
|
}
|
||||||
|
|
||||||
|
__state_mv() {
|
||||||
|
_arguments \
|
||||||
|
"-dry-run[If set, prints out what would've been moved but doesn't actually move anything.]" \
|
||||||
|
'-backup=[(PATH) Path where Terraform should write the backup for the original state. This can"t be disabled. If not set, Terraform will write it to the same path as the statefile with a ".backup" extension.]:backupfile:_files -g "*.backup"' \
|
||||||
|
'-backup-out=[(PATH) Path where Terraform should write the backup for the destination state. This can"t be disabled. If not set, Terraform will write it to the same path as the destination state file with a backup extension. This only needs to be specified if -state-out is set to a different path than -state.]:backupfile:_files -g "*.backup"' \
|
||||||
|
"-lock=[(true) Lock the state files when locking is supported.]:lock:(true false)" \
|
||||||
|
"-lock-timeout=[(0s) Duration to retry a state lock.]" \
|
||||||
|
'-state=[(path) Path to the source state file. Defaults to the configured backend, or "terraform.tfstate"]:statefile:_files -g "*.tfstate"' \
|
||||||
|
'-state-out=[(path) Path to the destination state file to write to. If this isn"t specified, the source state file will be used. This can be a new or existing path.]:statefile:_files -g "*.tfstate"' \
|
||||||
|
"::" \
|
||||||
|
":source:__statelist" \
|
||||||
|
":destination: "
|
||||||
|
}
|
||||||
|
|
||||||
|
__state_push() {
|
||||||
|
_arguments \
|
||||||
|
"-force[Write the state even if lineages don't match or the remote serial is higher.]" \
|
||||||
|
'-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
|
||||||
|
"-lock-timeout=[(0s) Duration to retry a state lock.]" \
|
||||||
|
"::" \
|
||||||
|
":destination:_files"
|
||||||
|
}
|
||||||
|
|
||||||
|
__state_replace_provider() {
|
||||||
|
_arguments \
|
||||||
|
'-auto-approve[Skip interactive approval.]' \
|
||||||
|
'-backup=[(PATH) Path where Terraform should write the backup for the state file. This can"t be disabled. If not set, Terraform will write it to the same path as the state file with a ".backup" extension.]:backupfile:_files -g "*.backup"' \
|
||||||
|
"-lock=[(true) Lock the state files when locking is supported.]:lock:(true false)" \
|
||||||
|
"-lock-timeout=[(0s) Duration to retry a state lock.]" \
|
||||||
|
'-state=[(PATH) Path to the source state file. Defaults to the configured backend, or "terraform.tfstate"]:statefile:_files -g "*.tfstate"' \
|
||||||
|
":from_provider_fqn:" \
|
||||||
|
":to_provider_fqn:"
|
||||||
|
}
|
||||||
|
|
||||||
|
__state_rm() {
|
||||||
|
_arguments \
|
||||||
|
"-dry-run[If set, prints out what would've been removed but doesn't actually remove anything.]" \
|
||||||
|
'-backup=[(PATH) Path where Terraform should write the backup for the original state.]::backupfile:_files -g "*.backup"' \
|
||||||
|
"-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)" \
|
||||||
|
"-lock-timeout=[(0s) Duration to retry a state lock.]" \
|
||||||
|
'-state=[(PATH) Path to the state file to update. Defaults to the current workspace state.]:statefile:_files -g "*.tfstate"' \
|
||||||
|
"*:address:__statelist"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
__state_show() {
|
||||||
|
_arguments \
|
||||||
|
'-state=[(statefile) Path to a Terraform state file to use to look up Terraform-managed resources. By default it will use the state "terraform.tfstate" if it exists.]:statefile:_files -g "*.tfstate"' \
|
||||||
|
"*:address:__statelist"
|
||||||
|
}
|
||||||
|
|
||||||
|
__statelist() {
|
||||||
|
compadd $(terraform state list $opt_args[-state])
|
||||||
|
}
|
||||||
|
|
||||||
|
__taint() {
|
||||||
|
_arguments \
|
||||||
|
'-allow-missing[If specified, the command will succeed (exit code 0) even if the resource is missing.]' \
|
||||||
|
'-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]:backupfile:_files -g "*.backup"' \
|
||||||
|
'-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
|
||||||
|
'-lock-timeout=[(0s) Duration to retry a state lock.]' \
|
||||||
|
'-module=[(path) The module path where the resource lives. By default this will be root. Child modules can be specified by names. Ex. "consul" or "consul.vpc" (nested modules).]' \
|
||||||
|
'-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]:statefile:_files -g "*.tfstate"' \
|
||||||
|
'-state-out=[(path) Path to write updated state file. By default, the "-state" path will be used.]:statefile:_files -g "*.tfstate"' \
|
||||||
|
"*:address:__statelist"
|
||||||
|
}
|
||||||
|
|
||||||
|
__untaint() {
|
||||||
|
_arguments \
|
||||||
|
'-allow-missing[If specified, the command will succeed (exit code 0) even if the resource is missing.]' \
|
||||||
|
'-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]:backupfile:_files -g "*.backup"' \
|
||||||
|
'-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
|
||||||
|
'-lock-timeout=[(0s) Duration to retry a state lock.]' \
|
||||||
|
'-module=[(path) The module path where the resource lives. By default this will be root. Child modules can be specified by names. Ex. "consul" or "consul.vpc" (nested modules).]' \
|
||||||
|
'-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]:statefile:_files -g "*.tfstate"' \
|
||||||
|
'-state-out=[(path) Path to write updated state file. By default, the "-state" path will be used.]:statefile:_files -g "*.tfstate"'
|
||||||
|
}
|
||||||
|
|
||||||
|
__validate() {
|
||||||
|
_arguments \
|
||||||
|
'-no-color[If specified, output will not contain any color.]' \
|
||||||
|
'-json[Produce output in a machine-readable JSON format, suitable for use in text editor integrations and other automated systems.]' \
|
||||||
|
':dir:_files -/'
|
||||||
|
}
|
||||||
|
|
||||||
|
__version() {
|
||||||
|
_arguments \
|
||||||
|
'-json[Output the version information as a JSON object.]'
|
||||||
|
}
|
||||||
|
|
||||||
|
__workspace() {
|
||||||
|
local -a __workspace_cmds
|
||||||
|
__workspace_cmds=(
|
||||||
|
'delete:Delete a workspace'
|
||||||
|
'list:List Workspaces'
|
||||||
|
'new:Create a new workspace'
|
||||||
|
'select:Select a workspace'
|
||||||
|
'show:Show the name of the current workspace'
|
||||||
|
)
|
||||||
|
_describe -t workspace "workspace commands" __workspace_cmds
|
||||||
|
}
|
||||||
|
|
||||||
|
_arguments '*:: :->command'
|
||||||
|
|
||||||
|
if (( CURRENT == 1 )); then
|
||||||
|
_describe -t commands "terraform command" _terraform_cmds
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
local -a _command_args
|
||||||
|
case "$words[1]" in
|
||||||
|
0.12upgrade)
|
||||||
|
__012upgrade ;;
|
||||||
|
0.13upgrade)
|
||||||
|
__013upgrade ;;
|
||||||
|
apply)
|
||||||
|
__apply ;;
|
||||||
|
console)
|
||||||
|
__console;;
|
||||||
|
destroy)
|
||||||
|
__destroy ;;
|
||||||
|
fmt)
|
||||||
|
__fmt;;
|
||||||
|
force-unlock)
|
||||||
|
__force_unlock;;
|
||||||
|
get)
|
||||||
|
__get ;;
|
||||||
|
graph)
|
||||||
|
__graph ;;
|
||||||
|
import)
|
||||||
|
__import;;
|
||||||
|
init)
|
||||||
|
__init ;;
|
||||||
|
login)
|
||||||
|
__login ;;
|
||||||
|
logout)
|
||||||
|
__logout ;;
|
||||||
|
output)
|
||||||
|
__output ;;
|
||||||
|
plan)
|
||||||
|
__plan ;;
|
||||||
|
providers)
|
||||||
|
test $CURRENT -lt 3 && __providers
|
||||||
|
[[ $words[2] = "mirror" ]] && __providers_mirror
|
||||||
|
[[ $words[2] = "schema" ]] && __providers_schema
|
||||||
|
;;
|
||||||
|
refresh)
|
||||||
|
__refresh ;;
|
||||||
|
show)
|
||||||
|
__show ;;
|
||||||
|
state)
|
||||||
|
test $CURRENT -lt 3 && __state
|
||||||
|
[[ $words[2] = "list" ]] && __state_list
|
||||||
|
[[ $words[2] = "mv" ]] && __state_mv
|
||||||
|
[[ $words[2] = "push" ]] && __state_push
|
||||||
|
[[ $words[2] = "replace-provider" ]] && __state_replace_provider
|
||||||
|
[[ $words[2] = "rm" ]] && __state_rm
|
||||||
|
[[ $words[2] = "show" ]] && __state_show
|
||||||
|
;;
|
||||||
|
taint)
|
||||||
|
__taint ;;
|
||||||
|
untaint)
|
||||||
|
__untaint ;;
|
||||||
|
validate)
|
||||||
|
__validate ;;
|
||||||
|
version)
|
||||||
|
__version ;;
|
||||||
|
workspace)
|
||||||
|
test $CURRENT -lt 3 && __workspace ;;
|
||||||
|
esac
|
|
@ -0,0 +1,35 @@
|
||||||
|
# Global variables to cache the last known .terraform directory and its corresponding workspace name
|
||||||
|
__TERRAFORM_WORKSPACE_CACHE=""
|
||||||
|
__TERRAFORM_DIRECTORY_CACHE=""
|
||||||
|
|
||||||
|
# Function to find the .terraform directory in the current or any parent directory
|
||||||
|
__find_terraform_directory() {
|
||||||
|
local current_dir="$PWD"
|
||||||
|
while [[ "$current_dir" != "/" ]]; do
|
||||||
|
if [[ -d "${current_dir}/.terraform" ]]; then
|
||||||
|
echo "${current_dir}/.terraform"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
current_dir="$(dirname "$current_dir")"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to update the Terraform workspace prompt based on the current working directory, utilizing the global cache variables
|
||||||
|
__update_terraform_workspace_prompt() {
|
||||||
|
local terraform_dir="$(__find_terraform_directory)"
|
||||||
|
if [[ -n "$terraform_dir" && "$terraform_dir" != "$__TERRAFORM_DIRECTORY_CACHE" ]]; then
|
||||||
|
__TERRAFORM_DIRECTORY_CACHE="$terraform_dir"
|
||||||
|
local workspace="$(terraform -chdir="$(dirname "${terraform_dir%/}")" workspace show 2>/dev/null)"
|
||||||
|
__TERRAFORM_WORKSPACE_CACHE="$workspace"
|
||||||
|
elif [[ -z "$terraform_dir" ]]; then
|
||||||
|
__TERRAFORM_DIRECTORY_CACHE=""
|
||||||
|
__TERRAFORM_WORKSPACE_CACHE=""
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Hooks to call the update function when the working directory changes or before each prompt is displayed
|
||||||
|
autoload -Uz add-zsh-hook
|
||||||
|
add-zsh-hook chpwd __update_terraform_workspace_prompt
|
||||||
|
add-zsh-hook precmd __update_terraform_workspace_prompt
|
||||||
|
|
||||||
|
complete -o nospace -C $(which terraform) terraform
|
|
@ -52,6 +52,7 @@ Available search contexts are:
|
||||||
| `gopkg` | `https://pkg.go.dev/search?m=package&q=` |
|
| `gopkg` | `https://pkg.go.dev/search?m=package&q=` |
|
||||||
| `chatgpt` | `https://chatgpt.com/?q=` |
|
| `chatgpt` | `https://chatgpt.com/?q=` |
|
||||||
| `reddit` | `https://www.reddit.com/search/?q=` |
|
| `reddit` | `https://www.reddit.com/search/?q=` |
|
||||||
|
| `ppai` | `https://www.perplexity.ai/search/new?q=` |
|
||||||
|
|
||||||
Also there are aliases for bang-searching DuckDuckGo:
|
Also there are aliases for bang-searching DuckDuckGo:
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ function web_search() {
|
||||||
gopkg "https://pkg.go.dev/search?m=package&q="
|
gopkg "https://pkg.go.dev/search?m=package&q="
|
||||||
chatgpt "https://chatgpt.com/?q="
|
chatgpt "https://chatgpt.com/?q="
|
||||||
reddit "https://www.reddit.com/search/?q="
|
reddit "https://www.reddit.com/search/?q="
|
||||||
|
ppai "https://www.perplexity.ai/search/new?q="
|
||||||
)
|
)
|
||||||
|
|
||||||
# check whether the search engine is supported
|
# check whether the search engine is supported
|
||||||
|
@ -87,6 +88,7 @@ alias packagist='web_search packagist'
|
||||||
alias gopkg='web_search gopkg'
|
alias gopkg='web_search gopkg'
|
||||||
alias chatgpt='web_search chatgpt'
|
alias chatgpt='web_search chatgpt'
|
||||||
alias reddit='web_search reddit'
|
alias reddit='web_search reddit'
|
||||||
|
alias ppai='web_search ppai'
|
||||||
|
|
||||||
#add your own !bang searches here
|
#add your own !bang searches here
|
||||||
alias wiki='web_search duckduckgo \!w'
|
alias wiki='web_search duckduckgo \!w'
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2018-2023 Alexandros Kozak
|
Copyright (c) 2018-2024 Alexandros Kozak
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|
|
@ -6,15 +6,15 @@
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
Zsh-z is a command line tool that allows you to jump quickly to directories that you have visited frequently in the past, or recently -- but most often a combination of the two (a concept known as ["frecency"](https://en.wikipedia.org/wiki/Frecency)). It works by keeping track of when you go to directories and how much time you spend in them. It is then in the position to guess where you want to go when you type a partial string, e.g., `z src` might take you to `~/src/zsh`. `z zsh` might also get you there, and `z c/z` might prove to be even more specific -- it all depends on your habits and how much time you have been using Zsh-z to build up a database. After using Zsh-z for a little while, you will get to where you want to be by typing considerably less than you would need if you were using `cd`.
|
Zsh-z is a command-line tool that allows you to jump quickly to directories that you have visited frequently or recently -- but most often a combination of the two (a concept known as ["frecency"](https://en.wikipedia.org/wiki/Frecency)). It works by keeping track of when you go to directories and how much time you spend in them. Based on this data, it predicts where you want to go when you type a partial string. For example, `z src` might take you to `~/src/zsh`. `z zsh` might also get you there, and `z c/z` might prove to be even more specific -- it all depends on your habits and how long you have been using Zsh-z to build up a database. After using Zsh-z for a little while, you will get to where you want to be by typing considerably less than you would need to if you were using `cd`.
|
||||||
|
|
||||||
Zsh-z is a native Zsh port of [rupa/z](https://github.com/rupa/z), a tool written for `bash` and Zsh that uses embedded `awk` scripts to do the heavy lifting. It was quite possibly my most used command line tool for a couple of years. I decided to translate it, `awk` parts and all, into pure Zsh script, to see if by eliminating calls to external tools (`awk`, `sort`, `date`, `sed`, `mv`, `rm`, and `chown`) and reducing forking through subshells I could make it faster. The performance increase is impressive, particularly on systems where forking is slow, such as Cygwin, MSYS2, and WSL. I have found that, in those environments, switching directories using Zsh-z can be over 100% faster than it is using `rupa/z`.
|
Zsh-z is a native Zsh port of [`rupa/z`](https://github.com/rupa/z), a tool written for `bash` and Zsh that uses embedded `awk` scripts to do the heavy lifting. `rupa/z` was my most used command-line tool for a couple of years. I decided to translate it, `awk` parts and all, into pure Zsh script, to see if by eliminating calls to external tools (`awk`, `sort`, `date`, `sed`, `mv`, `rm`, and `chown`) and reducing forking through subshells I could make it faster. The performance increase is impressive, particularly on systems where forking is slow, such as Cygwin, MSYS2, and WSL. I have found that in those environments, switching directories using Zsh-z can be over 100% faster than it is using `rupa/z`.
|
||||||
|
|
||||||
There is a noteworthy stability increase as well. Race conditions have always been a problem with `rupa/z`, and users of that utility will occasionally lose their `.z` databases. By having Zsh-z only use Zsh (`rupa/z` uses a hybrid shell code that works on `bash` as well), I have been able to implement a `zsh/system`-based file-locking mechanism similar to [the one @mafredri once proposed for `rupa/z`](https://github.com/rupa/z/pull/199). It is now nearly impossible to crash the database, even through extreme testing.
|
There is also a significant stability improvement. Race conditions have always been a problem with `rupa/z`, and users of that utility occasionally lose their `~/.z` databases. By having Zsh-z only use Zsh (`rupa/z` uses a hybrid shell code standard that works on `bash` as well), I have been able to implement a `zsh/system`-based file-locking mechanism similar to [the one @mafredri once proposed for `rupa/z`](https://github.com/rupa/z/pull/199). It is now nearly impossible to crash the database.
|
||||||
|
|
||||||
There are other, smaller improvements which I try to document in [Improvements and Fixes](#improvements-and-fixes). These include the new default behavior of sorting your tab completions by frecency rather than just letting Zsh sort the raw results alphabetically (a behavior which can be restored if you like it -- [see below](#settings)).
|
There are other, smaller improvements which I document below in [Improvements and Fixes](#improvements-and-fixes). For instance, tab completions are now sorted by frecency by default rather than alphabetically (the latter behavior can be restored if you like it -- [see below](#settings)).
|
||||||
|
|
||||||
Zsh-z is a drop-in replacement for `rupa/z` and will, by default, use the same database (`~/.z`), so you can go on using `rupa/z` when you launch `bash`.
|
Zsh-z is a drop-in replacement for `rupa/z` and will, by default, use the same database (`~/.z`, or whatever database file you specify), so you can go on using `rupa/z` when you launch `bash`.
|
||||||
|
|
||||||
## Table of Contents
|
## Table of Contents
|
||||||
- [News](#news)
|
- [News](#news)
|
||||||
|
@ -37,13 +37,13 @@ Zsh-z is a drop-in replacement for `rupa/z` and will, by default, use the same d
|
||||||
- August 24, 2023
|
- August 24, 2023
|
||||||
+ Zsh-z will now run when `setopt NO_UNSET` has been enabled (props @ntninja).
|
+ Zsh-z will now run when `setopt NO_UNSET` has been enabled (props @ntninja).
|
||||||
- August 23, 2023
|
- August 23, 2023
|
||||||
+ Better logic for loading `zsh/files` (props @z0rc)
|
+ Better logic for loading `zsh/files` (props @z0rc).
|
||||||
- August 2, 2023
|
- August 2, 2023
|
||||||
+ Zsh-z still uses the `zsh/files` module when possible, but will fall back on the standard `chown`, `mv`, and `rm` commands in its absence.
|
+ Zsh-z still uses the `zsh/files` module when possible but will fall back on the standard `chown`, `mv`, and `rm` commands in its absence.
|
||||||
- April 27, 2023
|
- April 27, 2023
|
||||||
+ Zsh-z now allows the user to specify the directory-changing command using the `ZSHZ_CD` environment variable (default: `builtin cd`; props @basnijholt).
|
+ Zsh-z now allows the user to specify the directory-changing command using the `ZSHZ_CD` environment variable (default: `builtin cd`; props @basnijholt).
|
||||||
- January 27, 2023
|
- January 27, 2023
|
||||||
+ If the datafile directory specified by `ZSHZ_DATA` or `_Z_DATA` does not already exist, create it (props @mattmc3).
|
+ If the database file directory specified by `ZSHZ_DATA` or `_Z_DATA` does not already exist, create it (props @mattmc3).
|
||||||
- June 29, 2022
|
- June 29, 2022
|
||||||
+ Zsh-z is less likely to leave temporary files sitting around (props @mafredri).
|
+ Zsh-z is less likely to leave temporary files sitting around (props @mafredri).
|
||||||
- June 27, 2022
|
- June 27, 2022
|
||||||
|
@ -69,7 +69,7 @@ Zsh-z is a drop-in replacement for `rupa/z` and will, by default, use the same d
|
||||||
+ Fixed the explanation string printed during completion so that it may be formatted with `zstyle`.
|
+ Fixed the explanation string printed during completion so that it may be formatted with `zstyle`.
|
||||||
+ Zsh-z now declares `ZSHZ_EXCLUDE_DIRS` as an array with unique elements so that you do not have to.
|
+ Zsh-z now declares `ZSHZ_EXCLUDE_DIRS` as an array with unique elements so that you do not have to.
|
||||||
- July 29, 2021
|
- July 29, 2021
|
||||||
+ Temporarily disabling use of `print -v`, which seems to be mangling CJK multibyte strings.
|
+ Temporarily disabling the use of `print -v`, which was mangling CJK multibyte strings.
|
||||||
- July 27, 2021
|
- July 27, 2021
|
||||||
+ Internal escaping of path names now works with older versions of ZSH.
|
+ Internal escaping of path names now works with older versions of ZSH.
|
||||||
+ Zsh-z now detects and discards any incomplete or incorrectly formatted database entries.
|
+ Zsh-z now detects and discards any incomplete or incorrectly formatted database entries.
|
||||||
|
@ -102,7 +102,7 @@ Zsh-z is a drop-in replacement for `rupa/z` and will, by default, use the same d
|
||||||
- December 22, 2020
|
- December 22, 2020
|
||||||
+ `ZSHZ_CASE`: when set to `ignore`, pattern matching is case-insensitive; when set to `smart`, patterns are matched case-insensitively when they are all lowercase and case-sensitively when they have uppercase characters in them (a behavior very much like Vim's `smartcase` setting).
|
+ `ZSHZ_CASE`: when set to `ignore`, pattern matching is case-insensitive; when set to `smart`, patterns are matched case-insensitively when they are all lowercase and case-sensitively when they have uppercase characters in them (a behavior very much like Vim's `smartcase` setting).
|
||||||
+ `ZSHZ_KEEP_DIRS` is an array of directory names that should not be removed from the database, even if they are not currently available (useful when a drive is not always mounted).
|
+ `ZSHZ_KEEP_DIRS` is an array of directory names that should not be removed from the database, even if they are not currently available (useful when a drive is not always mounted).
|
||||||
+ Symlinked datafiles were having their symlinks overwritten; this bug has been fixed.
|
+ Symlinked database files were having their symlinks overwritten; this bug has been fixed.
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ For tab completion to work, `_zshz` *must* be in the same directory as `zsh-z.pl
|
||||||
|
|
||||||
autoload -U compinit; compinit
|
autoload -U compinit; compinit
|
||||||
|
|
||||||
in your .zshrc somewhere below where you source `zsh-z.plugin.zsh`.
|
in your `.zshrc` somewhere below where you source `zsh-z.plugin.zsh`.
|
||||||
|
|
||||||
If you add
|
If you add
|
||||||
|
|
||||||
|
@ -228,7 +228,7 @@ Add the line
|
||||||
|
|
||||||
to your `.zshrc`.
|
to your `.zshrc`.
|
||||||
|
|
||||||
`zsh-z` supports `zinit`'s `unload` feature; just run `zinit unload agkozak/zshz` to restore the shell to its state before `zsh-z` was loaded.
|
Zsh-z supports `zinit`'s `unload` feature; just run `zinit unload agkozak/zsh-z` to restore the shell to its state before Zsh-z was loaded.
|
||||||
|
|
||||||
### For [Znap](https://github.com/marlonrichert/zsh-snap) users
|
### For [Znap](https://github.com/marlonrichert/zsh-snap) users
|
||||||
|
|
||||||
|
@ -249,7 +249,7 @@ somewhere above the line that says `zplug load`. Then run
|
||||||
zplug install
|
zplug install
|
||||||
zplug load
|
zplug load
|
||||||
|
|
||||||
to install `zsh-z`.
|
to install Zsh-z.
|
||||||
|
|
||||||
## Command Line Options
|
## Command Line Options
|
||||||
|
|
||||||
|
@ -263,9 +263,9 @@ to install `zsh-z`.
|
||||||
- `-x` Remove a directory (by default, the current directory) from the database
|
- `-x` Remove a directory (by default, the current directory) from the database
|
||||||
- `-xR` Remove a directory (by default, the current directory) and its subdirectories from the database
|
- `-xR` Remove a directory (by default, the current directory) and its subdirectories from the database
|
||||||
|
|
||||||
# Settings
|
## Settings
|
||||||
|
|
||||||
Zsh-z has environment variables (they all begin with `ZSHZ_`) that change its behavior if you set them; you can also keep your old ones if you have been using `rupa/z` (they begin with `_Z_`).
|
Zsh-z has environment variables (they all begin with `ZSHZ_`) that change its behavior if you set them. You can also keep your old ones if you have been using `rupa/z` (whose environment variables begin with `_Z_`).
|
||||||
|
|
||||||
* `ZSHZ_CMD` changes the command name (default: `z`)
|
* `ZSHZ_CMD` changes the command name (default: `z`)
|
||||||
* `ZSHZ_CD` specifies the default directory-changing command (default: `builtin cd`)
|
* `ZSHZ_CD` specifies the default directory-changing command (default: `builtin cd`)
|
||||||
|
@ -324,19 +324,18 @@ A good example might involve a directory tree that has Git repositories within i
|
||||||
|
|
||||||
(As a Zsh user, I tend to use `**` instead of `find`, but it is good to see how deep your directory trees go before doing that.)
|
(As a Zsh user, I tend to use `**` instead of `find`, but it is good to see how deep your directory trees go before doing that.)
|
||||||
|
|
||||||
|
|
||||||
## Other Improvements and Fixes
|
## Other Improvements and Fixes
|
||||||
|
|
||||||
* `z -x` works, with the help of `chpwd_functions`.
|
* `z -x` works, with the help of `chpwd_functions`.
|
||||||
* Zsh-z works on Solaris.
|
* Zsh-z is compatible with Solaris.
|
||||||
* Zsh-z uses the "new" `zshcompsys` completion system instead of the old `compctl` one.
|
* Zsh-z uses the "new" `zshcompsys` completion system instead of the old `compctl` one.
|
||||||
* There is no error message when the database file has not yet been created.
|
* No error message is displayed when the database file has not yet been created.
|
||||||
* There is support for special characters (e.g., `[`) in directory names.
|
* Special characters (e.g., `[`) in directory names are now supported.
|
||||||
* If `z -l` only returns one match, a common root is not printed.
|
* If `z -l` returns only one match, a common root is not printed.
|
||||||
* Exit status codes increasingly make sense.
|
* Exit status codes are more logical.
|
||||||
* Completions work with options `-c`, `-r`, and `-t`.
|
* Completions now work with options `-c`, `-r`, and `-t`.
|
||||||
* If `~/foo` and `~/foob` are matches, `~/foo` is *not* the common root. Only a common parent directory can be a common root.
|
* If `~/foo` and `~/foob` are matches, `~/foo` is no longer considered the common root. Only a common parent directory can be a common root.
|
||||||
* `z -x` and the new, recursive `z -xR` can take an argument so that you can remove directories other than `PWD` from the database.
|
* `z -x` and the new, recursive `z -xR` can now accept an argument so that you can remove directories other than `PWD` from the database.
|
||||||
|
|
||||||
## Migrating from Other Tools
|
## Migrating from Other Tools
|
||||||
|
|
||||||
|
@ -358,7 +357,7 @@ the line
|
||||||
|
|
||||||
That will re-bind `z` or the command of your choice to the underlying Zsh-z function.
|
That will re-bind `z` or the command of your choice to the underlying Zsh-z function.
|
||||||
|
|
||||||
## Known Bugs
|
## Known Bug
|
||||||
It is possible to run a completion on a string with spaces in it, e.g., `z us bi<TAB>` might take you to `/usr/local/bin`. This works, but as things stand, after the completion the command line reads
|
It is possible to run a completion on a string with spaces in it, e.g., `z us bi<TAB>` might take you to `/usr/local/bin`. This works, but as things stand, after the completion the command line reads
|
||||||
|
|
||||||
z us /usr/local/bin.
|
z us /usr/local/bin.
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#
|
#
|
||||||
# https://github.com/agkozak/zsh-z
|
# https://github.com/agkozak/zsh-z
|
||||||
#
|
#
|
||||||
# Copyright (c) 2018-2023 Alexandros Kozak
|
# Copyright (c) 2018-2024 Alexandros Kozak
|
||||||
#
|
#
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
# of this software and associated documentation files (the "Software"), to deal
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -120,7 +120,6 @@ fi
|
||||||
[[ ${builtins[zf_mv]-} == 'defined' ]] && ZSHZ[MV]='zf_mv'
|
[[ ${builtins[zf_mv]-} == 'defined' ]] && ZSHZ[MV]='zf_mv'
|
||||||
[[ ${builtins[zf_rm]-} == 'defined' ]] && ZSHZ[RM]='zf_rm'
|
[[ ${builtins[zf_rm]-} == 'defined' ]] && ZSHZ[RM]='zf_rm'
|
||||||
|
|
||||||
|
|
||||||
# Load zsh/system, if necessary
|
# Load zsh/system, if necessary
|
||||||
[[ ${modules[zsh/system]-} == 'loaded' ]] || zmodload zsh/system &> /dev/null
|
[[ ${modules[zsh/system]-} == 'loaded' ]] || zmodload zsh/system &> /dev/null
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,8 @@ function afmagic_dashes {
|
||||||
# the prompt, account for it when returning the number of dashes
|
# the prompt, account for it when returning the number of dashes
|
||||||
if [[ -n "$python_env" && "$PS1" = *\(${python_env}\)* ]]; then
|
if [[ -n "$python_env" && "$PS1" = *\(${python_env}\)* ]]; then
|
||||||
echo $(( COLUMNS - ${#python_env} - 3 ))
|
echo $(( COLUMNS - ${#python_env} - 3 ))
|
||||||
|
elif [[ -n "$VIRTUAL_ENV_PROMPT" && "$PS1" = *${VIRTUAL_ENV_PROMPT}* ]]; then
|
||||||
|
echo $(( COLUMNS - ${#VIRTUAL_ENV_PROMPT} ))
|
||||||
else
|
else
|
||||||
echo $COLUMNS
|
echo $COLUMNS
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue