From d157fc60c93fa59e757921b503e9594bd23b422c Mon Sep 17 00:00:00 2001 From: Ben Woodward Date: Thu, 21 Mar 2024 19:46:40 +0000 Subject: [PATCH 01/79] fix(mise): update environment when loading the plugin (#12294) --- plugins/mise/mise.plugin.zsh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/mise/mise.plugin.zsh b/plugins/mise/mise.plugin.zsh index 1b4d3ae81..357174d91 100644 --- a/plugins/mise/mise.plugin.zsh +++ b/plugins/mise/mise.plugin.zsh @@ -11,6 +11,9 @@ fi # Load mise hooks eval "$($__mise activate zsh)" +# Hook mise into current environment +eval "$($__mise hook-env -s zsh)" + # If the completion file doesn't exist yet, we need to autoload it and # bind it to `mise`. Otherwise, compinit will have already done that. if [[ ! -f "$ZSH_CACHE_DIR/completions/_$__mise" ]]; then From 3e05befaeee60a0f8522f470292c75046b05ceb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Schl=C3=BCter?= Date: Mon, 25 Mar 2024 12:27:21 +0100 Subject: [PATCH 02/79] fix(ssh-agent): don't start new agent if screen/tmux symlink exists (#12297) --- plugins/ssh-agent/ssh-agent.plugin.zsh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/ssh-agent/ssh-agent.plugin.zsh b/plugins/ssh-agent/ssh-agent.plugin.zsh index 49ad95a11..77c422ce1 100644 --- a/plugins/ssh-agent/ssh-agent.plugin.zsh +++ b/plugins/ssh-agent/ssh-agent.plugin.zsh @@ -98,8 +98,10 @@ function _add_identities() { # Add a nifty symlink for screen/tmux if agent forwarding is enabled if zstyle -t :omz:plugins:ssh-agent agent-forwarding \ - && [[ -n "$SSH_AUTH_SOCK" && ! -L "$SSH_AUTH_SOCK" ]]; then - ln -sf "$SSH_AUTH_SOCK" /tmp/ssh-agent-$USERNAME-screen + && [[ -n "$SSH_AUTH_SOCK" ]]; then + if [[ ! -L "$SSH_AUTH_SOCK" ]]; then + ln -sf "$SSH_AUTH_SOCK" /tmp/ssh-agent-$USERNAME-screen + fi else _start_agent fi From 7647c79bae1542b5f4dddc85b16058df7f83fc6c Mon Sep 17 00:00:00 2001 From: Jim Weller <31997291+jimweller@users.noreply.github.com> Date: Tue, 26 Mar 2024 01:48:14 -0700 Subject: [PATCH 03/79] feat(jira): add help/usage cmd (#12293) Co-authored-by: Carlo Sala --- plugins/jira/README.md | 5 ++++- plugins/jira/_jira | 1 + plugins/jira/jira.plugin.zsh | 17 +++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/plugins/jira/README.md b/plugins/jira/README.md index d78ea15a4..b1d8a8bc6 100644 --- a/plugins/jira/README.md +++ b/plugins/jira/README.md @@ -16,18 +16,21 @@ This plugin supplies one command, `jira`, through which all its features are exp ## Commands +`jira help` or `jira usage` will print the below usage instructions + | Command | Description | | :------------ | :-------------------------------------------------------- | | `jira` | Performs the default action | | `jira new` | Opens a new Jira issue dialogue | | `jira ABC-123` | Opens an existing issue | | `jira ABC-123 m` | Opens an existing issue for adding a comment | -| `jira dashboard [rapid_view]` | # opens your JIRA dashboard | +| `jira dashboard [rapid_view]` | Opens your JIRA dashboard | | `jira mine` | Queries for your own issues | | `jira tempo` | Opens your JIRA Tempo | | `jira reported [username]` | Queries for issues reported by a user | | `jira assigned [username]` | Queries for issues assigned to a user | | `jira branch` | Opens an existing issue matching the current branch name | +| `jira help` | Prints usage instructions | ### Jira Branch usage notes diff --git a/plugins/jira/_jira b/plugins/jira/_jira index 0e37b7e9d..5f7dcd09d 100644 --- a/plugins/jira/_jira +++ b/plugins/jira/_jira @@ -11,6 +11,7 @@ _1st_arguments=( 'assigned:search for issues assigned to a user' 'branch:open the issue named after the git branch of the current directory' 'dumpconfig:display effective jira configuration' + 'help:print usage help to stdout' ) _arguments -C \ diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh index b6ee9f100..9bcf4cc7b 100644 --- a/plugins/jira/jira.plugin.zsh +++ b/plugins/jira/jira.plugin.zsh @@ -2,6 +2,21 @@ # # See README.md for details +function _jira_usage() { +cat < Date: Tue, 26 Mar 2024 09:52:01 +0100 Subject: [PATCH 04/79] feat(terraform): add `tft` (`terraform test`) (#12299) --- plugins/terraform/README.md | 27 +++++++++++++------------- plugins/terraform/terraform.plugin.zsh | 1 + 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/plugins/terraform/README.md b/plugins/terraform/README.md index 135fd78ef..2b535517c 100644 --- a/plugins/terraform/README.md +++ b/plugins/terraform/README.md @@ -15,19 +15,20 @@ plugins=(... terraform) ## Aliases -| Alias | Command | -| ----- | -------------------- | -| `tf` | `terraform` | -| `tfa` | `terraform apply` | -| `tfc` | `terraform console` | -| `tfd` | `terraform destroy` | -| `tff` | `terraform fmt` | -| `tfi` | `terraform init` | -| `tfo` | `terraform output` | -| `tfp` | `terraform plan` | -| `tfv` | `terraform validate` | -| `tfs` | `terraform state` | -| `tfsh`| `terraform show` | +| Alias | Command | +| ------ | -------------------- | +| `tf` | `terraform` | +| `tfa` | `terraform apply` | +| `tfc` | `terraform console` | +| `tfd` | `terraform destroy` | +| `tff` | `terraform fmt` | +| `tfi` | `terraform init` | +| `tfo` | `terraform output` | +| `tfp` | `terraform plan` | +| `tfv` | `terraform validate` | +| `tfs` | `terraform state` | +| `tft` | `terraform test` | +| `tfsh` | `terraform show` | ## Prompt function diff --git a/plugins/terraform/terraform.plugin.zsh b/plugins/terraform/terraform.plugin.zsh index f66a8eac9..8ef392efd 100644 --- a/plugins/terraform/terraform.plugin.zsh +++ b/plugins/terraform/terraform.plugin.zsh @@ -25,4 +25,5 @@ alias tfo='terraform output' alias tfp='terraform plan' alias tfv='terraform validate' alias tfs='terraform state' +alias tft='terraform test' alias tfsh='terraform show' From a168efe73e467c7164ef9b49dea61e9aefd27a48 Mon Sep 17 00:00:00 2001 From: Zikoeng Xi Date: Tue, 26 Mar 2024 16:54:04 +0800 Subject: [PATCH 05/79] fix(poetry-env): activate only if env exists (#12301) --- plugins/poetry-env/poetry-env.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/poetry-env/poetry-env.plugin.zsh b/plugins/poetry-env/poetry-env.plugin.zsh index 86e5fad4e..97ca52492 100644 --- a/plugins/poetry-env/poetry-env.plugin.zsh +++ b/plugins/poetry-env/poetry-env.plugin.zsh @@ -14,10 +14,10 @@ _togglePoetryShell() { # activate the environment if pyproject.toml exists if [[ "$poetry_active" != 1 ]]; then if [[ -f "$PWD/pyproject.toml" ]]; then - if grep -q 'tool.poetry' "$PWD/pyproject.toml"; then + if grep -q 'tool.poetry' "$PWD/pyproject.toml" && venv_dir=$(poetry env info --path); then export poetry_active=1 export poetry_dir="$PWD" - source "$(poetry env info --path)/bin/activate" + source "${venv_dir}/bin/activate" fi fi fi From 1d09c6bb0a950756a65b02457842933e3aa493eb Mon Sep 17 00:00:00 2001 From: vladislav doster <10052309+vladdoster@users.noreply.github.com> Date: Tue, 26 Mar 2024 03:55:16 -0500 Subject: [PATCH 06/79] style: remove trailing whitespace (#12303) --- custom/example.zsh | 6 ++--- custom/themes/example.zsh-theme | 2 +- lib/compfix.zsh | 2 +- lib/diagnostics.zsh | 24 +++++++++---------- oh-my-zsh.sh | 2 +- plugins/ansible/README.md | 2 +- plugins/aws/aws.plugin.zsh | 2 +- plugins/branch/README.md | 2 +- plugins/chruby/chruby.plugin.zsh | 4 ++-- plugins/cloudfoundry/README.md | 2 +- plugins/coffee/README.md | 2 +- plugins/compleat/compleat.plugin.zsh | 4 ++-- plugins/copybuffer/copybuffer.plugin.zsh | 2 +- plugins/dash/README.md | 2 +- plugins/dotnet/dotnet.plugin.zsh | 2 +- plugins/emoji/emoji.plugin.zsh | 18 +++++++------- plugins/emotty/emotty.plugin.zsh | 2 +- plugins/encode64/README.md | 2 +- plugins/fancy-ctrl-z/README.md | 8 +++---- plugins/fastfile/README.md | 4 ++-- plugins/forklift/forklift.plugin.zsh | 4 ++-- plugins/fzf/fzf.plugin.zsh | 2 +- plugins/gnu-utils/gnu-utils.plugin.zsh | 4 ++-- plugins/grails/grails.plugin.zsh | 14 +++++------ plugins/history-substring-search/README.md | 8 +++---- plugins/ionic/ionic.plugin.zsh | 12 +++++----- plugins/iterm2/README.md | 2 +- plugins/iterm2/iterm2.plugin.zsh | 2 +- plugins/iterm2/iterm2_shell_integration.zsh | 4 ++-- plugins/jira/README.md | 2 +- plugins/juju/juju.plugin.zsh | 2 +- plugins/kn/kn.plugin.zsh | 2 +- plugins/macports/_port | 8 +++---- plugins/marked2/README.md | 2 +- plugins/marktext/README.md | 2 +- plugins/mongo-atlas/README.md | 2 +- plugins/n98-magerun/n98-magerun.plugin.zsh | 2 +- plugins/nmap/nmap.plugin.zsh | 2 +- plugins/nomad/_nomad | 2 +- plugins/npm/npm.plugin.zsh | 2 +- plugins/nvm/nvm.plugin.zsh | 2 +- plugins/otp/README.md | 2 +- plugins/pm2/_pm2 | 2 +- plugins/poetry-env/README.md | 2 +- plugins/ros/_ros | 2 +- plugins/sbt/sbt.plugin.zsh | 2 +- plugins/screen/screen.plugin.zsh | 2 +- plugins/singlechar/singlechar.plugin.zsh | 2 +- plugins/systemadmin/README.md | 2 +- plugins/thor/README.md | 2 +- plugins/ufw/README.md | 2 +- plugins/vagrant-prompt/README.md | 2 +- plugins/vi-mode/README.md | 2 +- plugins/vim-interaction/README.md | 2 +- .../vim-interaction.plugin.zsh | 2 +- .../virtualenvwrapper.plugin.zsh | 2 +- plugins/wd/README.md | 2 +- plugins/wd/_wd.sh | 2 +- plugins/z/MANUAL.md | 2 +- themes/Soliah.zsh-theme | 10 ++++---- themes/adben.zsh-theme | 2 +- themes/agnoster.zsh-theme | 2 +- themes/avit.zsh-theme | 2 +- themes/crunch.zsh-theme | 6 ++--- themes/eastwood.zsh-theme | 2 +- themes/emotty.zsh-theme | 4 ++-- themes/essembeh.zsh-theme | 4 ++-- themes/josh.zsh-theme | 8 +++---- themes/junkfood.zsh-theme | 4 ++-- themes/mlh.zsh-theme | 2 +- themes/mortalscumbag.zsh-theme | 2 +- themes/sonicradish.zsh-theme | 2 +- themes/wedisagree.zsh-theme | 14 +++++------ 73 files changed, 138 insertions(+), 138 deletions(-) diff --git a/custom/example.zsh b/custom/example.zsh index 21a8d8be7..c194f49d7 100644 --- a/custom/example.zsh +++ b/custom/example.zsh @@ -1,12 +1,12 @@ # Put files in this folder to add your own custom functionality. # See: https://github.com/ohmyzsh/ohmyzsh/wiki/Customization -# +# # Files in the custom/ directory will be: # - loaded automatically by the init script, in alphabetical order # - loaded last, after all built-ins in the lib/ directory, to override them # - ignored by git by default -# +# # Example: add custom/shortcuts.zsh for shortcuts to your local projects -# +# # brainstormr=~/Projects/development/planetargon/brainstormr # cd $brainstormr diff --git a/custom/themes/example.zsh-theme b/custom/themes/example.zsh-theme index 494d029e8..5551207f8 100644 --- a/custom/themes/example.zsh-theme +++ b/custom/themes/example.zsh-theme @@ -1,6 +1,6 @@ # Put your custom themes in this folder. # See: https://github.com/ohmyzsh/ohmyzsh/wiki/Customization#overriding-and-adding-themes -# +# # Example: PROMPT="%{$fg[red]%}%n%{$reset_color%}@%{$fg[blue]%}%m %{$fg[yellow]%}%~ %{$reset_color%}%% " diff --git a/lib/compfix.zsh b/lib/compfix.zsh index b09b283f2..2fe9d9e64 100644 --- a/lib/compfix.zsh +++ b/lib/compfix.zsh @@ -13,7 +13,7 @@ function handle_completion_insecurities() { # /usr/share/zsh/5.0.6 # # Since the ignorable first line is printed to stderr and thus not captured, - # stderr is squelched to prevent this output from leaking to the user. + # stderr is squelched to prevent this output from leaking to the user. local -aU insecure_dirs insecure_dirs=( ${(f@):-"$(compaudit 2>/dev/null)"} ) diff --git a/lib/diagnostics.zsh b/lib/diagnostics.zsh index eaeba7d23..d67e6fab4 100644 --- a/lib/diagnostics.zsh +++ b/lib/diagnostics.zsh @@ -30,7 +30,7 @@ # # This is written in a defensive style so it still works (and can detect) cases when # basic functionality like echo and which have been redefined. In particular, almost -# everything is invoked with "builtin" or "command", to work in the face of user +# everything is invoked with "builtin" or "command", to work in the face of user # redefinitions. # # OPTIONS @@ -59,7 +59,7 @@ function omz_diagnostic_dump() { emulate -L zsh builtin echo "Generating diagnostic dump; please be patient..." - + local thisfcn=omz_diagnostic_dump local -A opts local opt_verbose opt_noverbose opt_outfile @@ -90,7 +90,7 @@ function omz_diagnostic_dump() { builtin echo builtin echo Diagnostic dump file created at: "$outfile" builtin echo - builtin echo To share this with OMZ developers, post it as a gist on GitHub + builtin echo To share this with OMZ developers, post it as a gist on GitHub builtin echo at "https://gist.github.com" and share the link to the gist. builtin echo builtin echo "WARNING: This dump file contains all your zsh and omz configuration files," @@ -105,8 +105,8 @@ function _omz_diag_dump_one_big_text() { builtin echo oh-my-zsh diagnostic dump builtin echo builtin echo $outfile - builtin echo - + builtin echo + # Basic system and zsh information command date command uname -a @@ -151,7 +151,7 @@ function _omz_diag_dump_one_big_text() { # Core command definitions _omz_diag_dump_check_core_commands || return 1 - builtin echo + builtin echo # ZSH Process state builtin echo Process state: @@ -167,7 +167,7 @@ function _omz_diag_dump_one_big_text() { #TODO: Should this include `env` instead of or in addition to `export`? builtin echo Exported: builtin echo $(builtin export | command sed 's/=.*//') - builtin echo + builtin echo builtin echo Locale: command locale builtin echo @@ -181,7 +181,7 @@ function _omz_diag_dump_one_big_text() { builtin echo builtin echo 'compaudit output:' compaudit - builtin echo + builtin echo builtin echo '$fpath directories:' command ls -lad $fpath builtin echo @@ -224,7 +224,7 @@ function _omz_diag_dump_one_big_text() { local cfgfile cfgfiles # Some files for bash that zsh does not use are intentionally included # to help with diagnosing behavior differences between bash and zsh - cfgfiles=( /etc/zshenv /etc/zprofile /etc/zshrc /etc/zlogin /etc/zlogout + cfgfiles=( /etc/zshenv /etc/zprofile /etc/zshrc /etc/zlogin /etc/zlogout $zdotdir/.zshenv $zdotdir/.zprofile $zdotdir/.zshrc $zdotdir/.zlogin $zdotdir/.zlogout ~/.zsh.pre-oh-my-zsh /etc/bashrc /etc/profile ~/.bashrc ~/.profile ~/.bash_profile ~/.bash_logout ) @@ -258,8 +258,8 @@ function _omz_diag_dump_check_core_commands() { # (For back-compatibility, if any of these are newish, they should be removed, # or at least made conditional on the version of the current running zsh.) # "history" is also excluded because OMZ is known to redefine that - reserved_words=( do done esac then elif else fi for case if while function - repeat time until select coproc nocorrect foreach end '!' '[[' '{' '}' + reserved_words=( do done esac then elif else fi for case if while function + repeat time until select coproc nocorrect foreach end '!' '[[' '{' '}' ) builtins=( alias autoload bg bindkey break builtin bye cd chdir command comparguments compcall compctl compdescribe compfiles compgroups compquote comptags @@ -331,7 +331,7 @@ function _omz_diag_dump_os_specific_version() { case "$OSTYPE" in darwin*) osname=$(command sw_vers -productName) - osver=$(command sw_vers -productVersion) + osver=$(command sw_vers -productVersion) builtin echo "OS Version: $osname $osver build $(sw_vers -buildVersion)" ;; cygwin) diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index 137ca3b6f..2fb20298a 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -152,7 +152,7 @@ unset zcompdump_revision zcompdump_fpath zcompdump_refresh # zcompile the completion dump file if the .zwc is older or missing. if command mkdir "${ZSH_COMPDUMP}.lock" 2>/dev/null; then zrecompile -q -p "$ZSH_COMPDUMP" - command rm -rf "$ZSH_COMPDUMP.zwc.old" "${ZSH_COMPDUMP}.lock" + command rm -rf "$ZSH_COMPDUMP.zwc.old" "${ZSH_COMPDUMP}.lock" fi _omz_source() { diff --git a/plugins/ansible/README.md b/plugins/ansible/README.md index ce21e7075..dd0e1ce03 100644 --- a/plugins/ansible/README.md +++ b/plugins/ansible/README.md @@ -28,6 +28,6 @@ plugins=(... ansible) ## Maintainer -### [Deepankumar](https://github.com/deepan10) +### [Deepankumar](https://github.com/deepan10) [https://github.com/deepan10/oh-my-zsh/tree/features/ansible-plugin](https://github.com/deepan10/oh-my-zsh/tree/features/ansible-plugin) diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh index 071dd1f0b..0c43031df 100644 --- a/plugins/aws/aws.plugin.zsh +++ b/plugins/aws/aws.plugin.zsh @@ -280,7 +280,7 @@ if [[ "$AWS_PROFILE_STATE_ENABLED" == true ]]; then test -s "${AWS_STATE_FILE}" || return aws_state=($(cat $AWS_STATE_FILE)) - + export AWS_DEFAULT_PROFILE="${aws_state[1]}" export AWS_PROFILE="$AWS_DEFAULT_PROFILE" export AWS_EB_PROFILE="$AWS_DEFAULT_PROFILE" diff --git a/plugins/branch/README.md b/plugins/branch/README.md index a15dd22df..2b6d12d29 100644 --- a/plugins/branch/README.md +++ b/plugins/branch/README.md @@ -39,7 +39,7 @@ index 2fd5f2cd..9d89a464 100644 PROMPT="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )" -PROMPT+=' %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)' +PROMPT+=' %{$fg[cyan]%}%c%{$reset_color%} $(branch_prompt_info)' - + ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}" ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} " ``` diff --git a/plugins/chruby/chruby.plugin.zsh b/plugins/chruby/chruby.plugin.zsh index d7a28d4e2..1210897c4 100644 --- a/plugins/chruby/chruby.plugin.zsh +++ b/plugins/chruby/chruby.plugin.zsh @@ -2,7 +2,7 @@ _source-from-omz-settings() { local _chruby_path _chruby_auto - + zstyle -s :omz:plugins:chruby path _chruby_path || return 1 zstyle -s :omz:plugins:chruby auto _chruby_auto || return 1 @@ -23,7 +23,7 @@ _source-from-homebrew() { if [[ -h /usr/local/opt/chruby ]];then _brew_prefix="/usr/local/opt/chruby" else - # ok , it is not default prefix + # ok , it is not default prefix # this call to brew is expensive ( about 400 ms ), so at least let's make it only once _brew_prefix=$(brew --prefix chruby) fi diff --git a/plugins/cloudfoundry/README.md b/plugins/cloudfoundry/README.md index 89dd9d1ce..567a9056b 100644 --- a/plugins/cloudfoundry/README.md +++ b/plugins/cloudfoundry/README.md @@ -50,7 +50,7 @@ Alternatively, seek out the [online documentation][3]. And don't forget, there a ## Contributors -Contributed to `oh_my_zsh` by [benwilcock][2]. +Contributed to `oh_my_zsh` by [benwilcock][2]. [1]: https://docs.cloudfoundry.org/cf-cli/install-go-cli.html [2]: https://github.com/benwilcock diff --git a/plugins/coffee/README.md b/plugins/coffee/README.md index 2baade844..c2ab192b6 100644 --- a/plugins/coffee/README.md +++ b/plugins/coffee/README.md @@ -24,7 +24,7 @@ Also provides the following aliases: * **cfc:** Copies the compiled JS to your clipboard. Very useful when you want to run the code in a JS console. -* **cfp:** Compiles from your currently copied clipboard. Useful when you want +* **cfp:** Compiles from your currently copied clipboard. Useful when you want to compile large/multi-line snippets * **cfpc:** Paste coffeescript from clipboard, compile to JS, then copy the diff --git a/plugins/compleat/compleat.plugin.zsh b/plugins/compleat/compleat.plugin.zsh index 38f1b396a..7fbd2b953 100644 --- a/plugins/compleat/compleat.plugin.zsh +++ b/plugins/compleat/compleat.plugin.zsh @@ -7,7 +7,7 @@ if (( ${+commands[compleat]} )); then local prefix="${commands[compleat]:h:h}" - local setup="${prefix}/share/compleat-1.0/compleat_setup" + local setup="${prefix}/share/compleat-1.0/compleat_setup" if [[ -f "$setup" ]]; then if ! bashcompinit >/dev/null 2>&1; then @@ -15,6 +15,6 @@ if (( ${+commands[compleat]} )); then bashcompinit -i fi - source "$setup" + source "$setup" fi fi diff --git a/plugins/copybuffer/copybuffer.plugin.zsh b/plugins/copybuffer/copybuffer.plugin.zsh index e67f920f0..88bda32a0 100644 --- a/plugins/copybuffer/copybuffer.plugin.zsh +++ b/plugins/copybuffer/copybuffer.plugin.zsh @@ -1,4 +1,4 @@ -# copy the active line from the command line buffer +# copy the active line from the command line buffer # onto the system clipboard copybuffer () { diff --git a/plugins/dash/README.md b/plugins/dash/README.md index 0ca3e4e44..970c6541f 100644 --- a/plugins/dash/README.md +++ b/plugins/dash/README.md @@ -19,7 +19,7 @@ dash - Query for something in dash app: `dash query` ``` -dash golang +dash golang ``` - You can optionally provide a keyword: `dash [keyword:]query` diff --git a/plugins/dotnet/dotnet.plugin.zsh b/plugins/dotnet/dotnet.plugin.zsh index 40ee7efae..ed7c55024 100644 --- a/plugins/dotnet/dotnet.plugin.zsh +++ b/plugins/dotnet/dotnet.plugin.zsh @@ -11,7 +11,7 @@ _dotnet_completion() { compdef _dotnet_completion dotnet # Aliases bellow are here for backwards compatibility -# added by Shaun Tabone (https://github.com/xontab) +# added by Shaun Tabone (https://github.com/xontab) alias dn='dotnet new' alias dr='dotnet run' diff --git a/plugins/emoji/emoji.plugin.zsh b/plugins/emoji/emoji.plugin.zsh index f9e476ebf..f7be56cf7 100644 --- a/plugins/emoji/emoji.plugin.zsh +++ b/plugins/emoji/emoji.plugin.zsh @@ -24,7 +24,7 @@ unset _omz_emoji_plugin_dir # This is a combining character that can be placed after any other character to surround # it in a "keycap" symbol. -# The digits 0-9 are already in the emoji table as keycap_digit_, keycap_ten, etc. +# The digits 0-9 are already in the emoji table as keycap_digit_, keycap_ten, etc. # It's unclear whether this should be in the $emoji array, because those characters are all ones # which can be displayed on their own. @@ -63,9 +63,9 @@ function random_emoji() { [[ $list_size -eq 0 ]] && return 1 local random_index=$(( ( RANDOM % $list_size ) + 1 )) local name=${names[$random_index]} - if [[ "$group" == "flags" ]]; then + if [[ "$group" == "flags" ]]; then echo ${emoji_flags[$name]} - else + else echo ${emoji[$name]} fi } @@ -86,22 +86,22 @@ function display_emoji() { # terminals treat these emoji chars as single-width. local counter=1 for i in $names; do - if [[ "$group" == "flags" ]]; then + if [[ "$group" == "flags" ]]; then printf '%s ' "$emoji_flags[$i]" - else - printf '%s ' "$emoji[$i]" + else + printf '%s ' "$emoji[$i]" fi # New line every 20 emoji, to avoid weirdnesses if (($counter % 20 == 0)); then - printf "\n" + printf "\n" fi let counter=$counter+1 done print for i in $names; do - if [[ "$group" == "flags" ]]; then + if [[ "$group" == "flags" ]]; then echo "${emoji_flags[$i]} = $i" - else + else echo "${emoji[$i]} = $i" fi done diff --git a/plugins/emotty/emotty.plugin.zsh b/plugins/emotty/emotty.plugin.zsh index 661169a8b..b48d121dc 100644 --- a/plugins/emotty/emotty.plugin.zsh +++ b/plugins/emotty/emotty.plugin.zsh @@ -4,7 +4,7 @@ # AUTHOR: Alexis Hildebrandt (afh[at]surryhill.net) # VERSION: 1.0.0 # DEPENDS: emoji plugin -# +# # There are different sets of emoji characters available, to choose a different # set export emotty_set to the name of the set you would like to use, e.g.: # % export emotty_set=nature diff --git a/plugins/encode64/README.md b/plugins/encode64/README.md index 7cdf8c3f3..e3e25a742 100644 --- a/plugins/encode64/README.md +++ b/plugins/encode64/README.md @@ -40,7 +40,7 @@ plugins=(... encode64) ### Encoding a file -Encode a file's contents to base64 and save output to text file. +Encode a file's contents to base64 and save output to text file. **NOTE:** Takes provided file and saves encoded content as new file with `.txt` extension - From parameter diff --git a/plugins/fancy-ctrl-z/README.md b/plugins/fancy-ctrl-z/README.md index f1b1dfa5c..82a4fd75e 100644 --- a/plugins/fancy-ctrl-z/README.md +++ b/plugins/fancy-ctrl-z/README.md @@ -1,14 +1,14 @@ # Use Ctrl-Z to switch back to Vim -I frequently need to execute random commands in my shell. To achieve it I pause +I frequently need to execute random commands in my shell. To achieve it I pause Vim by pressing Ctrl-z, type command and press fg to switch back to Vim. -The fg part really hurts me. I just wanted to hit Ctrl-z once again to get back -to Vim. I could not find a solution, so I developed one on my own that +The fg part really hurts me. I just wanted to hit Ctrl-z once again to get back +to Vim. I could not find a solution, so I developed one on my own that works wonderfully with ZSH. Source: http://sheerun.net/2014/03/21/how-to-boost-your-vim-productivity/ -Credits: +Credits: - original idea by @sheerun - added to OMZ by @mbologna diff --git a/plugins/fastfile/README.md b/plugins/fastfile/README.md index 32f619ffd..7291fde38 100644 --- a/plugins/fastfile/README.md +++ b/plugins/fastfile/README.md @@ -71,13 +71,13 @@ them, add `=` to your zshrc file, before Oh My Zsh is sourced. For example: `fastfile_var_prefix='@'`. - `fastfile_var_prefix`: prefix for the global aliases created. Controls the prefix of the - created global aliases. + created global aliases. **Default:** `§` (section sign), easy to type in a german keyboard via the combination [`⇧ Shift`+`3`](https://en.wikipedia.org/wiki/German_keyboard_layout#/media/File:KB_Germany.svg), or using `⌥ Option`+`6` in macOS. - `fastfile_dir`: directory where the fastfile shortcuts are stored. Needs to end - with a trailing slash. + with a trailing slash. **Default:** `$HOME/.fastfile/`. ## Author diff --git a/plugins/forklift/forklift.plugin.zsh b/plugins/forklift/forklift.plugin.zsh index 85889481b..848aedabf 100644 --- a/plugins/forklift/forklift.plugin.zsh +++ b/plugins/forklift/forklift.plugin.zsh @@ -58,7 +58,7 @@ function fl { tell application forkLiftSetapp activate set forkLiftVersion to version - end tell + end tell else if forkLift3 is not null and application forkLift3 is running then tell application forkLift3 activate @@ -84,7 +84,7 @@ function fl { else if forkLift is not null then set appName to forkLift end if - + tell application appName activate set forkLiftVersion to version diff --git a/plugins/fzf/fzf.plugin.zsh b/plugins/fzf/fzf.plugin.zsh index 7312e3d26..9e372f498 100644 --- a/plugins/fzf/fzf.plugin.zsh +++ b/plugins/fzf/fzf.plugin.zsh @@ -62,7 +62,7 @@ function fzf_setup_using_base_dir() { function fzf_setup_using_debian() { if (( ! $+commands[apt] && ! $+commands[apt-get] )); then - # Not a debian based distro + # Not a debian based distro return 1 fi diff --git a/plugins/gnu-utils/gnu-utils.plugin.zsh b/plugins/gnu-utils/gnu-utils.plugin.zsh index 6023bf2b4..adc2bd3bb 100644 --- a/plugins/gnu-utils/gnu-utils.plugin.zsh +++ b/plugins/gnu-utils/gnu-utils.plugin.zsh @@ -14,7 +14,7 @@ __gnu_utils() { local -a gcmds local gcmd - # coreutils + # coreutils gcmds=('g[' 'gbase64' 'gbasename' 'gcat' 'gchcon' 'gchgrp' 'gchmod' 'gchown' 'gchroot' 'gcksum' 'gcomm' 'gcp' 'gcsplit' 'gcut' 'gdate' 'gdd' 'gdf' 'gdir' 'gdircolors' 'gdirname' 'gdu' 'gecho' 'genv' 'gexpand' @@ -41,7 +41,7 @@ __gnu_utils() { for gcmd in "${gcmds[@]}"; do # Do nothing if the command isn't found (( ${+commands[$gcmd]} )) || continue - + # This method allows for builtin commands to be primary but it's # lost if hash -r or rehash is executed, or if $PATH is updated. # Thus, a preexec hook is needed, which will only run if whoami diff --git a/plugins/grails/grails.plugin.zsh b/plugins/grails/grails.plugin.zsh index ddc257428..e5dceb530 100644 --- a/plugins/grails/grails.plugin.zsh +++ b/plugins/grails/grails.plugin.zsh @@ -7,7 +7,7 @@ _enumerateGrailsScripts() { then directories+=(plugins/*/scripts) fi - + # Enumerate all of the Groovy files files=() for dir in $directories; @@ -17,13 +17,13 @@ _enumerateGrailsScripts() { files+=($dir/[^_]*.groovy) fi done - + # Don't try to basename () if [ ${#files} -eq 0 ]; then return fi - + scripts=() for file in $files do @@ -42,19 +42,19 @@ _enumerateGrailsScripts() { done echo $scripts } - + _grails() { if (( CURRENT == 2 )); then scripts=( $(_enumerateGrailsScripts) ) - + if [ ${#scripts} -ne 0 ]; then _multi_parts / scripts return fi fi - + _files } - + compdef _grails grails diff --git a/plugins/history-substring-search/README.md b/plugins/history-substring-search/README.md index 71a389535..4be744c4c 100644 --- a/plugins/history-substring-search/README.md +++ b/plugins/history-substring-search/README.md @@ -57,13 +57,13 @@ Using [antigen](https://github.com/zsh-users/antigen): 1. Add the `antigen bundle` command just before `antigen apply`, like this: -``` +``` antigen bundle zsh-users/zsh-history-substring-search antigen apply ``` - + 2. Then, **after** `antigen apply`, add the key binding configurations, like this: - + ``` # zsh-history-substring-search configuration bindkey '^[[A' history-substring-search-up # or '\eOA' @@ -120,7 +120,7 @@ Usage bindkey "$terminfo[kcuu1]" history-substring-search-up bindkey "$terminfo[kcud1]" history-substring-search-down - Users have also observed that `[OA` and `[OB` are correct values, + Users have also observed that `[OA` and `[OB` are correct values, _even if_ these were not the observed values. If you are having trouble with the observed values, give these a try. diff --git a/plugins/ionic/ionic.plugin.zsh b/plugins/ionic/ionic.plugin.zsh index cf388af1b..e3913b549 100644 --- a/plugins/ionic/ionic.plugin.zsh +++ b/plugins/ionic/ionic.plugin.zsh @@ -3,13 +3,13 @@ alias ih="ionic --help" alias ist="ionic start" alias ii="ionic info" alias is="ionic serve" -alias icba="ionic cordova build android" -alias icbi="ionic cordova build ios" -alias icra="ionic cordova run android" -alias icri="ionic cordova run ios" -alias icrsa="ionic cordova resources android" +alias icba="ionic cordova build android" +alias icbi="ionic cordova build ios" +alias icra="ionic cordova run android" +alias icri="ionic cordova run ios" +alias icrsa="ionic cordova resources android" alias icrsi="ionic cordova resources ios" -alias icpaa="ionic cordova platform add android" +alias icpaa="ionic cordova platform add android" alias icpai="ionic cordova platform add ios" alias icpra="ionic cordova platform rm android" alias icpri="ionic cordova platform rm ios" diff --git a/plugins/iterm2/README.md b/plugins/iterm2/README.md index 3d11622df..86bd77f1d 100644 --- a/plugins/iterm2/README.md +++ b/plugins/iterm2/README.md @@ -9,7 +9,7 @@ plugins=(... iterm2) ``` Optionally, the plugin also applies the [Shell Integration Script for iTerm2](https://iterm2.com/documentation-shell-integration.html). -You can enable the integration with zstyle. It's important to add this line +You can enable the integration with zstyle. It's important to add this line before the line sourcing oh-my-zsh: ``` diff --git a/plugins/iterm2/iterm2.plugin.zsh b/plugins/iterm2/iterm2.plugin.zsh index d00232a30..03a63a70c 100644 --- a/plugins/iterm2/iterm2.plugin.zsh +++ b/plugins/iterm2/iterm2.plugin.zsh @@ -8,7 +8,7 @@ if [[ "$OSTYPE" == darwin* ]] && [[ -n "$ITERM_SESSION_ID" ]] ; then # maybe make it the default in the future and allow opting out? - if zstyle -t ':omz:plugins:iterm2' shell-integration; then + if zstyle -t ':omz:plugins:iterm2' shell-integration; then # Handle $0 according to the standard: # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html 0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}" diff --git a/plugins/iterm2/iterm2_shell_integration.zsh b/plugins/iterm2/iterm2_shell_integration.zsh index 7871ddded..281332e0d 100644 --- a/plugins/iterm2/iterm2_shell_integration.zsh +++ b/plugins/iterm2/iterm2_shell_integration.zsh @@ -2,12 +2,12 @@ # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. -# +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/plugins/jira/README.md b/plugins/jira/README.md index b1d8a8bc6..1c6930298 100644 --- a/plugins/jira/README.md +++ b/plugins/jira/README.md @@ -35,7 +35,7 @@ This plugin supplies one command, `jira`, through which all its features are exp ### Jira Branch usage notes -The branch name may have prefixes ending in "/": "feature/MP-1234", and also suffixes +The branch name may have prefixes ending in "/": "feature/MP-1234", and also suffixes starting with "_": "MP-1234_fix_dashboard". In both these cases, the issue opened will be "MP-1234" This is also checks if the prefix is in the name, and adds it if not, so: "MP-1234" opens the issue "MP-1234", diff --git a/plugins/juju/juju.plugin.zsh b/plugins/juju/juju.plugin.zsh index a82ebaf84..3c159da22 100644 --- a/plugins/juju/juju.plugin.zsh +++ b/plugins/juju/juju.plugin.zsh @@ -184,7 +184,7 @@ jmodel() { fi local model="$(yq e ".controllers.$(jcontroller).current-model" < ~/.local/share/juju/models.yaml | cut -d/ -f2)" - + if [[ -z "$model" ]]; then echo "--" return 1 diff --git a/plugins/kn/kn.plugin.zsh b/plugins/kn/kn.plugin.zsh index f60177dd9..483d1d68c 100644 --- a/plugins/kn/kn.plugin.zsh +++ b/plugins/kn/kn.plugin.zsh @@ -4,5 +4,5 @@ if [ $commands[kn] ]; then source <(kn completion zsh) - compdef _kn kn + compdef _kn kn fi diff --git a/plugins/macports/_port b/plugins/macports/_port index 897598a46..f40f6550b 100644 --- a/plugins/macports/_port +++ b/plugins/macports/_port @@ -1,6 +1,6 @@ #compdef port -local subcmds +local subcmds # we cache the list of ports # we shall use some cache policy to avoid problems with new ports @@ -31,8 +31,8 @@ subcmds=( 'file' 'help' 'info' -'install' -'installed' +'install' +'installed' 'list' 'livecheck' 'location' @@ -51,7 +51,7 @@ subcmds=( 'test' 'unarchive' 'uninstall' -'upgrade' +'upgrade' 'variants' 'version' ) diff --git a/plugins/marked2/README.md b/plugins/marked2/README.md index 101343abb..2f825bc4a 100644 --- a/plugins/marked2/README.md +++ b/plugins/marked2/README.md @@ -1,6 +1,6 @@ ## marked2 -Plugin for Marked 2, a previewer for Markdown files on Mac OS X +Plugin for Marked 2, a previewer for Markdown files on Mac OS X ### Requirements diff --git a/plugins/marktext/README.md b/plugins/marktext/README.md index 71d287451..254e4e7ac 100644 --- a/plugins/marktext/README.md +++ b/plugins/marktext/README.md @@ -1,6 +1,6 @@ ## marktext -Plugin for MarkText, a previewer for Markdown files on Mac OS X +Plugin for MarkText, a previewer for Markdown files on Mac OS X ### Requirements diff --git a/plugins/mongo-atlas/README.md b/plugins/mongo-atlas/README.md index ef1b5e0d2..94183c544 100644 --- a/plugins/mongo-atlas/README.md +++ b/plugins/mongo-atlas/README.md @@ -1,6 +1,6 @@ # MongoDB Atlas plugin -This plugin adds completion for [Atlas](https://www.mongodb.com/docs/atlas/cli/stable/) a command line interface built specifically for +This plugin adds completion for [Atlas](https://www.mongodb.com/docs/atlas/cli/stable/) a command line interface built specifically for MongoDB Atlas. To use it, add `mongo-atlas` to the plugins array in your zshrc file: diff --git a/plugins/n98-magerun/n98-magerun.plugin.zsh b/plugins/n98-magerun/n98-magerun.plugin.zsh index d79aee7eb..2744ad96e 100644 --- a/plugins/n98-magerun/n98-magerun.plugin.zsh +++ b/plugins/n98-magerun/n98-magerun.plugin.zsh @@ -1,6 +1,6 @@ # ------------------------------------------------------------------------------ # FILE: n98-magerun.plugin.zsh -# DESCRIPTION: oh-my-zsh n98-magerun plugin file. Adapted from composer plugin +# DESCRIPTION: oh-my-zsh n98-magerun plugin file. Adapted from composer plugin # AUTHOR: Andrew Dwyer (andrewrdwyer at gmail dot com) # AUTHOR: Jisse Reitsma (jisse at yireo dot com) # VERSION: 1.1.0 diff --git a/plugins/nmap/nmap.plugin.zsh b/plugins/nmap/nmap.plugin.zsh index 406870f00..f649dafc2 100644 --- a/plugins/nmap/nmap.plugin.zsh +++ b/plugins/nmap/nmap.plugin.zsh @@ -27,6 +27,6 @@ alias nmap_detect_versions="sudo nmap -sV -p1-65535 -O --osscan-guess -T4 -Pn" alias nmap_check_for_vulns="nmap --script=vuln" alias nmap_full_udp="sudo nmap -sS -sU -T4 -A -v -PE -PS22,25,80 -PA21,23,80,443,3389 " alias nmap_traceroute="sudo nmap -sP -PE -PS22,25,80 -PA21,23,80,3389 -PU -PO --traceroute " -alias nmap_full_with_scripts="sudo nmap -sS -sU -T4 -A -v -PE -PP -PS21,22,23,25,80,113,31339 -PA80,113,443,10042 -PO --script all " +alias nmap_full_with_scripts="sudo nmap -sS -sU -T4 -A -v -PE -PP -PS21,22,23,25,80,113,31339 -PA80,113,443,10042 -PO --script all " alias nmap_web_safe_osscan="sudo nmap -p 80,443 -O -v --osscan-guess --fuzzy " alias nmap_ping_scan="nmap -n -sP" diff --git a/plugins/nomad/_nomad b/plugins/nomad/_nomad index 4c6cb2fcb..87f80aa84 100644 --- a/plugins/nomad/_nomad +++ b/plugins/nomad/_nomad @@ -89,7 +89,7 @@ __plan() { '-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \ '-region=[(region) The region of the Nomad servers to forward commands to. Overrides the NOMAD_REGION environment variable if set. Defaults to the Agent s local region.]' \ '-no-color[Disables colored command output.]' \ - '-diff[Determines whether the diff between the remote job and planned job is shown. Defaults to true.]' + '-diff[Determines whether the diff between the remote job and planned job is shown. Defaults to true.]' } __run() { diff --git a/plugins/npm/npm.plugin.zsh b/plugins/npm/npm.plugin.zsh index 23377b085..c333f76ed 100644 --- a/plugins/npm/npm.plugin.zsh +++ b/plugins/npm/npm.plugin.zsh @@ -58,7 +58,7 @@ alias npmt="npm test" # Run npm scripts alias npmR="npm run" -# Run npm publish +# Run npm publish alias npmP="npm publish" # Run npm init diff --git a/plugins/nvm/nvm.plugin.zsh b/plugins/nvm/nvm.plugin.zsh index 6a5afecfa..c2e8de94b 100644 --- a/plugins/nvm/nvm.plugin.zsh +++ b/plugins/nvm/nvm.plugin.zsh @@ -16,7 +16,7 @@ if [[ -z "$NVM_DIR" ]]; then fi fi -if [[ -z "$NVM_DIR" ]] || [[ ! -f "$NVM_DIR/nvm.sh" ]]; then +if [[ -z "$NVM_DIR" ]] || [[ ! -f "$NVM_DIR/nvm.sh" ]]; then return fi diff --git a/plugins/otp/README.md b/plugins/otp/README.md index 8331fd02b..52ad9525b 100644 --- a/plugins/otp/README.md +++ b/plugins/otp/README.md @@ -16,7 +16,7 @@ Provided aliases: email address). Then the OTP key needs to be pasted, followed by a CTRL+D character inserted on an empty line. -- `ot`: generates a MFA code based on the given key and copies it to the clipboard +- `ot`: generates a MFA code based on the given key and copies it to the clipboard (on Linux it relies on xsel, on MacOS X it uses pbcopy instead). The plugin uses `$HOME/.otp` to store its internal files. diff --git a/plugins/pm2/_pm2 b/plugins/pm2/_pm2 index faa6a3404..66320b810 100644 --- a/plugins/pm2/_pm2 +++ b/plugins/pm2/_pm2 @@ -79,7 +79,7 @@ _id_names() { local app_list app_list=`pm2 list -m` - local -a names ids + local -a names ids names=(`echo $app_list | grep '+---' | awk '{print $2}'`) ids=(`echo $app_list | grep 'pm2 id' | awk '{print $4}'`) diff --git a/plugins/poetry-env/README.md b/plugins/poetry-env/README.md index a7d16563e..bd99d2a91 100644 --- a/plugins/poetry-env/README.md +++ b/plugins/poetry-env/README.md @@ -1,6 +1,6 @@ # Poetry Environment Plugin -This plugin automatically changes poetry environment when you cd into or out of the project directory. +This plugin automatically changes poetry environment when you cd into or out of the project directory. Note: Script looks for pyproject.toml file to determine poetry if its a poetry environment To use it, add `poetry-env` to the plugins array in your zshrc file: diff --git a/plugins/ros/_ros b/plugins/ros/_ros index 6a04d3c8f..c73a7b353 100644 --- a/plugins/ros/_ros +++ b/plugins/ros/_ros @@ -18,7 +18,7 @@ _1st_arguments=( 'config:Get and set options' 'version:Show the roswell version information' "help:Use \"ros help [command]\" for more information about a command."$'\n\t\t'"Use \"ros help [topic]\" for more information about the topic." -) +) #local expl diff --git a/plugins/sbt/sbt.plugin.zsh b/plugins/sbt/sbt.plugin.zsh index 851302c68..1e977140b 100644 --- a/plugins/sbt/sbt.plugin.zsh +++ b/plugins/sbt/sbt.plugin.zsh @@ -4,7 +4,7 @@ # AUTHOR: Mirko Caserta (mirko.caserta@gmail.com) # VERSION: 1.0.2 # ------------------------------------------------------------------------------ - + # aliases - mnemonic: prefix is 'sb' alias sbc='sbt compile' alias sbcc='sbt clean compile' diff --git a/plugins/screen/screen.plugin.zsh b/plugins/screen/screen.plugin.zsh index c1db8ad92..26531c40b 100644 --- a/plugins/screen/screen.plugin.zsh +++ b/plugins/screen/screen.plugin.zsh @@ -8,7 +8,7 @@ if [[ "$TERM" == screen* ]]; then _GET_HOST='echo $HOST | sed "s/\..*//"' fi - # use the current user as the prefix of the current tab title + # use the current user as the prefix of the current tab title TAB_TITLE_PREFIX='"`'$_GET_HOST'`:`'$_GET_PATH' | sed "s:..*/::"`$PROMPT_CHAR"' # when at the shell prompt, show a truncated version of the current path (with # standard ~ replacement) as the rest of the title. diff --git a/plugins/singlechar/singlechar.plugin.zsh b/plugins/singlechar/singlechar.plugin.zsh index d4b0b6735..6d785d9e1 100644 --- a/plugins/singlechar/singlechar.plugin.zsh +++ b/plugins/singlechar/singlechar.plugin.zsh @@ -1,5 +1,5 @@ ########################### -# Settings +# Settings # These can be overwritten any time. # If they are not set yet, they will be diff --git a/plugins/systemadmin/README.md b/plugins/systemadmin/README.md index 3a9d9de66..bd6b08760 100644 --- a/plugins/systemadmin/README.md +++ b/plugins/systemadmin/README.md @@ -1,7 +1,7 @@ # Systemadmin plugin This plugin adds a series of aliases and functions which make a System Administrator's life easier. - + To use it, add `systemadmin` to the plugins array in your zshrc file: ```zsh diff --git a/plugins/thor/README.md b/plugins/thor/README.md index 09c705d9a..484c88b84 100644 --- a/plugins/thor/README.md +++ b/plugins/thor/README.md @@ -1,6 +1,6 @@ # Thor plugin -This plugin adds completion for [Thor](http://whatisthor.com/), +This plugin adds completion for [Thor](http://whatisthor.com/), a ruby toolkit for building powerful command-line interfaces. To use it, add `thor` to the plugins array in your zshrc file: diff --git a/plugins/ufw/README.md b/plugins/ufw/README.md index ac377cd17..ffcc6d6f7 100644 --- a/plugins/ufw/README.md +++ b/plugins/ufw/README.md @@ -10,7 +10,7 @@ plugins=(... ufw) Some of the commands include: -* `allow /` add an allow rule +* `allow /` add an allow rule * `default` set default policy * `delete /` delete RULE * `deny /` add deny rule diff --git a/plugins/vagrant-prompt/README.md b/plugins/vagrant-prompt/README.md index c5bc55d17..dd0ca363b 100644 --- a/plugins/vagrant-prompt/README.md +++ b/plugins/vagrant-prompt/README.md @@ -1,6 +1,6 @@ This plugin prompts the status of the Vagrant VMs. It supports single-host and multi-host configurations as well. -Look inside the source for documentation about custom variables. +Look inside the source for documentation about custom variables. Alberto Re diff --git a/plugins/vi-mode/README.md b/plugins/vi-mode/README.md index 84ba30105..6e781f296 100644 --- a/plugins/vi-mode/README.md +++ b/plugins/vi-mode/README.md @@ -55,7 +55,7 @@ INSERT_MODE_INDICATOR="%F{yellow}+%f" ### Adding mode indicators to your prompt -`Vi-mode` by default will add mode indicators to `RPROMPT` **unless** that is defined by +`Vi-mode` by default will add mode indicators to `RPROMPT` **unless** that is defined by a preceding plugin. If `PROMPT` or `RPROMPT` is not defined to your liking, you can add mode info manually. The `vi_mode_prompt_info` function is available to insert mode indicator information. diff --git a/plugins/vim-interaction/README.md b/plugins/vim-interaction/README.md index 681648018..c2b45f1d8 100644 --- a/plugins/vim-interaction/README.md +++ b/plugins/vim-interaction/README.md @@ -3,7 +3,7 @@ The plugin presents a function called `callvim` whose usage is: usage: callvim [-b cmd] [-a cmd] [file ... fileN] - + -b cmd Run this command in GVIM before editing the first file -a cmd Run this command in GVIM after editing the first file file The file to edit diff --git a/plugins/vim-interaction/vim-interaction.plugin.zsh b/plugins/vim-interaction/vim-interaction.plugin.zsh index b73f9b4da..a12b52bd5 100644 --- a/plugins/vim-interaction/vim-interaction.plugin.zsh +++ b/plugins/vim-interaction/vim-interaction.plugin.zsh @@ -2,7 +2,7 @@ # See README.md # # Derek Wyatt (derek@{myfirstnamemylastname}.org -# +# function callvim { if [[ $# == 0 ]]; then diff --git a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh index e037241e4..1a3ae37b8 100644 --- a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh +++ b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh @@ -52,7 +52,7 @@ if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then else ENV_NAME="" fi - + if [[ -n $CD_VIRTUAL_ENV && "$ENV_NAME" != "$CD_VIRTUAL_ENV" ]]; then # We've just left the repo, deactivate the environment # Note: this only happens if the virtualenv was activated automatically diff --git a/plugins/wd/README.md b/plugins/wd/README.md index 1d1980632..0ad74e805 100644 --- a/plugins/wd/README.md +++ b/plugins/wd/README.md @@ -153,7 +153,7 @@ wd .. wd ... ``` -This is a wrapper for the zsh's `dirs` function. +This is a wrapper for the zsh's `dirs` function. _You might need to add `setopt AUTO_PUSHD` to your `.zshrc` if you are not using [oh-my-zsh](https://github.com/ohmyzsh/ohmyzsh)._ * Remove warp point: diff --git a/plugins/wd/_wd.sh b/plugins/wd/_wd.sh index 8d5cf15a2..52ecb12e6 100644 --- a/plugins/wd/_wd.sh +++ b/plugins/wd/_wd.sh @@ -77,7 +77,7 @@ function _wd() { # complete sub directories from the warp point _path_files -W "(${points[$target]})" -/ && ret=0 fi - + # don't complete anything if warp point is not valid ;; esac diff --git a/plugins/z/MANUAL.md b/plugins/z/MANUAL.md index 67a207dbb..106d8c107 100644 --- a/plugins/z/MANUAL.md +++ b/plugins/z/MANUAL.md @@ -188,7 +188,7 @@ Add a backslash to the end of the last line add `'zsh-z'` to the list, e.g., Then relaunch `zsh`. ### For [zcomet](https://github.com/agkozak/zcomet) users - + Simply add zcomet load agkozak/zsh-z diff --git a/themes/Soliah.zsh-theme b/themes/Soliah.zsh-theme index c3dd6af89..e297fe9ca 100644 --- a/themes/Soliah.zsh-theme +++ b/themes/Soliah.zsh-theme @@ -5,10 +5,10 @@ ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[white]%}" ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%})" # Text to display if the branch is dirty -ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}*%{$reset_color%}" +ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}*%{$reset_color%}" # Text to display if the branch is clean -ZSH_THEME_GIT_PROMPT_CLEAN="" +ZSH_THEME_GIT_PROMPT_CLEAN="" # Colors vary depending on time lapsed. ZSH_THEME_GIT_TIME_SINCE_COMMIT_SHORT="%{$fg[green]%}" @@ -36,7 +36,7 @@ function rvm_gemset() { GEMSET=`rvm gemset list | grep '=>' | cut -b4-` if [[ -n $GEMSET ]]; then echo "%{$fg[yellow]%}$GEMSET%{$reset_color%}|" - fi + fi fi } @@ -52,12 +52,12 @@ function git_time_since_commit() { # Totals MINUTES=$((seconds_since_last_commit / 60)) HOURS=$((seconds_since_last_commit/3600)) - + # Sub-hours and sub-minutes DAYS=$((seconds_since_last_commit / 86400)) SUB_HOURS=$((HOURS % 24)) SUB_MINUTES=$((MINUTES % 60)) - + if [[ -n $(git status -s 2> /dev/null) ]]; then if [ "$MINUTES" -gt 30 ]; then COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_LONG" diff --git a/themes/adben.zsh-theme b/themes/adben.zsh-theme index c2fdbed23..cc097057f 100644 --- a/themes/adben.zsh-theme +++ b/themes/adben.zsh-theme @@ -79,7 +79,7 @@ ps1_command_tip() { command wget -qO- https://www.commandlinefu.com/commands/random/plaintext elif (( ${+commands[curl]} )); then command curl -fsL https://www.commandlinefu.com/commands/random/plaintext - fi + fi } | sed '1d;/^$/d' } diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme index aa274a5bb..bd0405efb 100644 --- a/themes/agnoster.zsh-theme +++ b/themes/agnoster.zsh-theme @@ -111,7 +111,7 @@ prompt_git() { dirty=$(parse_git_dirty) ref=$(git symbolic-ref HEAD 2> /dev/null) || \ ref="◈ $(git describe --exact-match --tags HEAD 2> /dev/null)" || \ - ref="➦ $(git rev-parse --short HEAD 2> /dev/null)" + ref="➦ $(git rev-parse --short HEAD 2> /dev/null)" if [[ -n $dirty ]]; then prompt_segment yellow black else diff --git a/themes/avit.zsh-theme b/themes/avit.zsh-theme index 206274462..0e39d9077 100644 --- a/themes/avit.zsh-theme +++ b/themes/avit.zsh-theme @@ -15,7 +15,7 @@ __RPROMPT='$(vi_mode_prompt_info)%{$(echotc UP 1)%}$(_git_time_since_commit) $(g if [[ -z $RPROMPT ]]; then RPROMPT=$__RPROMPT else - RPROMPT="${RPROMPT} ${__RPROMPT}" + RPROMPT="${RPROMPT} ${__RPROMPT}" fi function _user_host() { diff --git a/themes/crunch.zsh-theme b/themes/crunch.zsh-theme index 8278661ab..d86ce1e4a 100644 --- a/themes/crunch.zsh-theme +++ b/themes/crunch.zsh-theme @@ -1,15 +1,15 @@ # CRUNCH - created from Steve Eley's cat waxing. # Initially hacked from the Dallas theme. Thanks, Dallas Reedy. # -# This theme assumes you do most of your oh-my-zsh'ed "colorful" work at a single machine, -# and eschews the standard space-consuming user and hostname info. Instead, only the +# This theme assumes you do most of your oh-my-zsh'ed "colorful" work at a single machine, +# and eschews the standard space-consuming user and hostname info. Instead, only the # things that vary in my own workflow are shown: # # * The time (not the date) # * The RVM version and gemset (omitting the 'ruby' name if it's MRI) # * The current directory # * The Git branch and its 'dirty' state -# +# # Colors are at the top so you can mess with those separately if you like. # For the most part I stuck with Dallas's. diff --git a/themes/eastwood.zsh-theme b/themes/eastwood.zsh-theme index 88134f8e6..31e24fa7f 100644 --- a/themes/eastwood.zsh-theme +++ b/themes/eastwood.zsh-theme @@ -1,5 +1,5 @@ # RVM settings -if [[ -s ~/.rvm/scripts/rvm ]] ; then +if [[ -s ~/.rvm/scripts/rvm ]] ; then RPS1="%{$fg[yellow]%}rvm:%{$reset_color%}%{$fg[red]%}\$(~/.rvm/bin/rvm-prompt)%{$reset_color%} $EPS1" else if which rbenv &> /dev/null; then diff --git a/themes/emotty.zsh-theme b/themes/emotty.zsh-theme index ba0840950..0fea7d916 100644 --- a/themes/emotty.zsh-theme +++ b/themes/emotty.zsh-theme @@ -11,7 +11,7 @@ # # There are pre-defined different emoji sets to choose from, e.g.: # emoji, stellar, floral, zodiac, love (see emotty plugin). -# +# # To choose a different emotty set than the default (emoji) # % export emotty_set=nature # @@ -95,7 +95,7 @@ zstyle ':vcs_info:*' stagedstr "${green}${vcs_staged_glyph}" # %(k|f) reset (back|fore)ground color zstyle ':vcs_info:*' max-exports 3 zstyle ':vcs_info:*' nvcsformats "${prompt_glyph}" '%3~' '' -zstyle ':vcs_info:*' formats "${yellow}%u%c%b${vcs_branch_glyph}%f" '%S|' "$FX[bold]%r$FX[no-bold]" +zstyle ':vcs_info:*' formats "${yellow}%u%c%b${vcs_branch_glyph}%f" '%S|' "$FX[bold]%r$FX[no-bold]" zstyle ':vcs_info:*' actionformats "${red}%K{white}%a${vcs_action_glyph}%k%f" '%S|' "$FX[bold]%r$FX[no-bold]" red_if_root="%(!.%F{red}.)" diff --git a/themes/essembeh.zsh-theme b/themes/essembeh.zsh-theme index 43d4093b1..50b3f7772 100644 --- a/themes/essembeh.zsh-theme +++ b/themes/essembeh.zsh-theme @@ -8,7 +8,7 @@ # - prefix to detect docker containers or chroot # - git plugin to display current branch and status -# git plugin +# git plugin ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[cyan]%}(" ZSH_THEME_GIT_PROMPT_SUFFIX=") %{$reset_color%}" ZSH_THEME_GIT_PROMPT_UNTRACKED="%%" @@ -35,7 +35,7 @@ if [[ -n "$SSH_CONNECTION" ]]; then ZSH_ESSEMBEH_PREFIX="%{$fg[yellow]%}[$(echo $SSH_CONNECTION | awk '{print $1}')]%{$reset_color%} " # use red color to highlight a remote connection ZSH_ESSEMBEH_COLOR="red" -elif [[ -r /etc/debian_chroot ]]; then +elif [[ -r /etc/debian_chroot ]]; then # prefix prompt in case of chroot ZSH_ESSEMBEH_PREFIX="%{$fg[yellow]%}[chroot:$(cat /etc/debian_chroot)]%{$reset_color%} " elif [[ -r /.dockerenv ]]; then diff --git a/themes/josh.zsh-theme b/themes/josh.zsh-theme index ea051c58e..df59280d7 100644 --- a/themes/josh.zsh-theme +++ b/themes/josh.zsh-theme @@ -15,7 +15,7 @@ function josh_prompt { branch_size=${#branch} ruby_size=${#ruby_version} user_machine_size=${#${(%):-%n@%m-}} - + if [[ ${#branch} -eq 0 ]] then (( ruby_size = ruby_size + 1 )) else @@ -24,15 +24,15 @@ function josh_prompt { (( branch_size = branch_size + 2 )) fi fi - + (( spare_width = ${spare_width} - (${user_machine_size} + ${path_size} + ${branch_size} + ${ruby_size}) )) while [ ${#prompt} -lt $spare_width ]; do prompt=" $prompt" done - + prompt="%{%F{green}%}$PWD$prompt%{%F{red}%}$(ruby_prompt_info)%{$reset_color%} $(git_current_branch)" - + echo $prompt } diff --git a/themes/junkfood.zsh-theme b/themes/junkfood.zsh-theme index 01fae4b95..e3b746c7a 100644 --- a/themes/junkfood.zsh-theme +++ b/themes/junkfood.zsh-theme @@ -3,10 +3,10 @@ # Grab the current date (%W) and time (%t): JUNKFOOD_TIME_="%{$fg_bold[red]%}#%{$fg_bold[white]%}( %{$fg_bold[yellow]%}%W%{$reset_color%}@%{$fg_bold[white]%}%t )( %{$reset_color%}" -# Grab the current machine name +# Grab the current machine name JUNKFOOD_MACHINE_="%{$fg_bold[blue]%}%m%{$fg[white]%} ):%{$reset_color%}" -# Grab the current username +# Grab the current username JUNKFOOD_CURRENT_USER_="%{$fg_bold[green]%}%n%{$reset_color%}" # Grab the current filepath, use shortcuts: ~/Desktop diff --git a/themes/mlh.zsh-theme b/themes/mlh.zsh-theme index c059bf850..94718f8f2 100644 --- a/themes/mlh.zsh-theme +++ b/themes/mlh.zsh-theme @@ -15,7 +15,7 @@ # To customize symbols (e.g MLH_AT_SYMBOL), simply set them as environment variables # for example in your ~/.zshrc file, like this: # MLH_AT_SYMBOL=" at " -# +# # Settings *must* be set before sourcing oh-my-zsh.sh the .zshrc file. # # To easily discover colors and their codes, type `spectrum_ls` in the terminal diff --git a/themes/mortalscumbag.zsh-theme b/themes/mortalscumbag.zsh-theme index 36301cb76..c9994c0f9 100644 --- a/themes/mortalscumbag.zsh-theme +++ b/themes/mortalscumbag.zsh-theme @@ -1,6 +1,6 @@ function my_git_prompt() { tester=$(git rev-parse --git-dir 2> /dev/null) || return - + INDEX=$(git status --porcelain 2> /dev/null) STATUS="" diff --git a/themes/sonicradish.zsh-theme b/themes/sonicradish.zsh-theme index 508611830..db6170969 100644 --- a/themes/sonicradish.zsh-theme +++ b/themes/sonicradish.zsh-theme @@ -1,4 +1,4 @@ -#!/usr/bin/env zsh +#!/usr/bin/env zsh #local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})" setopt promptsubst diff --git a/themes/wedisagree.zsh-theme b/themes/wedisagree.zsh-theme index e9e9d6ef8..358891992 100644 --- a/themes/wedisagree.zsh-theme +++ b/themes/wedisagree.zsh-theme @@ -5,9 +5,9 @@ # - Place that bundle in ~/Library/Application\ Support/SIMBL/Plugins (create that folder if it doesn't exist) # - Open Terminal preferences. Go to Settings -> Text -> More # - Change default colours to your liking. -# +# # Here are the colours from Textmate's Monokai theme: -# +# # Black: 0, 0, 0 # Red: 229, 34, 34 # Green: 166, 227, 45 @@ -28,7 +28,7 @@ PROMPT='%{$fg[magenta]%}[%c] %{$reset_color%}' RPROMPT='${time} %{$fg[magenta]%}$(git_prompt_info)%{$reset_color%}$(git_prompt_status)%{$reset_color%}$(git_prompt_ahead)%{$reset_color%}' # Add this at the start of RPROMPT to include rvm info showing ruby-version@gemset-name -# $(ruby_prompt_info) +# $(ruby_prompt_info) # local time, color coded by last return code time_enabled="%(?.%{$fg[green]%}.%{$fg[red]%})%*%{$reset_color%}" @@ -53,7 +53,7 @@ ZSH_THEME_RUBY_PROMPT_SUFFIX="%{$reset_color%}" # More symbols to choose from: # ☀ ✹ ☄ ♆ ♀ ♁ ♐ ♇ ♈ ♉ ♚ ♛ ♜ ♝ ♞ ♟ ♠ ♣ ⚢ ⚲ ⚳ ⚴ ⚥ ⚤ ⚦ ⚒ ⚑ ⚐ ♺ ♻ ♼ ☰ ☱ ☲ ☳ ☴ ☵ ☶ ☷ -# ✡ ✔ ✖ ✚ ✱ ✤ ✦ ❤ ➜ ➟ ➼ ✂ ✎ ✐ ⨀ ⨁ ⨂ ⨍ ⨎ ⨏ ⨷ ⩚ ⩛ ⩡ ⩱ ⩲ ⩵ ⩶ ⨠ +# ✡ ✔ ✖ ✚ ✱ ✤ ✦ ❤ ➜ ➟ ➼ ✂ ✎ ✐ ⨀ ⨁ ⨂ ⨍ ⨎ ⨏ ⨷ ⩚ ⩛ ⩡ ⩱ ⩲ ⩵ ⩶ ⨠ # ⬅ ⬆ ⬇ ⬈ ⬉ ⬊ ⬋ ⬒ ⬓ ⬔ ⬕ ⬖ ⬗ ⬘ ⬙ ⬟ ⬤ 〒 ǀ ǁ ǂ ĭ Ť Ŧ # Determine if we are using a gemset. @@ -61,7 +61,7 @@ function rvm_gemset() { GEMSET=`rvm gemset list | grep '=>' | cut -b4-` if [[ -n $GEMSET ]]; then echo "%{$fg[yellow]%}$GEMSET%{$reset_color%}|" - fi + fi } # Determine the time since last commit. If branch is clean, @@ -76,12 +76,12 @@ function git_time_since_commit() { # Totals MINUTES=$((seconds_since_last_commit / 60)) HOURS=$((seconds_since_last_commit/3600)) - + # Sub-hours and sub-minutes DAYS=$((seconds_since_last_commit / 86400)) SUB_HOURS=$((HOURS % 24)) SUB_MINUTES=$((MINUTES % 60)) - + if [[ -n $(git status -s 2> /dev/null) ]]; then if [ "$MINUTES" -gt 30 ]; then COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_LONG" From 62a76353ab73532c2681c6b168623f7f1e7d96ae Mon Sep 17 00:00:00 2001 From: Masaru Iritani <25241373+masaru-iritani@users.noreply.github.com> Date: Sat, 30 Mar 2024 16:25:34 +0900 Subject: [PATCH 07/79] fix(starship): keep `ZSH_THEME` if not installed (#12309) --- plugins/starship/starship.plugin.zsh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/starship/starship.plugin.zsh b/plugins/starship/starship.plugin.zsh index 8c5d9135e..fc415e64c 100644 --- a/plugins/starship/starship.plugin.zsh +++ b/plugins/starship/starship.plugin.zsh @@ -1,7 +1,7 @@ -# ignore oh-my-zsh theme -unset ZSH_THEME - if (( $+commands[starship] )); then + # ignore oh-my-zsh theme + unset ZSH_THEME + eval "$(starship init zsh)" else echo '[oh-my-zsh] starship not found, please install it from https://starship.rs' From 6dfa9507ce0eb0f4d386bd03268e33943ea55c0f Mon Sep 17 00:00:00 2001 From: Jason D'Amour Date: Sat, 30 Mar 2024 00:26:14 -0700 Subject: [PATCH 08/79] feat(gcloud): add homebrew installation path (#12308) --- plugins/gcloud/gcloud.plugin.zsh | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/gcloud/gcloud.plugin.zsh b/plugins/gcloud/gcloud.plugin.zsh index cf3d650ea..fa8f884a4 100644 --- a/plugins/gcloud/gcloud.plugin.zsh +++ b/plugins/gcloud/gcloud.plugin.zsh @@ -9,6 +9,7 @@ if [[ -z "${CLOUDSDK_HOME}" ]]; then "/usr/local/share/google-cloud-sdk" "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk" "/opt/homebrew/Caskroom/google-cloud-sdk/latest/google-cloud-sdk" + "/opt/homebrew/share/google-cloud-sdk" "/usr/share/google-cloud-sdk" "/snap/google-cloud-sdk/current" "/snap/google-cloud-cli/current" From 130002a79e8567befa409177990bb2724b8edefc Mon Sep 17 00:00:00 2001 From: Gregory Reshetniak Date: Wed, 3 Apr 2024 09:10:33 +0200 Subject: [PATCH 09/79] feat(httpie): complete https command (#12314) --- plugins/httpie/_httpie | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/httpie/_httpie b/plugins/httpie/_httpie index 11bc8e1f8..2c0db229f 100644 --- a/plugins/httpie/_httpie +++ b/plugins/httpie/_httpie @@ -1,4 +1,4 @@ -#compdef http +#compdef http https # ------------------------------------------------------------------------------ # Copyright (c) 2015 GitHub zsh-users - http://github.com/zsh-users # All rights reserved. From b43b84abc77850a3734c127c38afdd7cf7739dc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Yhuel?= Date: Wed, 3 Apr 2024 19:42:47 +0200 Subject: [PATCH 10/79] fix(async): avoid blocking the shell while waiting (#12304) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Marc Cornellà --- lib/async_prompt.zsh | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/lib/async_prompt.zsh b/lib/async_prompt.zsh index 384e49d33..ac95bcd73 100644 --- a/lib/async_prompt.zsh +++ b/lib/async_prompt.zsh @@ -82,10 +82,8 @@ function _omz_async_request { exec {fd}< <( # Tell parent process our PID builtin echo ${sysparams[pid]} - # Store handler name for callback - builtin echo $handler # Set exit code for the handler if used - (exit $ret) + () { return $ret } # Run the async function handler $handler ) @@ -98,8 +96,7 @@ function _omz_async_request { command true # Save the PID from the handler child process - read pid <&$fd - _OMZ_ASYNC_PIDS[$handler]=$pid + read -u $fd "_OMZ_ASYNC_PIDS[$handler]" # When the fd is readable, call the response handler zle -F "$fd" _omz_async_callback @@ -114,15 +111,14 @@ function _omz_async_callback() { local err=$2 # Second arg will be passed in case of error if [[ -z "$err" || "$err" == "hup" ]]; then - # Get handler name from first line - local handler - read handler <&$fd + # Get handler name from fd + local handler="${(k)_OMZ_ASYNC_FDS[(r)$fd]}" # Store old output which is supposed to be already printed local old_output="${_OMZ_ASYNC_OUTPUT[$handler]}" # Read output from fd - _OMZ_ASYNC_OUTPUT[$handler]="$(cat <&$fd)" + IFS= read -r -u $fd -d '' "_OMZ_ASYNC_OUTPUT[$handler]" # Repaint prompt if output has changed if [[ "$old_output" != "${_OMZ_ASYNC_OUTPUT[$handler]}" ]]; then From ec1afe9dd683c36e6384db25fc1e95acbb0cbc7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Wed, 3 Apr 2024 19:55:46 +0200 Subject: [PATCH 11/79] feat(git)!: enable async git prompt (now for real) BREAKING CHANGE: the new async prompt feature will render prompt information asyncronously and degrade nicely when the calls take too long to finish, as the prompt will already be first drawn and interactive. This is enabled by default for the git prompt and themes that use it (`git_prompt_info`). If you find that it's not working for you, please open an issue if one is not already opened, and see https://github.com/ohmyzsh/ohmyzsh#disable-async-git-prompt for how to turn it off. --- README.md | 12 ++++++++++++ lib/git.zsh | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b3561a833..2ba374335 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,7 @@ To learn more, visit [ohmyz.sh](https://ohmyz.sh), follow [@ohmyzsh](https://twi - [Custom Plugins And Themes](#custom-plugins-and-themes) - [Enable GNU ls In macOS And freeBSD Systems](#enable-gnu-ls-in-macos-and-freebsd-systems) - [Skip Aliases](#skip-aliases) + - [Disable async git prompt](#disable-async-git-prompt) - [Getting Updates](#getting-updates) - [Updates Verbosity](#updates-verbosity) - [Manual Updates](#manual-updates) @@ -361,6 +362,17 @@ Instead, you can now use the following: zstyle ':omz:lib:directories' aliases no ``` +### Disable async git prompt + +Async prompt functions are an experimental feature (included on April 3, 2024) that allows Oh My Zsh to render prompt information +asyncronously. This can improve prompt rendering performance, but it might not work well with some setups. We hope that's not an +issue, but if you're seeing problems with this new feature, you can turn it of by setting the following in your .zshrc file, +before Oh My Zsh is sourced: + +```sh +zstyle ':omz:alpha:lib:git' async-prompt no +``` + #### Notice > This feature is currently in a testing phase and it may be subject to change in the future. diff --git a/lib/git.zsh b/lib/git.zsh index 96df5589d..4d6681c5b 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -38,7 +38,7 @@ function _omz_git_prompt_status() { } # Enable async prompt by default unless the setting is at false / no -if zstyle -t ':omz:alpha:lib:git' async-prompt; then +if zstyle -T ':omz:alpha:lib:git' async-prompt; then function git_prompt_info() { if [[ -n "$_OMZ_ASYNC_OUTPUT[_omz_git_prompt_status]" ]]; then echo -n "$_OMZ_ASYNC_OUTPUT[_omz_git_prompt_status]" From 04007a0e5d0a458efff23da896cf70dc40df585d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Yhuel?= Date: Wed, 3 Apr 2024 21:32:16 +0200 Subject: [PATCH 12/79] feat(git): implement async completion for `git_prompt_status` (#12319) This is important for themes using it, since it is usually a little slower than git_prompt_info. Also two small fixes : - the handler for git_prompt_info was incorrectly named _omz_git_prompt_status - _defer_async_git_register was kept in precmd, there is no need to call it on each prompt --- lib/git.zsh | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/lib/git.zsh b/lib/git.zsh index 4d6681c5b..76b3778db 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -9,7 +9,7 @@ function __git_prompt_git() { GIT_OPTIONAL_LOCKS=0 command git "$@" } -function _omz_git_prompt_status() { +function _omz_git_prompt_info() { # If we are on a folder not tracked by git, get out. # Otherwise, check for hide-info at global and local repository level if ! __git_prompt_git rev-parse --git-dir &> /dev/null \ @@ -40,6 +40,12 @@ function _omz_git_prompt_status() { # Enable async prompt by default unless the setting is at false / no if zstyle -T ':omz:alpha:lib:git' async-prompt; then function git_prompt_info() { + if [[ -n "$_OMZ_ASYNC_OUTPUT[_omz_git_prompt_info]" ]]; then + echo -n "$_OMZ_ASYNC_OUTPUT[_omz_git_prompt_info]" + fi + } + + function git_prompt_status() { if [[ -n "$_OMZ_ASYNC_OUTPUT[_omz_git_prompt_status]" ]]; then echo -n "$_OMZ_ASYNC_OUTPUT[_omz_git_prompt_status]" fi @@ -51,8 +57,13 @@ if zstyle -T ':omz:alpha:lib:git' async-prompt; then # Check if git_prompt_info is used in a prompt variable case "${PS1}:${PS2}:${PS3}:${PS4}:${RPS1}:${RPS2}:${RPS3}:${RPS4}" in *(\$\(git_prompt_info\)|\`git_prompt_info\`)*) + _omz_register_handler _omz_git_prompt_info + ;; + esac + + case "${PS1}:${PS2}:${PS3}:${PS4}:${RPS1}:${RPS2}:${RPS3}:${RPS4}" in + *(\$\(git_prompt_status\)|\`git_prompt_status\`)*) _omz_register_handler _omz_git_prompt_status - return ;; esac @@ -65,6 +76,9 @@ if zstyle -T ':omz:alpha:lib:git' async-prompt; then precmd_functions=(_defer_async_git_register $precmd_functions) else function git_prompt_info() { + _omz_git_prompt_info + } + function git_prompt_status() { _omz_git_prompt_status } fi @@ -197,7 +211,7 @@ function git_prompt_long_sha() { SHA=$(__git_prompt_git rev-parse HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER" } -function git_prompt_status() { +function _omz_git_prompt_status() { [[ "$(__git_prompt_git config --get oh-my-zsh.hide-status 2>/dev/null)" = 1 ]] && return # Maps a git status prefix to an internal constant From 6d0362ef2f355a05cf945fae882ad1fa95428991 Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Thu, 4 Apr 2024 10:08:28 +0200 Subject: [PATCH 13/79] fix(archlinux): make `upgrade` work with non-english Closes #12316 --- plugins/archlinux/archlinux.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/archlinux/archlinux.plugin.zsh b/plugins/archlinux/archlinux.plugin.zsh index fca6548c0..e20a31156 100644 --- a/plugins/archlinux/archlinux.plugin.zsh +++ b/plugins/archlinux/archlinux.plugin.zsh @@ -179,8 +179,8 @@ fi # Check Arch Linux PGP Keyring before System Upgrade to prevent failure. function upgrade() { echo ":: Checking Arch Linux PGP Keyring..." - local installedver="$(sudo pacman -Qi archlinux-keyring | grep -Po '(?<=Version : ).*')" - local currentver="$(sudo pacman -Si archlinux-keyring | grep -Po '(?<=Version : ).*')" + local installedver="$(LANG= sudo pacman -Qi archlinux-keyring | grep -Po '(?<=Version : ).*')" + local currentver="$(LANG= sudo pacman -Si archlinux-keyring | grep -Po '(?<=Version : ).*')" if [ $installedver != $currentver ]; then echo " Arch Linux PGP Keyring is out of date." echo " Updating before full system upgrade." From 114b58ed4e93faee352187779c7151f8580f24fe Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Thu, 4 Apr 2024 11:58:43 +0200 Subject: [PATCH 14/79] fix(git): disable locally `ksharrays` Fixes #12321 --- lib/git.zsh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/git.zsh b/lib/git.zsh index 76b3778db..23d11db2d 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -40,12 +40,14 @@ function _omz_git_prompt_info() { # Enable async prompt by default unless the setting is at false / no if zstyle -T ':omz:alpha:lib:git' async-prompt; then function git_prompt_info() { + setopt localoptions noksharrays if [[ -n "$_OMZ_ASYNC_OUTPUT[_omz_git_prompt_info]" ]]; then echo -n "$_OMZ_ASYNC_OUTPUT[_omz_git_prompt_info]" fi } function git_prompt_status() { + setopt localoptions noksharrays if [[ -n "$_OMZ_ASYNC_OUTPUT[_omz_git_prompt_status]" ]]; then echo -n "$_OMZ_ASYNC_OUTPUT[_omz_git_prompt_status]" fi From 9d529c41cc82580d0a947ce8bcf5ff7775585fe5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Yhuel?= Date: Thu, 4 Apr 2024 16:20:20 +0200 Subject: [PATCH 15/79] perf(async): avoid executing `true` if not required (#12318) The issue which required "command true" was fixed in zsh 5.8. --- lib/async_prompt.zsh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/async_prompt.zsh b/lib/async_prompt.zsh index ac95bcd73..a83c57f35 100644 --- a/lib/async_prompt.zsh +++ b/lib/async_prompt.zsh @@ -3,6 +3,7 @@ # https://github.com/woefe/git-prompt.zsh/blob/master/git-prompt.zsh zmodload zsh/system +autoload -Uz is-at-least # For now, async prompt function handlers are set up like so: # First, define the async function handler and register the handler @@ -93,7 +94,8 @@ function _omz_async_request { # There's a weird bug here where ^C stops working unless we force a fork # See https://github.com/zsh-users/zsh-autosuggestions/issues/364 - command true + # and https://github.com/zsh-users/zsh-autosuggestions/pull/612 + is-at-least 5.8 || command true # Save the PID from the handler child process read -u $fd "_OMZ_ASYNC_PIDS[$handler]" From 038931039030911852d456215d6f39385d5b7a6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Fri, 5 Apr 2024 07:38:36 +0200 Subject: [PATCH 16/79] fix(lib/git): fix detection of function use in prompt RPS1 and RPROMPT are not equivalent, though they have the same effect. Added both to detect if `git_prompt_*` is used. Fixes #12325 --- lib/git.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/git.zsh b/lib/git.zsh index 23d11db2d..c4265970b 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -57,13 +57,13 @@ if zstyle -T ':omz:alpha:lib:git' async-prompt; then # or any of the other prompt variables function _defer_async_git_register() { # Check if git_prompt_info is used in a prompt variable - case "${PS1}:${PS2}:${PS3}:${PS4}:${RPS1}:${RPS2}:${RPS3}:${RPS4}" in + case "${PS1}:${PS2}:${PS3}:${PS4}:${RPROMPT}:${RPS1}:${RPS2}:${RPS3}:${RPS4}" in *(\$\(git_prompt_info\)|\`git_prompt_info\`)*) _omz_register_handler _omz_git_prompt_info ;; esac - case "${PS1}:${PS2}:${PS3}:${PS4}:${RPS1}:${RPS2}:${RPS3}:${RPS4}" in + case "${PS1}:${PS2}:${PS3}:${PS4}:${RPROMPT}:${RPS1}:${RPS2}:${RPS3}:${RPS4}" in *(\$\(git_prompt_status\)|\`git_prompt_status\`)*) _omz_register_handler _omz_git_prompt_status ;; From d893dd9b83d518f2b2bd4b9a5b6a92ca0e4e33e2 Mon Sep 17 00:00:00 2001 From: Dee'Kej Date: Sat, 6 Apr 2024 19:12:05 +0200 Subject: [PATCH 17/79] fix(autojump): add macOS 'pkgsrc' installation location (#12329) --- plugins/autojump/autojump.plugin.zsh | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/autojump/autojump.plugin.zsh b/plugins/autojump/autojump.plugin.zsh index 84333a89f..5a52e3067 100644 --- a/plugins/autojump/autojump.plugin.zsh +++ b/plugins/autojump/autojump.plugin.zsh @@ -13,6 +13,7 @@ autojump_paths=( /opt/local/etc/profile.d/autojump.sh # macOS with MacPorts /usr/local/etc/profile.d/autojump.sh # macOS with Homebrew (default) /opt/homebrew/etc/profile.d/autojump.sh # macOS with Homebrew (default on M1 macs) + /opt/pkg/share/autojump/autojump.zsh # macOS with pkgsrc /etc/profiles/per-user/$USER/etc/profile.d/autojump.sh # macOS Nix, Home Manager and flakes ) From bf713e2c112ee1f0daf10deffa1215c982513f9b Mon Sep 17 00:00:00 2001 From: David Chin Date: Sun, 7 Apr 2024 01:23:19 +0800 Subject: [PATCH 18/79] Update README for git-prompt to clarify how to use (#10922) * Add note about need to customise theme. It may not be obvious that the theme needs to be customised. See: https://github.com/ohmyzsh/ohmyzsh/issues/9395 * Clarify type of theme customisation needed. --- plugins/git-prompt/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/git-prompt/README.md b/plugins/git-prompt/README.md index 05208d72f..8f42c6842 100644 --- a/plugins/git-prompt/README.md +++ b/plugins/git-prompt/README.md @@ -9,6 +9,10 @@ To use it, add `git-prompt` to the plugins array in your zshrc file: plugins=(... git-prompt) ``` +You may also need to [customize your theme](https://github.com/ohmyzsh/ohmyzsh/issues/9395#issuecomment-1027130429) +to change the way the prompt is built. See the +[OMZ wiki on customizing themes](https://github.com/ohmyzsh/ohmyzsh/wiki/Customization#overriding-and-adding-themes). + See the [original repository](https://github.com/olivierverdier/zsh-git-prompt). ## Requirements From a6ce40df49e0b219372517273c4edce1d34e49a2 Mon Sep 17 00:00:00 2001 From: Matheus Richard Date: Mon, 8 Apr 2024 12:48:57 -0300 Subject: [PATCH 19/79] feat(git): introduce `gwipe` alias (#12302) `gpristine` might be too much on several occasions, given that it removes all untracked files. This might not be ideal because it will delete important things like environment files and encryption keys. With that in mind, this commit introduces `gwipe` as a way to get a "clean slate" but still have your dev environment working. --- plugins/git/git.plugin.zsh | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 692a36a73..545ccc541 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -349,6 +349,7 @@ alias grhh='git reset --hard' alias grhk='git reset --keep' alias grhs='git reset --soft' alias gpristine='git reset --hard && git clean --force -dfx' +alias gwipe='git reset --hard && git clean --force -df' alias groh='git reset origin/$(git_current_branch) --hard' alias grs='git restore' alias grss='git restore --source' From 5bff59f78e607e77f2ed924c1e93ccc09a6ccb7e Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Mon, 8 Apr 2024 22:05:23 +0200 Subject: [PATCH 20/79] docs(git): add `gwipe` alias --- plugins/git/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/git/README.md b/plugins/git/README.md index 4acb0c858..181de37fc 100644 --- a/plugins/git/README.md +++ b/plugins/git/README.md @@ -166,6 +166,7 @@ plugins=(... git) | `grhk` | `git reset --keep` | | `grhs` | `git reset --soft` | | `gpristine` | `git reset --hard && git clean --force -dfx` | +| `gwipe` | `git reset --hard && git clean --force -df` | | `groh` | `git reset origin/$(git_current_branch) --hard` | | `grs` | `git restore` | | `grss` | `git restore --source` | From 982ea721bde90c1fca233419e2c5b6e90fd10225 Mon Sep 17 00:00:00 2001 From: Reza Askari Date: Tue, 9 Apr 2024 00:06:38 +0330 Subject: [PATCH 21/79] feat(laravel): add `artisan test` alias (`pats`) (#12310) --- plugins/laravel/README.md | 1 + plugins/laravel/laravel.plugin.zsh | 1 + 2 files changed, 2 insertions(+) diff --git a/plugins/laravel/README.md b/plugins/laravel/README.md index 95f590191..a831a86b6 100644 --- a/plugins/laravel/README.md +++ b/plugins/laravel/README.md @@ -10,6 +10,7 @@ plugins=(... laravel) |:-:|:-:| | `artisan` | `php artisan` | | `pas` | `php artisan serve` | +| `pats` | `php artisan test` | ## Database diff --git a/plugins/laravel/laravel.plugin.zsh b/plugins/laravel/laravel.plugin.zsh index a8382d3c9..319946f07 100644 --- a/plugins/laravel/laravel.plugin.zsh +++ b/plugins/laravel/laravel.plugin.zsh @@ -4,6 +4,7 @@ alias bob='php artisan bob::build' # Development alias pas='php artisan serve' +alias pats='php artisan test' # Database alias pam='php artisan migrate' From 3e2a5742cdb4deae4d7f10351d59c7f2933e3555 Mon Sep 17 00:00:00 2001 From: Soo Philip Jason Kim Date: Tue, 9 Apr 2024 05:40:15 +0900 Subject: [PATCH 22/79] feat(git): add alias `gmc` for `git merge --continue` (#12326) Co-authored-by: PJ Kim --- plugins/git/README.md | 1 + plugins/git/git.plugin.zsh | 1 + 2 files changed, 2 insertions(+) diff --git a/plugins/git/README.md b/plugins/git/README.md index 181de37fc..4c005ad2f 100644 --- a/plugins/git/README.md +++ b/plugins/git/README.md @@ -111,6 +111,7 @@ plugins=(... git) | `gfg` | `git ls-files \| grep` | | `gm` | `git merge` | | `gma` | `git merge --abort` | +| `gmc` | `git merge --continue` | | `gms` | `git merge --squash` | | `gmom` | `git merge origin/$(git_main_branch)` | | `gmum` | `git merge upstream/$(git_main_branch)` | diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 545ccc541..146f4a512 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -252,6 +252,7 @@ alias gignored='git ls-files -v | grep "^[[:lower:]]"' alias gfg='git ls-files | grep' alias gm='git merge' alias gma='git merge --abort' +alias gmc='git merge --continue' alias gms="git merge --squash" alias gmom='git merge origin/$(git_main_branch)' alias gmum='git merge upstream/$(git_main_branch)' From a8f7f9f707ca5fb9ac7bedb088748b09db2fd3bd Mon Sep 17 00:00:00 2001 From: MoAlkhateeb <110918029+MoAlkhateeb@users.noreply.github.com> Date: Tue, 9 Apr 2024 09:07:57 +0300 Subject: [PATCH 23/79] fix(history)!: fix arg passing to `fc` for `history` command (#12338) BREAKING CHANGE: we have fixed a bug in the `history` wrapper for OMZ which means that running just history will now not show all the history since the 1st command, but only recent ones. To get the previous behavior, you can run `history 1` to get all the command history, or other commands such as `history -30` to get the last 30 commands. --- lib/history.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/history.zsh b/lib/history.zsh index 794076904..c39c8c866 100644 --- a/lib/history.zsh +++ b/lib/history.zsh @@ -12,8 +12,8 @@ function omz_history { # if -l provided, run as if calling `fc' directly builtin fc "$@" else - # unless a number is provided, show all history events (starting from 1) - [[ ${@[-1]-} = *[0-9]* ]] && builtin fc -l "$@" || builtin fc -l "$@" 1 + # otherwise, run `fc -l` with a custom format + builtin fc -l "$@" fi } From ef402864830ba2e23720e3a6ee6f6b4f0e05d692 Mon Sep 17 00:00:00 2001 From: Taekin Kim Date: Tue, 9 Apr 2024 19:18:05 +0900 Subject: [PATCH 24/79] docs: fix typo (#12339) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2ba374335..dea36fda7 100644 --- a/README.md +++ b/README.md @@ -366,7 +366,7 @@ zstyle ':omz:lib:directories' aliases no Async prompt functions are an experimental feature (included on April 3, 2024) that allows Oh My Zsh to render prompt information asyncronously. This can improve prompt rendering performance, but it might not work well with some setups. We hope that's not an -issue, but if you're seeing problems with this new feature, you can turn it of by setting the following in your .zshrc file, +issue, but if you're seeing problems with this new feature, you can turn it off by setting the following in your .zshrc file, before Oh My Zsh is sourced: ```sh From f85f501bcf3dc771c64f4b2ec7609fc542d4d031 Mon Sep 17 00:00:00 2001 From: Bartek Pacia Date: Tue, 9 Apr 2024 11:19:14 +0100 Subject: [PATCH 25/79] feat(macos): `ofd` now opens any directory (#12337) Co-authored-by: Carlo Sala --- plugins/macos/README.md | 2 +- plugins/macos/macos.plugin.zsh | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/plugins/macos/README.md b/plugins/macos/README.md index 1cb9b395d..2c52ec8a7 100644 --- a/plugins/macos/README.md +++ b/plugins/macos/README.md @@ -17,7 +17,7 @@ Original author: [Sorin Ionescu](https://github.com/sorin-ionescu) | `tab` | Open the current directory in a new tab | | `split_tab` | Split the current terminal tab horizontally | | `vsplit_tab` | Split the current terminal tab vertically | -| `ofd` | Open the current directory in a Finder window | +| `ofd` | Open passed directories (or $PWD by default) in Finder | | `pfd` | Return the path of the frontmost Finder window | | `pfs` | Return the current Finder selection | | `cdf` | `cd` to the current Finder directory | diff --git a/plugins/macos/macos.plugin.zsh b/plugins/macos/macos.plugin.zsh index a4347005e..2702a1901 100644 --- a/plugins/macos/macos.plugin.zsh +++ b/plugins/macos/macos.plugin.zsh @@ -3,8 +3,15 @@ 0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}" 0="${${(M)0:#/*}:-$PWD/$0}" -# Open the current directory in a Finder window -alias ofd='open_command $PWD' +# Open in Finder the directories passed as arguments, or the current directory if +# no directories are passed +function ofd { + if (( ! $# )); then + open_command $PWD + else + open_command $@ + fi +} # Show/hide hidden files in the Finder alias showfiles="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder" From 605d76616aa47b2e5abe25eb26c4c9c1554f93d5 Mon Sep 17 00:00:00 2001 From: MoAlkhateeb <110918029+MoAlkhateeb@users.noreply.github.com> Date: Tue, 9 Apr 2024 19:09:26 +0300 Subject: [PATCH 26/79] fix(history): revert to old behavior when no args passed (#12341) * Fixed a bug in *omz_history* where it would automatically create a file when run with the -p flag * Reverted old history behaviour while fixing parsing bug --- lib/history.zsh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/history.zsh b/lib/history.zsh index c39c8c866..56dda2462 100644 --- a/lib/history.zsh +++ b/lib/history.zsh @@ -3,7 +3,10 @@ function omz_history { local clear list zparseopts -E c=clear l=list - if [[ -n "$clear" ]]; then + if [[ $# -eq 0 ]]; then + # if no arguments provided, show full history starting from 1 + builtin fc -l 1 + elif [[ -n "$clear" ]]; then # if -c provided, clobber the history file echo -n >| "$HISTFILE" fc -p "$HISTFILE" From 53c4c4671a931d9f7a3b39fe9131c6f84fe27ca5 Mon Sep 17 00:00:00 2001 From: Ruize Tang <1466040111@qq.com> Date: Wed, 10 Apr 2024 21:39:19 +0800 Subject: [PATCH 27/79] fix(shell-proxy): support ssh-proxy using http proxy in cygwin (#12340) --- plugins/shell-proxy/ssh-proxy.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/shell-proxy/ssh-proxy.py b/plugins/shell-proxy/ssh-proxy.py index a498c84bc..4b692f9e4 100755 --- a/plugins/shell-proxy/ssh-proxy.py +++ b/plugins/shell-proxy/ssh-proxy.py @@ -22,7 +22,8 @@ if parsed.scheme not in proxy_protocols: def make_argv(): yield "nc" - if sys.platform == 'linux': + if sys.platform in {'linux', 'cygwin'}: + # caveats: the built-in netcat of most linux distributions and cygwin support proxy type # caveats: macOS built-in netcat command not supported proxy-type yield "-X" # --proxy-type # Supported protocols are 4 (SOCKS v4), 5 (SOCKS v5) and connect (HTTP proxy). From 6e9d57d5abdb33b0c22f8979dc529c1a046d7aa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?jo=C3=A9l=20hawkins=20torres?= Date: Thu, 11 Apr 2024 10:27:29 -0700 Subject: [PATCH 28/79] fix(yarn): use `builtin cd` in completion (#12347) --- plugins/yarn/_yarn | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/yarn/_yarn b/plugins/yarn/_yarn index f15756ff4..9ffe5660c 100644 --- a/plugins/yarn/_yarn +++ b/plugins/yarn/_yarn @@ -86,7 +86,7 @@ _global_commands=( ) _yarn_find_package_json() { - local dir=$(cd "$1" && pwd) + local dir=$(builtin cd "$1" && pwd) while true do @@ -109,7 +109,7 @@ _yarn_commands_scripts() { if [[ -n $opt_args[--cwd] ]]; then packageJson=$(_yarn_find_package_json $opt_args[--cwd]) - binaries=($(cd $opt_args[--cwd] && echo node_modules/.bin/*(x:t))) + binaries=($(builtin cd $opt_args[--cwd] && echo node_modules/.bin/*(x:t))) else packageJson=$(_yarn_find_package_json $pwd) binaries=($(echo node_modules/.bin/*(x:t))) @@ -130,9 +130,9 @@ _yarn_scripts() { if [[ -n $_yarn_run_cwd ]]; then packageJson=$(_yarn_find_package_json $_yarn_run_cwd) if [[ -d "${_yarn_run_cwd}/node_modules" ]]; then - binaries=($(cd $_yarn_run_cwd && echo node_modules/.bin/*(x:t))) + binaries=($(builtin cd $_yarn_run_cwd && echo node_modules/.bin/*(x:t))) else - binaries=($(cd $_yarn_run_cwd && yarn bin | perl -wln -e 'm{^[^:]+: (\S+)$} and print $1')) + binaries=($(builtin cd $_yarn_run_cwd && yarn bin | perl -wln -e 'm{^[^:]+: (\S+)$} and print $1')) fi else packageJson=$(_yarn_find_package_json $pwd) From 31f2025e0fa963788655fe197e0179c47588b175 Mon Sep 17 00:00:00 2001 From: Kate Sullivan <75387802+katesullivan@users.noreply.github.com> Date: Fri, 12 Apr 2024 02:24:54 -0500 Subject: [PATCH 29/79] feat(poetry-env): support changing between two venv dirs (#12346) Co-authored-by: Carlo Sala --- plugins/poetry-env/poetry-env.plugin.zsh | 38 ++++++++++++------------ 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/plugins/poetry-env/poetry-env.plugin.zsh b/plugins/poetry-env/poetry-env.plugin.zsh index 97ca52492..f98c177b4 100644 --- a/plugins/poetry-env/poetry-env.plugin.zsh +++ b/plugins/poetry-env/poetry-env.plugin.zsh @@ -1,27 +1,27 @@ -# Automatic poetry environment activation/deactivation _togglePoetryShell() { - # deactivate environment if pyproject.toml doesn't exist and not in a subdir - if [[ ! -f "$PWD/pyproject.toml" ]] ; then - if [[ "$poetry_active" == 1 ]]; then - if [[ "$PWD" != "$poetry_dir"* ]]; then - export poetry_active=0 - deactivate - return - fi - fi + # Determine if currently in a Poetry-managed directory + local in_poetry_dir=0 + if [[ -f "$PWD/pyproject.toml" ]] && grep -q 'tool.poetry' "$PWD/pyproject.toml"; then + in_poetry_dir=1 fi - # activate the environment if pyproject.toml exists - if [[ "$poetry_active" != 1 ]]; then - if [[ -f "$PWD/pyproject.toml" ]]; then - if grep -q 'tool.poetry' "$PWD/pyproject.toml" && venv_dir=$(poetry env info --path); then - export poetry_active=1 - export poetry_dir="$PWD" - source "${venv_dir}/bin/activate" - fi + # Deactivate the current environment if moving out of a Poetry directory or into a different Poetry directory + if [[ $poetry_active -eq 1 ]] && { [[ $in_poetry_dir -eq 0 ]] || [[ "$PWD" != "$poetry_dir"* ]]; }; then + export poetry_active=0 + unset poetry_dir + deactivate + fi + + # Activate the environment if in a Poetry directory and no environment is currently active + if [[ $in_poetry_dir -eq 1 ]] && [[ $poetry_active -ne 1 ]]; then + venv_dir=$(poetry env info --path 2>/dev/null) + if [[ -n "$venv_dir" ]]; then + export poetry_active=1 + export poetry_dir="$PWD" + source "${venv_dir}/bin/activate" fi fi } autoload -U add-zsh-hook add-zsh-hook chpwd _togglePoetryShell -_togglePoetryShell +_togglePoetryShell # Initial call to check the current directory at shell startup From b26000d1685fa61bddddea42e2a606b2a0d64e25 Mon Sep 17 00:00:00 2001 From: Jhon Pedroza Date: Tue, 16 Apr 2024 02:52:12 -0500 Subject: [PATCH 30/79] feat(tmux): sessions named as current dir (#12351) --- plugins/tmux/README.md | 1 + plugins/tmux/tmux.plugin.zsh | 24 ++++++++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/plugins/tmux/README.md b/plugins/tmux/README.md index 50f8b2c2f..09952a9f5 100644 --- a/plugins/tmux/README.md +++ b/plugins/tmux/README.md @@ -37,6 +37,7 @@ The plugin also supports the following: | `ZSH_TMUX_AUTOQUIT` | Automatically closes terminal once tmux exits (default: `ZSH_TMUX_AUTOSTART`) | | `ZSH_TMUX_CONFIG` | Set the configuration path (default: `$HOME/.tmux.conf`, `$XDG_CONFIG_HOME/tmux/tmux.conf`) | | `ZSH_TMUX_DEFAULT_SESSION_NAME` | Set tmux default session name when autostart is enabled | +| `ZSH_TMUX_AUTONAME_SESSION` | Automatically name new sessions based on the basename of `$PWD` (default: `false`) | | `ZSH_TMUX_DETACHED` | Set the detached mode (default: `false`) | | `ZSH_TMUX_FIXTERM` | Sets `$TERM` to 256-color term or not based on current terminal support | | `ZSH_TMUX_FIXTERM_WITHOUT_256COLOR` | `$TERM` to use for non 256-color terminals (default: `tmux` if available, `screen` otherwise) | diff --git a/plugins/tmux/tmux.plugin.zsh b/plugins/tmux/tmux.plugin.zsh index 791592d8f..f65598358 100644 --- a/plugins/tmux/tmux.plugin.zsh +++ b/plugins/tmux/tmux.plugin.zsh @@ -13,6 +13,8 @@ fi : ${ZSH_TMUX_AUTOCONNECT:=true} # Automatically close the terminal when tmux exits : ${ZSH_TMUX_AUTOQUIT:=$ZSH_TMUX_AUTOSTART} +# Automatically name the new session based on the basename of PWD +: ${ZSH_TMUX_AUTONAME_SESSION:=false} # Set term to screen or screen-256color based on current terminal support : ${ZSH_TMUX_DETACHED:=false} # Set detached mode @@ -102,9 +104,22 @@ function _zsh_tmux_plugin_run() { local _detached="" [[ "$ZSH_TMUX_DETACHED" == "true" ]] && _detached="-d" + + local session_name + if [[ "$ZSH_TMUX_AUTONAME_SESSION" == "true" ]]; then + # Name the session after the basename of the current directory + session_name=${PWD##*/} + # If the current directory is the home directory, name it 'HOME' + [[ "$PWD" == "$HOME" ]] && session_name="HOME" + # If the current directory is the root directory, name it 'ROOT' + [[ "$PWD" == "/" ]] && session_name="ROOT" + else + session_name="$ZSH_TMUX_DEFAULT_SESSION_NAME" + fi + # Try to connect to an existing session. - if [[ -n "$ZSH_TMUX_DEFAULT_SESSION_NAME" ]]; then - [[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]] && $tmux_cmd attach $_detached -t $ZSH_TMUX_DEFAULT_SESSION_NAME + if [[ -n "$session_name" ]]; then + [[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]] && $tmux_cmd attach $_detached -t "$session_name" else [[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]] && $tmux_cmd attach $_detached fi @@ -116,8 +131,9 @@ function _zsh_tmux_plugin_run() { elif [[ -e "$ZSH_TMUX_CONFIG" ]]; then tmux_cmd+=(-f "$ZSH_TMUX_CONFIG") fi - if [[ -n "$ZSH_TMUX_DEFAULT_SESSION_NAME" ]]; then - $tmux_cmd new-session -s $ZSH_TMUX_DEFAULT_SESSION_NAME + + if [[ -n "$session_name" ]]; then + $tmux_cmd new-session -s "$session_name" else $tmux_cmd new-session fi From efa8de0b52dda6b51bded60c0b26b6dce2dfa354 Mon Sep 17 00:00:00 2001 From: Martin Hans Date: Tue, 16 Apr 2024 19:38:58 +0200 Subject: [PATCH 31/79] fix(history): fix edge cases introduced in #12341 (#12357) --- lib/history.zsh | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/history.zsh b/lib/history.zsh index 56dda2462..ec89bc15e 100644 --- a/lib/history.zsh +++ b/lib/history.zsh @@ -1,22 +1,20 @@ ## History wrapper function omz_history { - local clear list - zparseopts -E c=clear l=list + # parse arguments and remove from $@ + local clear list stamp + zparseopts -E -D c=clear l=list f=stamp E=stamp i=stamp if [[ $# -eq 0 ]]; then # if no arguments provided, show full history starting from 1 - builtin fc -l 1 + builtin fc $stamp -l 1 elif [[ -n "$clear" ]]; then # if -c provided, clobber the history file echo -n >| "$HISTFILE" fc -p "$HISTFILE" echo >&2 History file deleted. - elif [[ -n "$list" ]]; then - # if -l provided, run as if calling `fc' directly - builtin fc "$@" else # otherwise, run `fc -l` with a custom format - builtin fc -l "$@" + builtin fc $stamp -l "$@" fi } From 7ef3f49f97ff34db3785b1cea444eb4972b1937b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Tue, 16 Apr 2024 20:04:25 +0200 Subject: [PATCH 32/79] fix(agnoster): prevent accidental alias use --- themes/agnoster.zsh-theme | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme index bd0405efb..c2a542163 100644 --- a/themes/agnoster.zsh-theme +++ b/themes/agnoster.zsh-theme @@ -96,7 +96,7 @@ prompt_context() { # Git: branch/detached head, dirty status prompt_git() { (( $+commands[git] )) || return - if [[ "$(git config --get oh-my-zsh.hide-status 2>/dev/null)" = 1 ]]; then + if [[ "$(command git config --get oh-my-zsh.hide-status 2>/dev/null)" = 1 ]]; then return fi local PL_BRANCH_CHAR @@ -106,12 +106,12 @@ prompt_git() { } local ref dirty mode repo_path - if [[ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]]; then - repo_path=$(git rev-parse --git-dir 2>/dev/null) + if [[ "$(command git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]]; then + repo_path=$(command git rev-parse --git-dir 2>/dev/null) dirty=$(parse_git_dirty) - ref=$(git symbolic-ref HEAD 2> /dev/null) || \ - ref="◈ $(git describe --exact-match --tags HEAD 2> /dev/null)" || \ - ref="➦ $(git rev-parse --short HEAD 2> /dev/null)" + ref=$(command git symbolic-ref HEAD 2> /dev/null) || \ + ref="◈ $(command git describe --exact-match --tags HEAD 2> /dev/null)" || \ + ref="➦ $(command git rev-parse --short HEAD 2> /dev/null)" if [[ -n $dirty ]]; then prompt_segment yellow black else @@ -119,8 +119,8 @@ prompt_git() { fi local ahead behind - ahead=$(git log --oneline @{upstream}.. 2>/dev/null) - behind=$(git log --oneline ..@{upstream} 2>/dev/null) + ahead=$(command git log --oneline @{upstream}.. 2>/dev/null) + behind=$(command git log --oneline ..@{upstream} 2>/dev/null) if [[ -n "$ahead" ]] && [[ -n "$behind" ]]; then PL_BRANCH_CHAR=$'\u21c5' elif [[ -n "$ahead" ]]; then @@ -163,10 +163,10 @@ prompt_bzr() { done local bzr_status status_mod status_all revision - if bzr_status=$(bzr status 2>&1); then + if bzr_status=$(command bzr status 2>&1); then status_mod=$(echo -n "$bzr_status" | head -n1 | grep "modified" | wc -m) status_all=$(echo -n "$bzr_status" | head -n1 | wc -m) - revision=${$(bzr log -r-1 --log-format line | cut -d: -f1):gs/%/%%} + revision=${$(command bzr log -r-1 --log-format line | cut -d: -f1):gs/%/%%} if [[ $status_mod -gt 0 ]] ; then prompt_segment yellow black "bzr@$revision ✚" else @@ -182,13 +182,13 @@ prompt_bzr() { prompt_hg() { (( $+commands[hg] )) || return local rev st branch - if $(hg id >/dev/null 2>&1); then - if $(hg prompt >/dev/null 2>&1); then - if [[ $(hg prompt "{status|unknown}") = "?" ]]; then + if $(command hg id >/dev/null 2>&1); then + if $(command hg prompt >/dev/null 2>&1); then + if [[ $(command hg prompt "{status|unknown}") = "?" ]]; then # if files are not added prompt_segment red white st='±' - elif [[ -n $(hg prompt "{status|modified}") ]]; then + elif [[ -n $(command hg prompt "{status|modified}") ]]; then # if any modification prompt_segment yellow black st='±' @@ -196,15 +196,15 @@ prompt_hg() { # if working copy is clean prompt_segment green $CURRENT_FG fi - echo -n ${$(hg prompt "☿ {rev}@{branch}"):gs/%/%%} $st + echo -n ${$(command hg prompt "☿ {rev}@{branch}"):gs/%/%%} $st else st="" - rev=$(hg id -n 2>/dev/null | sed 's/[^-0-9]//g') - branch=$(hg id -b 2>/dev/null) - if `hg st | grep -q "^\?"`; then + rev=$(command hg id -n 2>/dev/null | sed 's/[^-0-9]//g') + branch=$(command hg id -b 2>/dev/null) + if command hg st | command grep -q "^\?"; then prompt_segment red black st='±' - elif `hg st | grep -q "^[MA]"`; then + elif command hg st | command grep -q "^[MA]"; then prompt_segment yellow black st='±' else From 1ed8d4b55530888bfa723e7dc6226a798260bdc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Wed, 17 Apr 2024 20:21:18 +0200 Subject: [PATCH 33/79] fix(git): turn off async prompt by default on zsh < 5.0.6 (#12331) See https://github.com/ohmyzsh/ohmyzsh/issues/12331#issuecomment-2059460268 --- lib/git.zsh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/git.zsh b/lib/git.zsh index c4265970b..277c0b3e8 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -1,3 +1,5 @@ +autoload -Uz is-at-least + # The git prompt's git commands are read-only and should not interfere with # other processes. This environment variable is equivalent to running with `git # --no-optional-locks`, but falls back gracefully for older versions of git. @@ -37,8 +39,10 @@ function _omz_git_prompt_info() { echo "${ZSH_THEME_GIT_PROMPT_PREFIX}${ref:gs/%/%%}${upstream:gs/%/%%}$(parse_git_dirty)${ZSH_THEME_GIT_PROMPT_SUFFIX}" } -# Enable async prompt by default unless the setting is at false / no -if zstyle -T ':omz:alpha:lib:git' async-prompt; then +# Use async version if setting is enabled, or undefined but zsh version is at least 5.0.6 +# https://github.com/ohmyzsh/ohmyzsh/issues/12331#issuecomment-2059460268 +if zstyle -t ':omz:alpha:lib:git' async-prompt \ + || { is-at-least 5.0.6 && zstyle -T ':omz:alpha:lib:git' async-prompt }; then function git_prompt_info() { setopt localoptions noksharrays if [[ -n "$_OMZ_ASYNC_OUTPUT[_omz_git_prompt_info]" ]]; then From eafa78217d836115a99f80bddfcd0a8901a15f77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Thu, 18 Apr 2024 07:12:32 +0200 Subject: [PATCH 34/79] fix(history): fix `history -c` (#12362) Fixes #12362 --- lib/history.zsh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/history.zsh b/lib/history.zsh index ec89bc15e..aace78aa1 100644 --- a/lib/history.zsh +++ b/lib/history.zsh @@ -4,14 +4,14 @@ function omz_history { local clear list stamp zparseopts -E -D c=clear l=list f=stamp E=stamp i=stamp - if [[ $# -eq 0 ]]; then - # if no arguments provided, show full history starting from 1 - builtin fc $stamp -l 1 - elif [[ -n "$clear" ]]; then + if [[ -n "$clear" ]]; then # if -c provided, clobber the history file echo -n >| "$HISTFILE" fc -p "$HISTFILE" echo >&2 History file deleted. + elif [[ $# -eq 0 ]]; then + # if no arguments provided, show full history starting from 1 + builtin fc $stamp -l 1 else # otherwise, run `fc -l` with a custom format builtin fc $stamp -l "$@" From c262ffbb68e6dfc30b619e6ce6bdbd00f27b8a71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Thu, 18 Apr 2024 07:16:42 +0200 Subject: [PATCH 35/79] fix(update): define `$ZSH` if undefined (#12273) Fixes #12273 Fixes https://github.com/topgrade-rs/topgrade/issues/519 --- tools/upgrade.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/upgrade.sh b/tools/upgrade.sh index d7016aa44..5eb90ab41 100755 --- a/tools/upgrade.sh +++ b/tools/upgrade.sh @@ -10,9 +10,14 @@ fi # Protect against unwanted sourcing case "$ZSH_EVAL_CONTEXT" in - *:file) echo "error: this file should not be sourced" && return ;; + *:file) echo "error: this file should not be sourced" && return 1 ;; esac +# Define "$ZSH" if not defined -- in theory this should be `export`ed by the calling script +if [[ -z "$ZSH" ]]; then + ZSH="${0:a:h:h}" +fi + cd "$ZSH" verbose_mode="default" From 56cfcb44e7ff730c10c5a00b58f38c33c984c52e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Thu, 18 Apr 2024 07:33:13 +0200 Subject: [PATCH 36/79] fix(updater): abort update if `$ZSH` is not a git repository Fixes #12298 --- lib/cli.zsh | 12 +++++++++++- tools/check_for_upgrade.sh | 10 ++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/lib/cli.zsh b/lib/cli.zsh index aa36a6ab5..4a8d4d127 100644 --- a/lib/cli.zsh +++ b/lib/cli.zsh @@ -773,7 +773,17 @@ function _omz::theme::use { } function _omz::update { - local last_commit=$(builtin cd -q "$ZSH"; git rev-parse HEAD) + # Check if git command is available + (( $+commands[git] )) || { + _omz::log error "git is not installed. Aborting..." + return 1 + } + + local last_commit=$(builtin cd -q "$ZSH"; git rev-parse HEAD 2>/dev/null) + [[ $? -eq 0 ]] || { + _omz::log error "\`$ZSH\` is not a git directory. Aborting..." + return 1 + } # Run update script zstyle -s ':omz:update' verbose verbose_mode || verbose_mode=default diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh index 1cc193bde..a5d2112f6 100644 --- a/tools/check_for_upgrade.sh +++ b/tools/check_for_upgrade.sh @@ -20,14 +20,16 @@ zstyle -s ':omz:update' mode update_mode || { } # Cancel update if: -# - the automatic update is disabled. -# - the current user doesn't have write permissions nor owns the $ZSH directory. +# - the automatic update is disabled +# - the current user doesn't have write permissions nor owns the $ZSH directory # - is not run from a tty -# - git is unavailable on the system. +# - git is unavailable on the system +# - $ZSH is not a git repository if [[ "$update_mode" = disabled ]] \ || [[ ! -w "$ZSH" || ! -O "$ZSH" ]] \ || [[ ! -t 1 ]] \ - || ! command git --version 2>&1 >/dev/null; then + || ! command git --version 2>&1 >/dev/null + || (builtin cd -q "$ZSH"; ! command git rev-parse --is-inside-work-tree &>/dev/null); then unset update_mode return fi From 80a651a6dfafc40630b47ad2f173d326844d6925 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Thu, 18 Apr 2024 07:48:33 +0200 Subject: [PATCH 37/79] chore(updater): small typo --- tools/check_for_upgrade.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh index a5d2112f6..1ecab5c0b 100644 --- a/tools/check_for_upgrade.sh +++ b/tools/check_for_upgrade.sh @@ -28,7 +28,7 @@ zstyle -s ':omz:update' mode update_mode || { if [[ "$update_mode" = disabled ]] \ || [[ ! -w "$ZSH" || ! -O "$ZSH" ]] \ || [[ ! -t 1 ]] \ - || ! command git --version 2>&1 >/dev/null + || ! command git --version 2>&1 >/dev/null \ || (builtin cd -q "$ZSH"; ! command git rev-parse --is-inside-work-tree &>/dev/null); then unset update_mode return From d17ca487a4357923d8b8681b9e40c2bb2d2fadea Mon Sep 17 00:00:00 2001 From: Martin Hans Date: Thu, 18 Apr 2024 10:49:34 +0200 Subject: [PATCH 38/79] fix(history): add `t` option to history wrapper (#12365) The `t` option takes a strftime format specification as argument. This fixes cases in which $HIST_STAMPS is set to a value other than `mm/dd/yyyy|dd.mm.yyyy|yyyy-mm-dd`. --- lib/history.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/history.zsh b/lib/history.zsh index aace78aa1..a8431fd5a 100644 --- a/lib/history.zsh +++ b/lib/history.zsh @@ -2,7 +2,7 @@ function omz_history { # parse arguments and remove from $@ local clear list stamp - zparseopts -E -D c=clear l=list f=stamp E=stamp i=stamp + zparseopts -E -D c=clear l=list f=stamp E=stamp i=stamp t:=stamp if [[ -n "$clear" ]]; then # if -c provided, clobber the history file From 1b5503a3eefeb3e248bbc07a2f4e4b7591924307 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Fri, 19 Apr 2024 21:57:46 +0200 Subject: [PATCH 39/79] feat(fzf): support fzf setup for 0.48.0 and older (#12367) Fixes #12355 --- plugins/fzf/fzf.plugin.zsh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/plugins/fzf/fzf.plugin.zsh b/plugins/fzf/fzf.plugin.zsh index 9e372f498..ac4370596 100644 --- a/plugins/fzf/fzf.plugin.zsh +++ b/plugins/fzf/fzf.plugin.zsh @@ -1,3 +1,12 @@ +function fzf_setup_using_fzf() { + (( ${+commands[fzf]} )) || return 1 + + local fzf_ver=${$(fzf --version)[1]} + is-at-least 0.48.0 $fzf_ver || return 1 + + eval "$(fzf --zsh)" +} + function fzf_setup_using_base_dir() { local fzf_base fzf_shell fzfdirs dir @@ -217,7 +226,8 @@ Please add `export FZF_BASE=/path/to/fzf/install/dir` to your .zshrc EOF } -fzf_setup_using_openbsd \ +fzf_setup_using_fzf \ + || fzf_setup_using_openbsd \ || fzf_setup_using_debian \ || fzf_setup_using_opensuse \ || fzf_setup_using_cygwin \ From f78c6b90fc18e2d0bb119ff549207463ce1d57a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Tue, 16 Apr 2024 18:07:10 +0200 Subject: [PATCH 40/79] fix(async): fix crash on zsh < 5.0.6 (#12358) --- lib/async_prompt.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/async_prompt.zsh b/lib/async_prompt.zsh index a83c57f35..db48446e7 100644 --- a/lib/async_prompt.zsh +++ b/lib/async_prompt.zsh @@ -124,7 +124,7 @@ function _omz_async_callback() { # Repaint prompt if output has changed if [[ "$old_output" != "${_OMZ_ASYNC_OUTPUT[$handler]}" ]]; then - zle reset-prompt + zle .reset-prompt zle -R fi From 0c80a063c3ad9513b83589d377c501a8d85d63a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Fri, 19 Apr 2024 18:47:21 +0200 Subject: [PATCH 41/79] chore(async): reenable async prompt by default on zsh < 5.0.6 (#12358) Fixes #12331 --- lib/git.zsh | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/lib/git.zsh b/lib/git.zsh index 277c0b3e8..b257d01a4 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -39,21 +39,17 @@ function _omz_git_prompt_info() { echo "${ZSH_THEME_GIT_PROMPT_PREFIX}${ref:gs/%/%%}${upstream:gs/%/%%}$(parse_git_dirty)${ZSH_THEME_GIT_PROMPT_SUFFIX}" } -# Use async version if setting is enabled, or undefined but zsh version is at least 5.0.6 -# https://github.com/ohmyzsh/ohmyzsh/issues/12331#issuecomment-2059460268 -if zstyle -t ':omz:alpha:lib:git' async-prompt \ - || { is-at-least 5.0.6 && zstyle -T ':omz:alpha:lib:git' async-prompt }; then +# Use async version if setting is enabled or undefined +if zstyle -T ':omz:alpha:lib:git' async-prompt; then function git_prompt_info() { - setopt localoptions noksharrays - if [[ -n "$_OMZ_ASYNC_OUTPUT[_omz_git_prompt_info]" ]]; then - echo -n "$_OMZ_ASYNC_OUTPUT[_omz_git_prompt_info]" + if [[ -n "${_OMZ_ASYNC_OUTPUT[_omz_git_prompt_info]}" ]]; then + echo -n "${_OMZ_ASYNC_OUTPUT[_omz_git_prompt_info]}" fi } function git_prompt_status() { - setopt localoptions noksharrays - if [[ -n "$_OMZ_ASYNC_OUTPUT[_omz_git_prompt_status]" ]]; then - echo -n "$_OMZ_ASYNC_OUTPUT[_omz_git_prompt_status]" + if [[ -n "${_OMZ_ASYNC_OUTPUT[_omz_git_prompt_status]}" ]]; then + echo -n "${_OMZ_ASYNC_OUTPUT[_omz_git_prompt_status]}" fi } From 67581c53c6458566e174620361e84b364b9034d2 Mon Sep 17 00:00:00 2001 From: Zikoeng Xi Date: Tue, 23 Apr 2024 03:37:17 +0800 Subject: [PATCH 42/79] fix(ssh-agent): add identity only if identity exists (#12371) --- plugins/ssh-agent/ssh-agent.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/ssh-agent/ssh-agent.plugin.zsh b/plugins/ssh-agent/ssh-agent.plugin.zsh index 77c422ce1..1da54d4dd 100644 --- a/plugins/ssh-agent/ssh-agent.plugin.zsh +++ b/plugins/ssh-agent/ssh-agent.plugin.zsh @@ -62,7 +62,7 @@ function _add_identities() { # if id is an absolute path, make file equal to id [[ "$id" = /* ]] && file="$id" || file="$HOME/.ssh/$id" # check for filename match, otherwise try for signature match - if [[ ${loaded_ids[(I)$file]} -le 0 ]]; then + if [[ -f $file && ${loaded_ids[(I)$file]} -le 0 ]]; then sig="$(ssh-keygen -lf "$file" | awk '{print $2}')" [[ ${loaded_sigs[(I)$sig]} -le 0 ]] && not_loaded+=("$file") fi From ee69c14beb24c652707b2f6b2a9db0fa8b238d05 Mon Sep 17 00:00:00 2001 From: John Matczak <50644033+cidrmill@users.noreply.github.com> Date: Tue, 23 Apr 2024 01:54:00 -0700 Subject: [PATCH 43/79] feat(fishy): add color to username (#12369) --- themes/fishy.zsh-theme | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/themes/fishy.zsh-theme b/themes/fishy.zsh-theme index 2b8d559e5..3b975c8f4 100644 --- a/themes/fishy.zsh-theme +++ b/themes/fishy.zsh-theme @@ -16,7 +16,8 @@ _fishy_collapsed_wd() { } local user_color='green'; [ $UID -eq 0 ] && user_color='red' -PROMPT='%n@%m %{$fg[$user_color]%}$(_fishy_collapsed_wd)%{$reset_color%}%(!.#.>) ' +local host_color='white'; [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ] && host_color='yellow' +PROMPT='%{$fg[$user_color]%}%n%{$reset_color%}@%{$fg[$host_color]%}%m %{$fg[$user_color]%}$(_fishy_collapsed_wd)%{$reset_color%}%(!.#.>) ' PROMPT2='%{$fg[red]%}\ %{$reset_color%}' local return_status="%{$fg_bold[red]%}%(?..%?)%{$reset_color%}" From 5d2d35cd1741af19553007fe0cc5324744fc58fa Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Tue, 23 Apr 2024 16:21:21 +0200 Subject: [PATCH 44/79] fix(poetry-env): do not deactivate in a subdir Closes #12377 --- plugins/poetry-env/poetry-env.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/poetry-env/poetry-env.plugin.zsh b/plugins/poetry-env/poetry-env.plugin.zsh index f98c177b4..be46717d8 100644 --- a/plugins/poetry-env/poetry-env.plugin.zsh +++ b/plugins/poetry-env/poetry-env.plugin.zsh @@ -6,7 +6,7 @@ _togglePoetryShell() { fi # Deactivate the current environment if moving out of a Poetry directory or into a different Poetry directory - if [[ $poetry_active -eq 1 ]] && { [[ $in_poetry_dir -eq 0 ]] || [[ "$PWD" != "$poetry_dir"* ]]; }; then + if [[ $poetry_active -eq 1 ]] && { [[ $in_poetry_dir -eq 0 ]] && [[ "$PWD" != "$poetry_dir"* ]]; }; then export poetry_active=0 unset poetry_dir deactivate From 803e1a784cd520f101d126b47deea3297e6a82fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Thu, 25 Apr 2024 08:04:18 +0200 Subject: [PATCH 45/79] fix(copybuffer): prevent `which` alias usage (#12379) --- plugins/copybuffer/copybuffer.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/copybuffer/copybuffer.plugin.zsh b/plugins/copybuffer/copybuffer.plugin.zsh index 88bda32a0..e636d9730 100644 --- a/plugins/copybuffer/copybuffer.plugin.zsh +++ b/plugins/copybuffer/copybuffer.plugin.zsh @@ -2,7 +2,7 @@ # onto the system clipboard copybuffer () { - if which clipcopy &>/dev/null; then + if builtin which clipcopy &>/dev/null; then printf "%s" "$BUFFER" | clipcopy else zle -M "clipcopy not found. Please make sure you have Oh My Zsh installed correctly." From 21963f4f678e69fb3154a1d43a33d531a5b3566d Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Tue, 30 Apr 2024 12:56:02 +0200 Subject: [PATCH 46/79] fix(fzf): support old `fzf` versions Closes #12387 --- plugins/fzf/fzf.plugin.zsh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/fzf/fzf.plugin.zsh b/plugins/fzf/fzf.plugin.zsh index ac4370596..3d29f1762 100644 --- a/plugins/fzf/fzf.plugin.zsh +++ b/plugins/fzf/fzf.plugin.zsh @@ -1,8 +1,10 @@ function fzf_setup_using_fzf() { (( ${+commands[fzf]} )) || return 1 - local fzf_ver=${$(fzf --version)[1]} - is-at-least 0.48.0 $fzf_ver || return 1 + # we remove "fzf " prefix, this fixes really old fzf versions behaviour + # see https://github.com/ohmyzsh/ohmyzsh/issues/12387 + local fzf_ver=${"$(fzf --version)"#fzf } + is-at-least 0.48.0 ${${(s: :)fzf_ver}[1]} || return 1 eval "$(fzf --zsh)" } From 8581ecd462ab2714936398c54433ed1deddb2926 Mon Sep 17 00:00:00 2001 From: Antoine Date: Wed, 1 May 2024 11:04:12 +0200 Subject: [PATCH 47/79] feat(autojump): add `nix-darwin` install path (#12389) --- plugins/autojump/autojump.plugin.zsh | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/autojump/autojump.plugin.zsh b/plugins/autojump/autojump.plugin.zsh index 5a52e3067..e385a2de8 100644 --- a/plugins/autojump/autojump.plugin.zsh +++ b/plugins/autojump/autojump.plugin.zsh @@ -15,6 +15,7 @@ autojump_paths=( /opt/homebrew/etc/profile.d/autojump.sh # macOS with Homebrew (default on M1 macs) /opt/pkg/share/autojump/autojump.zsh # macOS with pkgsrc /etc/profiles/per-user/$USER/etc/profile.d/autojump.sh # macOS Nix, Home Manager and flakes + /nix/var/nix/gcroots/current-system/sw/share/zsh/site-functions/autojump.zsh # macOS Nix, nix-darwin ) for file in $autojump_paths; do From 529f77a344de5fd53ea2235547cefd5d15d02723 Mon Sep 17 00:00:00 2001 From: stefan Date: Thu, 2 May 2024 15:11:18 +0200 Subject: [PATCH 48/79] feat(termsupport): support `alacritty*` TERM (#12392) Closes #12391 --- lib/termsupport.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh index d170ffcbf..087bae9bb 100644 --- a/lib/termsupport.zsh +++ b/lib/termsupport.zsh @@ -17,7 +17,7 @@ function title { : ${2=$1} case "$TERM" in - cygwin|xterm*|putty*|rxvt*|konsole*|ansi|mlterm*|alacritty|st*|foot*|contour*) + cygwin|xterm*|putty*|rxvt*|konsole*|ansi|mlterm*|alacritty*|st*|foot*|contour*) print -Pn "\e]2;${2:q}\a" # set window name print -Pn "\e]1;${1:q}\a" # set tab name ;; @@ -129,7 +129,7 @@ fi # Don't define the function if we're in an unsupported terminal case "$TERM" in # all of these either process OSC 7 correctly or ignore entirely - xterm*|putty*|rxvt*|konsole*|mlterm*|alacritty|screen*|tmux*) ;; + xterm*|putty*|rxvt*|konsole*|mlterm*|alacritty*|screen*|tmux*) ;; contour*|foot*) ;; *) # Terminal.app and iTerm2 process OSC 7 correctly From 668ca3a32dae5ff5d164fc3be565f1e2ece248db Mon Sep 17 00:00:00 2001 From: Shai Coleman Date: Fri, 3 May 2024 20:43:53 +0100 Subject: [PATCH 49/79] fix(extract): `zst` now extracts as expected (#12395) --- plugins/extract/extract.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/extract/extract.plugin.zsh b/plugins/extract/extract.plugin.zsh index 80ca50c50..1c7599195 100644 --- a/plugins/extract/extract.plugin.zsh +++ b/plugins/extract/extract.plugin.zsh @@ -87,7 +87,7 @@ EOF builtin cd -q control; extract ../control.tar.* builtin cd -q ../data; extract ../data.tar.* builtin cd -q ..; command rm *.tar.* debian-binary ;; - (*.zst) unzstd "$full_path" ;; + (*.zst) unzstd --stdout "$full_path" > "${file:t:r}" ;; (*.cab|*.exe) cabextract "$full_path" ;; (*.cpio|*.obscpio) cpio -idmvF "$full_path" ;; (*.zpaq) zpaq x "$full_path" ;; From 22bbc233e90f18ad7a02625c66d1867a5486fcbb Mon Sep 17 00:00:00 2001 From: Michael Gonzo Date: Tue, 7 May 2024 21:30:23 +0200 Subject: [PATCH 50/79] feat(python): autovenv keeps activated on subdirs (#12396) Co-authored-by: Carlo Sala --- plugins/python/README.md | 7 ++++--- plugins/python/python.plugin.zsh | 19 ++++++++++++++----- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/plugins/python/README.md b/plugins/python/README.md index c99697b22..b990a26b9 100644 --- a/plugins/python/README.md +++ b/plugins/python/README.md @@ -32,8 +32,9 @@ virtual environments: `venv`) in the current directory. - `auto_vrun`: Automatically activate the venv virtual environment when entering a directory containing - `/bin/activate`, and automatically deactivate it when navigating out of it (including - subdirectories!). + `/bin/activate`, and automatically deactivate it when navigating out of it (keeps venv activated + in subdirectories). - To enable the feature, set `export PYTHON_AUTO_VRUN=true` before sourcing oh-my-zsh. - - The default virtual environment name is `venv`. To use a different name, set + - Plugin activates first virtual environment in lexicographic order whose name begins with ``. + The default virtual environment name is `venv`. To use a different name, set `export PYTHON_VENV_NAME=`. For example: `export PYTHON_VENV_NAME=".venv"` diff --git a/plugins/python/python.plugin.zsh b/plugins/python/python.plugin.zsh index f6ea85027..7256aa04f 100644 --- a/plugins/python/python.plugin.zsh +++ b/plugins/python/python.plugin.zsh @@ -86,11 +86,20 @@ function mkv() { if [[ "$PYTHON_AUTO_VRUN" == "true" ]]; then # Automatically activate venv when changing dir - auto_vrun() { - if [[ -f "${PYTHON_VENV_NAME}/bin/activate" ]]; then - source "${PYTHON_VENV_NAME}/bin/activate" > /dev/null 2>&1 - else - (( $+functions[deactivate] )) && deactivate > /dev/null 2>&1 + function auto_vrun() { + # deactivate if we're on a different dir than VIRTUAL_ENV states + # we don't deactivate subdirectories! + if (( $+functions[deactivate] )) && [[ $PWD != ${VIRTUAL_ENV:h}* ]]; then + deactivate > /dev/null 2>&1 + fi + + if [[ $PWD != ${VIRTUAL_ENV:h} ]]; then + for _file in "${PYTHON_VENV_NAME}"*/bin/activate(N.); do + # make sure we're not in a venv already + (( $+functions[deactivate] )) && deactivate > /dev/null 2>&1 + source $_file > /dev/null 2>&1 + break + done fi } add-zsh-hook chpwd auto_vrun From 8c5f64cc2f0e75399a1e906e39713ed25b65ece1 Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Mon, 6 May 2024 09:49:21 +0200 Subject: [PATCH 51/79] feat(nvm): add `corepack` to `lazy_cmd` --- plugins/nvm/README.md | 6 +++--- plugins/nvm/nvm.plugin.zsh | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/nvm/README.md b/plugins/nvm/README.md index e88ce0158..eb1e236ee 100644 --- a/plugins/nvm/README.md +++ b/plugins/nvm/README.md @@ -26,9 +26,9 @@ These settings should go in your zshrc file, before Oh My Zsh is sourced: #### Lazy startup This option will help you to defer nvm's load until you use it to speed-up your zsh startup. This will source -nvm script only when using it, and will create a function for `node`, `npm`, `npx`, `pnpm`, `yarn`, and the -command(s) specified by `lazy-cmd` option, so when you call either of them, nvm will be loaded and run with -default version. To enable it, you can add this snippet to your zshrc, before Oh My Zsh is sourced: +nvm script only when using it, and will create a function for `node`, `npm`, `npx`, `pnpm`, `yarn`, `corepack` +and the command(s) specified by `lazy-cmd` option, so when you call either of them, nvm will be loaded and run +with default version. To enable it, you can add this snippet to your zshrc, before Oh My Zsh is sourced: ```zsh zstyle ':omz:plugins:nvm' lazy yes diff --git a/plugins/nvm/nvm.plugin.zsh b/plugins/nvm/nvm.plugin.zsh index c2e8de94b..95c94030a 100644 --- a/plugins/nvm/nvm.plugin.zsh +++ b/plugins/nvm/nvm.plugin.zsh @@ -72,9 +72,9 @@ function _omz_setup_autoload { } if zstyle -t ':omz:plugins:nvm' lazy; then - # Call nvm when first using nvm, node, npm, pnpm, yarn or other commands in lazy-cmd + # Call nvm when first using nvm, node, npm, pnpm, yarn, corepack or other commands in lazy-cmd zstyle -a ':omz:plugins:nvm' lazy-cmd nvm_lazy_cmd - nvm_lazy_cmd=(nvm node npm npx pnpm yarn $nvm_lazy_cmd) # default values + nvm_lazy_cmd=(nvm node npm npx pnpm yarn corepack $nvm_lazy_cmd) # default values eval " function $nvm_lazy_cmd { for func in $nvm_lazy_cmd; do From b0561d28b5a3efbbcca4700626fa32e62c23959b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Wed, 8 May 2024 22:20:42 +0200 Subject: [PATCH 52/79] fix(cli): fix edge cases in `omz plugin disable` command (#12401) Also introduces tests, which will be refactored into the proper place when a test system is finally designed. Fixes #12400 --- lib/cli.zsh | 14 +++- lib/tests/cli.test.zsh | 169 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 180 insertions(+), 3 deletions(-) create mode 100644 lib/tests/cli.test.zsh diff --git a/lib/cli.zsh b/lib/cli.zsh index 4a8d4d127..383b0cfb0 100644 --- a/lib/cli.zsh +++ b/lib/cli.zsh @@ -241,10 +241,18 @@ function _omz::plugin::disable { # Remove plugins substitution awk script local awk_subst_plugins="\ - gsub(/[ \t]+(${(j:|:)dis_plugins})/, \"\") # with spaces before - gsub(/(${(j:|:)dis_plugins})[ \t]+/, \"\") # with spaces after - gsub(/\((${(j:|:)dis_plugins})\)/, \"\") # without spaces (only plugin) + gsub(/[ \t]+(${(j:|:)dis_plugins})[ \t]+/, \" \") # with spaces before or after + gsub(/[ \t]+(${(j:|:)dis_plugins})$/, \"\") # with spaces before and EOL + gsub(/^(${(j:|:)dis_plugins})[ \t]+/, \"\") # with BOL and spaces after + + gsub(/\((${(j:|:)dis_plugins})[ \t]+/, \"(\") # with parenthesis before and spaces after + gsub(/[ \t]+(${(j:|:)dis_plugins})\)/, \")\") # with spaces before or parenthesis after + gsub(/\((${(j:|:)dis_plugins})\)/, \"()\") # with only parentheses + + gsub(/^(${(j:|:)dis_plugins})\)/, \")\") # with BOL and closing parenthesis + gsub(/\((${(j:|:)dis_plugins})$/, \"(\") # with opening parenthesis and EOL " + # Disable plugins awk script local awk_script=" # if plugins=() is in oneline form, substitute disabled plugins and go to next line diff --git a/lib/tests/cli.test.zsh b/lib/tests/cli.test.zsh new file mode 100644 index 000000000..9ee5cd219 --- /dev/null +++ b/lib/tests/cli.test.zsh @@ -0,0 +1,169 @@ +#!/usr/bin/zsh -df + +run_awk() { + local -a dis_plugins=(${=1}) + local input_text="$2" + + (( ! DEBUG )) || set -xv + + local awk_subst_plugins="\ + gsub(/[ \t]+(${(j:|:)dis_plugins})[ \t]+/, \" \") # with spaces before or after + gsub(/[ \t]+(${(j:|:)dis_plugins})$/, \"\") # with spaces before and EOL + gsub(/^(${(j:|:)dis_plugins})[ \t]+/, \"\") # with BOL and spaces after + + gsub(/\((${(j:|:)dis_plugins})[ \t]+/, \"(\") # with parenthesis before and spaces after + gsub(/[ \t]+(${(j:|:)dis_plugins})\)/, \")\") # with spaces before or parenthesis after + gsub(/\((${(j:|:)dis_plugins})\)/, \"()\") # with only parentheses + + gsub(/^(${(j:|:)dis_plugins})\)/, \")\") # with BOL and closing parenthesis + gsub(/\((${(j:|:)dis_plugins})$/, \"(\") # with opening parenthesis and EOL + " + # Disable plugins awk script + local awk_script=" + # if plugins=() is in oneline form, substitute disabled plugins and go to next line + /^[ \t]*plugins=\([^#]+\).*\$/ { + $awk_subst_plugins + print \$0 + next + } + + # if plugins=() is in multiline form, enable multi flag and disable plugins if they're there + /^[ \t]*plugins=\(/ { + multi=1 + $awk_subst_plugins + print \$0 + next + } + + # if multi flag is enabled and we find a valid closing parenthesis, remove plugins and disable multi flag + multi == 1 && /^[^#]*\)/ { + multi=0 + $awk_subst_plugins + print \$0 + next + } + + multi == 1 && length(\$0) > 0 { + $awk_subst_plugins + if (length(\$0) > 0) print \$0 + next + } + + { print \$0 } + " + + command awk "$awk_script" <<< "$input_text" + + (( ! DEBUG )) || set +xv +} + +# runs awk against stdin, checks if the resulting file is not empty and then checks if the file has valid zsh syntax +run_awk_and_test() { + local description="$1" + local plugins_to_disable="$2" + local input_text="$3" + local expected_output="$4" + + local tmpfile==(:) + + { + print -u2 "Test: $description" + DEBUG=0 run_awk "$plugins_to_disable" "$input_text" >| $tmpfile + + if [[ ! -s "$tmpfile" ]]; then + print -u2 "\e[31mError\e[0m: output file empty" + return 1 + fi + + if ! zsh -n $tmpfile; then + print -u2 "\e[31mError\e[0m: zsh syntax error" + diff -u $tmpfile <(echo "$expected_output") + return 1 + fi + + if ! diff -u --color=always $tmpfile <(echo "$expected_output"); then + if (( DEBUG )); then + print -u2 "" + DEBUG=1 run_awk "$plugins_to_disable" "$input_text" + print -u2 "" + fi + print -u2 "\e[31mError\e[0m: output file does not match expected output" + return 1 + fi + + print -u2 "\e[32mSuccess\e[0m" + } always { + print -u2 "" + command rm -f "$tmpfile" + } +} + +# These tests are for the `omz plugin disable` command +run_awk_and_test \ + "it should delete a single plugin in oneline format" \ + "git" \ + "plugins=(git)" \ + "plugins=()" + +run_awk_and_test \ + "it should delete a single plugin in multiline format" \ + "github" \ +"plugins=( + github +)" \ +"plugins=( +)" + +run_awk_and_test \ + "it should delete multiple plugins in oneline format" \ + "github git z" \ + "plugins=(github git z)" \ + "plugins=()" + +run_awk_and_test \ + "it should delete multiple plugins in multiline format" \ + "github git z" \ +"plugins=( + github + git + z +)" \ +"plugins=( +)" + +run_awk_and_test \ + "it should delete a single plugin among multiple in oneline format" \ + "git" \ + "plugins=(github git z)" \ + "plugins=(github z)" + +run_awk_and_test \ + "it should delete a single plugin among multiple in multiline format" \ + "git" \ +"plugins=( + github + git + z +)" \ +"plugins=( + github + z +)" + +run_awk_and_test \ + "it should delete multiple plugins in mixed format" \ + "git z" \ +"plugins=(github +git z)" \ +"plugins=(github +)" + +run_awk_and_test \ + "it should delete multiple plugins in mixed format 2" \ + "github z" \ +"plugins=(github + git +z)" \ +"plugins=( + git +)" From 5947c3c3c91d04fa0bff45866938027b85b56c6e Mon Sep 17 00:00:00 2001 From: Atk Date: Thu, 9 May 2024 15:57:30 +0100 Subject: [PATCH 53/79] feat(dependencies): add `wd` (#12405) Co-authored-by: Carlo Sala --- .github/dependencies.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/dependencies.yml b/.github/dependencies.yml index f760ddcef..a105f440d 100644 --- a/.github/dependencies.yml +++ b/.github/dependencies.yml @@ -36,3 +36,11 @@ dependencies: precopy: | set -e find . ! -name _gradle ! -name LICENSE -delete + plugins/wd: + repo: mfaerevaag/wd + branch: master + version: tag:v0.6.0 + precopy: | + set -e + rm -r test + rm install.sh tty.gif wd.1 From b1af78d64d81ade60d74f301c877d6a6394a12ab Mon Sep 17 00:00:00 2001 From: Kiran Koirala Date: Fri, 10 May 2024 13:12:47 +0545 Subject: [PATCH 54/79] fix(nvm): use `nvm version` when needed (#12409) --- plugins/nvm/nvm.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/nvm/nvm.plugin.zsh b/plugins/nvm/nvm.plugin.zsh index 95c94030a..8ca82fe83 100644 --- a/plugins/nvm/nvm.plugin.zsh +++ b/plugins/nvm/nvm.plugin.zsh @@ -54,7 +54,7 @@ function _omz_setup_autoload { if [[ "$nvmrc_node_version" = "N/A" ]]; then nvm install - elif [[ "$nvmrc_node_version" != "$node_version" ]]; then + elif [[ "$nvmrc_node_version" != "$(nvm version)" ]]; then nvm use $nvm_silent fi elif [[ -n "$(PWD=$OLDPWD nvm_find_nvmrc)" ]] && [[ "$(nvm version)" != "$(nvm version default)" ]]; then From 9af7ebcf36c20e1490a50fa5bab6319275859c17 Mon Sep 17 00:00:00 2001 From: Kiran Koirala Date: Fri, 10 May 2024 15:53:35 +0545 Subject: [PATCH 55/79] fix(nvm): use `command cat` to avoid alias (#12410) --- plugins/nvm/nvm.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/nvm/nvm.plugin.zsh b/plugins/nvm/nvm.plugin.zsh index 8ca82fe83..f36182eda 100644 --- a/plugins/nvm/nvm.plugin.zsh +++ b/plugins/nvm/nvm.plugin.zsh @@ -50,7 +50,7 @@ function _omz_setup_autoload { zstyle -t ':omz:plugins:nvm' silent-autoload && nvm_silent="--silent" if [[ -n "$nvmrc_path" ]]; then - local nvmrc_node_version=$(nvm version $(cat "$nvmrc_path" | tr -dc '[:print:]')) + local nvmrc_node_version=$(nvm version $(command cat "$nvmrc_path" | tr -dc '[:print:]')) if [[ "$nvmrc_node_version" = "N/A" ]]; then nvm install From d2cf10c29f2ebcbdbcc70ed3569aa3333d70d00d Mon Sep 17 00:00:00 2001 From: Ilya <68309482+Str1kez@users.noreply.github.com> Date: Fri, 10 May 2024 20:16:45 +0300 Subject: [PATCH 56/79] feat(procs): add completions plugin (#12406) --- plugins/procs/README.md | 9 +++++++++ plugins/procs/procs.plugin.zsh | 13 +++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 plugins/procs/README.md create mode 100644 plugins/procs/procs.plugin.zsh diff --git a/plugins/procs/README.md b/plugins/procs/README.md new file mode 100644 index 000000000..f1e663d9b --- /dev/null +++ b/plugins/procs/README.md @@ -0,0 +1,9 @@ +# procs + +This plugin provides completion for [procs](https://github.com/dalance/procs). + +To use it, add `procs` to the plugins array in your zshrc file. + +``` +plugins=(... procs) +``` diff --git a/plugins/procs/procs.plugin.zsh b/plugins/procs/procs.plugin.zsh new file mode 100644 index 000000000..332985bf9 --- /dev/null +++ b/plugins/procs/procs.plugin.zsh @@ -0,0 +1,13 @@ +if (( ! $+commands[procs] )); then + return +fi + +# If the completion file doesn't exist yet, we need to autoload it and +# bind it to `minikube`. Otherwise, compinit will have already done that. +if [[ ! -f "$ZSH_CACHE_DIR/completions/_procs" ]]; then + typeset -g -A _comps + autoload -Uz _procs + _comps[procs]=_procs +fi + +procs --gen-completion-out zsh >| "$ZSH_CACHE_DIR/completions/_procs" &| From 0fabd5f22f4e0378b09c92607789fdb17cab3c20 Mon Sep 17 00:00:00 2001 From: Francesco Ilario Date: Fri, 10 May 2024 19:17:18 +0200 Subject: [PATCH 57/79] fix(git): add checked-out branch support to `gbg*` (#12397) --- plugins/git/README.md | 4 ++-- plugins/git/git.plugin.zsh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/git/README.md b/plugins/git/README.md index 4c005ad2f..4022f8c62 100644 --- a/plugins/git/README.md +++ b/plugins/git/README.md @@ -41,8 +41,8 @@ plugins=(... git) | `gba` | `git branch --all` | | `gbd` | `git branch --delete` | | `gbD` | `git branch --delete --force` | -| `gbgd` | `LANG=C git branch --no-color -vv \| grep ": gone\]" \| awk '"'"'{print $1}'"'"' \| xargs git branch -d` | -| `gbgD` | `LANG=C git branch --no-color -vv \| grep ": gone\]" \| awk '"'"'{print $1}'"'"' \| xargs git branch -D` | +| `gbgd` | `LANG=C git branch --no-color -vv \| grep ": gone\]" \| cut -c 3- \| awk '"'"'{print $1}'"'"' \| xargs git branch -d` | +| `gbgD` | `LANG=C git branch --no-color -vv \| grep ": gone\]" \| cut -c 3- \| awk '"'"'{print $1}'"'"' \| xargs git branch -D` | | `gbm` | `git branch --move` | | `gbnm` | `git branch --no-merged` | | `gbr` | `git branch --remote` | diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 146f4a512..c48e365b5 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -147,8 +147,8 @@ function gbds() { done } -alias gbgd='LANG=C git branch --no-color -vv | grep ": gone\]" | awk '"'"'{print $1}'"'"' | xargs git branch -d' -alias gbgD='LANG=C git branch --no-color -vv | grep ": gone\]" | awk '"'"'{print $1}'"'"' | xargs git branch -D' +alias gbgd='LANG=C git branch --no-color -vv | grep ": gone\]" | cut -c 3- | awk '"'"'{print $1}'"'"' | xargs git branch -d' +alias gbgD='LANG=C git branch --no-color -vv | grep ": gone\]" | cut -c 3- | awk '"'"'{print $1}'"'"' | xargs git branch -D' alias gbm='git branch --move' alias gbnm='git branch --no-merged' alias gbr='git branch --remote' From d91f4e83efc5759a3347a2e1ae919ce0a6dda07f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Sun, 12 May 2024 09:44:11 +0200 Subject: [PATCH 58/79] fix(fzf): fix missing `is-at-least` error in setup (#12412) Fixes #12412 --- plugins/fzf/fzf.plugin.zsh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/fzf/fzf.plugin.zsh b/plugins/fzf/fzf.plugin.zsh index 3d29f1762..48fea4f63 100644 --- a/plugins/fzf/fzf.plugin.zsh +++ b/plugins/fzf/fzf.plugin.zsh @@ -4,6 +4,8 @@ function fzf_setup_using_fzf() { # we remove "fzf " prefix, this fixes really old fzf versions behaviour # see https://github.com/ohmyzsh/ohmyzsh/issues/12387 local fzf_ver=${"$(fzf --version)"#fzf } + + autoload -Uz is-at-least is-at-least 0.48.0 ${${(s: :)fzf_ver}[1]} || return 1 eval "$(fzf --zsh)" From 83110e8ce16cd3c6bd85e7f96a920d114f598df1 Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Thu, 9 May 2024 17:19:43 +0200 Subject: [PATCH 59/79] chore(dependencies): update requirements.txt --- .github/workflows/dependencies/requirements.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dependencies/requirements.txt b/.github/workflows/dependencies/requirements.txt index 3c4c149ea..0ef3e54ca 100644 --- a/.github/workflows/dependencies/requirements.txt +++ b/.github/workflows/dependencies/requirements.txt @@ -1,2 +1,6 @@ -PyYAML~=6.0.1 -requests~=2.31.0 +certifi==2024.2.2 +charset-normalizer==3.3.2 +idna==3.7 +PyYAML==6.0.1 +requests==2.31.0 +urllib3==2.2.1 From 13c8a10e39d60c078193d403b253270cdc4abc80 Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Thu, 9 May 2024 17:20:09 +0200 Subject: [PATCH 60/79] style(dependencies): run `ruff` formatter --- .editorconfig | 3 + .github/workflows/dependencies/updater.py | 704 ++++++++++++---------- 2 files changed, 378 insertions(+), 329 deletions(-) diff --git a/.editorconfig b/.editorconfig index b5321de59..b349bcc42 100644 --- a/.editorconfig +++ b/.editorconfig @@ -6,3 +6,6 @@ insert_final_newline = true charset = utf-8 indent_size = 2 indent_style = space + +[*.py] +indent_size = 4 diff --git a/.github/workflows/dependencies/updater.py b/.github/workflows/dependencies/updater.py index f54d316f9..765cb26fe 100644 --- a/.github/workflows/dependencies/updater.py +++ b/.github/workflows/dependencies/updater.py @@ -1,12 +1,14 @@ import os +import shutil import subprocess import sys -import requests -import shutil -import yaml +import timeit from copy import deepcopy from typing import Optional, TypedDict +import requests +import yaml + # Get TMP_DIR variable from environment TMP_DIR = os.path.join(os.environ.get("TMP_DIR", "/tmp"), "ohmyzsh") # Relative path to dependencies.yml file @@ -14,28 +16,29 @@ DEPS_YAML_FILE = ".github/dependencies.yml" # Dry run flag DRY_RUN = os.environ.get("DRY_RUN", "0") == "1" -import timeit + class CodeTimer: - def __init__(self, name=None): - self.name = " '" + name + "'" if name else '' + def __init__(self, name=None): + self.name = " '" + name + "'" if name else "" - def __enter__(self): - self.start = timeit.default_timer() + def __enter__(self): + self.start = timeit.default_timer() - def __exit__(self, exc_type, exc_value, traceback): - self.took = (timeit.default_timer() - self.start) * 1000.0 - print('Code block' + self.name + ' took: ' + str(self.took) + ' ms') + def __exit__(self, exc_type, exc_value, traceback): + self.took = (timeit.default_timer() - self.start) * 1000.0 + print("Code block" + self.name + " took: " + str(self.took) + " ms") ### YAML representation def str_presenter(dumper, data): - """ - Configures yaml for dumping multiline strings - Ref: https://stackoverflow.com/a/33300001 - """ - if len(data.splitlines()) > 1: # check for multiline string - return dumper.represent_scalar('tag:yaml.org,2002:str', data, style='|') - return dumper.represent_scalar('tag:yaml.org,2002:str', data) + """ + Configures yaml for dumping multiline strings + Ref: https://stackoverflow.com/a/33300001 + """ + if len(data.splitlines()) > 1: # check for multiline string + return dumper.represent_scalar("tag:yaml.org,2002:str", data, style="|") + return dumper.represent_scalar("tag:yaml.org,2002:str", data) + yaml.add_representer(str, str_presenter) yaml.representer.SafeRepresenter.add_representer(str, str_presenter) @@ -43,408 +46,451 @@ yaml.representer.SafeRepresenter.add_representer(str, str_presenter) # Types class DependencyDict(TypedDict): - repo: str - branch: str - version: str - precopy: Optional[str] - postcopy: Optional[str] + repo: str + branch: str + version: str + precopy: Optional[str] + postcopy: Optional[str] + class DependencyYAML(TypedDict): - dependencies: dict[str, DependencyDict] + dependencies: dict[str, DependencyDict] + class UpdateStatus(TypedDict): - has_updates: bool - version: Optional[str] - compare_url: Optional[str] - head_ref: Optional[str] - head_url: Optional[str] + has_updates: bool + version: Optional[str] + compare_url: Optional[str] + head_ref: Optional[str] + head_url: Optional[str] class CommandRunner: - class Exception(Exception): - def __init__(self, message, returncode, stage, stdout, stderr): - super().__init__(message) - self.returncode = returncode - self.stage = stage - self.stdout = stdout - self.stderr = stderr + class Exception(Exception): + def __init__(self, message, returncode, stage, stdout, stderr): + super().__init__(message) + self.returncode = returncode + self.stage = stage + self.stdout = stdout + self.stderr = stderr - @staticmethod - def run_or_fail(command: list[str], stage: str, *args, **kwargs): - if DRY_RUN and command[0] == "gh": - command.insert(0, "echo") + @staticmethod + def run_or_fail(command: list[str], stage: str, *args, **kwargs): + if DRY_RUN and command[0] == "gh": + command.insert(0, "echo") - result = subprocess.run(command, *args, capture_output=True, **kwargs) + result = subprocess.run(command, *args, capture_output=True, **kwargs) - if result.returncode != 0: - raise CommandRunner.Exception( - f"{stage} command failed with exit code {result.returncode}", returncode=result.returncode, - stage=stage, - stdout=result.stdout.decode("utf-8"), - stderr=result.stderr.decode("utf-8") - ) + if result.returncode != 0: + raise CommandRunner.Exception( + f"{stage} command failed with exit code {result.returncode}", + returncode=result.returncode, + stage=stage, + stdout=result.stdout.decode("utf-8"), + stderr=result.stderr.decode("utf-8"), + ) - return result + return result class DependencyStore: - store: DependencyYAML = { - "dependencies": {} - } + store: DependencyYAML = {"dependencies": {}} - @staticmethod - def set(data: DependencyYAML): - DependencyStore.store = data + @staticmethod + def set(data: DependencyYAML): + DependencyStore.store = data - @staticmethod - def update_dependency_version(path: str, version: str) -> DependencyYAML: - with CodeTimer(f"store deepcopy: {path}"): - store_copy = deepcopy(DependencyStore.store) + @staticmethod + def update_dependency_version(path: str, version: str) -> DependencyYAML: + with CodeTimer(f"store deepcopy: {path}"): + store_copy = deepcopy(DependencyStore.store) - dependency = store_copy["dependencies"].get(path, {}) - dependency["version"] = version - store_copy["dependencies"][path] = dependency + dependency = store_copy["dependencies"].get(path, {}) + dependency["version"] = version + store_copy["dependencies"][path] = dependency - return store_copy + return store_copy - @staticmethod - def write_store(file: str, data: DependencyYAML): - with open(file, "w") as yaml_file: - yaml.safe_dump(data, yaml_file, sort_keys=False) + @staticmethod + def write_store(file: str, data: DependencyYAML): + with open(file, "w") as yaml_file: + yaml.safe_dump(data, yaml_file, sort_keys=False) class Dependency: - def __init__(self, path: str, values: DependencyDict): - self.path = path - self.values = values + def __init__(self, path: str, values: DependencyDict): + self.path = path + self.values = values - self.name: str = "" - self.desc: str = "" - self.kind: str = "" + self.name: str = "" + self.desc: str = "" + self.kind: str = "" - match path.split("/"): - case ["plugins", name]: - self.name = name - self.kind = "plugin" - self.desc = f"{name} plugin" - case ["themes", name]: - self.name = name.replace(".zsh-theme", "") - self.kind = "theme" - self.desc = f"{self.name} theme" - case _: - self.name = self.desc = path + match path.split("/"): + case ["plugins", name]: + self.name = name + self.kind = "plugin" + self.desc = f"{name} plugin" + case ["themes", name]: + self.name = name.replace(".zsh-theme", "") + self.kind = "theme" + self.desc = f"{self.name} theme" + case _: + self.name = self.desc = path - def __str__(self): - output: str = "" - for key in DependencyDict.__dict__['__annotations__'].keys(): - if key not in self.values: - output += f"{key}: None\n" - continue + def __str__(self): + output: str = "" + for key in DependencyDict.__dict__["__annotations__"].keys(): + if key not in self.values: + output += f"{key}: None\n" + continue - value = self.values[key] - if "\n" not in value: - output += f"{key}: {value}\n" - else: - output += f"{key}:\n " - output += value.replace("\n", "\n ", value.count("\n") - 1) - return output + value = self.values[key] + if "\n" not in value: + output += f"{key}: {value}\n" + else: + output += f"{key}:\n " + output += value.replace("\n", "\n ", value.count("\n") - 1) + return output - def update_or_notify(self): - # Print dependency settings - print(f"Processing {self.desc}...", file=sys.stderr) - print(self, file=sys.stderr) + def update_or_notify(self): + # Print dependency settings + print(f"Processing {self.desc}...", file=sys.stderr) + print(self, file=sys.stderr) - # Check for updates - repo = self.values["repo"] - remote_branch = self.values["branch"] - version = self.values["version"] - is_tag = version.startswith("tag:") - - try: - with CodeTimer(f"update check: {repo}"): - if is_tag: - status = GitHub.check_newer_tag(repo, version.replace("tag:", "")) - else: - status = GitHub.check_updates(repo, remote_branch, version) - - if status["has_updates"]: - short_sha = status["head_ref"][:8] - new_version = status["version"] if is_tag else short_sha + # Check for updates + repo = self.values["repo"] + remote_branch = self.values["branch"] + version = self.values["version"] + is_tag = version.startswith("tag:") try: - # Create new branch - branch = Git.create_branch(self.path, new_version) + with CodeTimer(f"update check: {repo}"): + if is_tag: + status = GitHub.check_newer_tag(repo, version.replace("tag:", "")) + else: + status = GitHub.check_updates(repo, remote_branch, version) - # Update dependencies.yml file - self.__update_yaml(f"tag:{new_version}" if is_tag else status["version"]) + if status["has_updates"]: + short_sha = status["head_ref"][:8] + new_version = status["version"] if is_tag else short_sha - # Update dependency files - self.__apply_upstream_changes() + try: + # Create new branch + branch = Git.create_branch(self.path, new_version) - # Add all changes and commit - Git.add_and_commit(self.name, short_sha) + # Update dependencies.yml file + self.__update_yaml( + f"tag:{new_version}" if is_tag else status["version"] + ) - # Push changes to remote - Git.push(branch) + # Update dependency files + self.__apply_upstream_changes() - # Create GitHub PR - GitHub.create_pr( - branch, - f"feat({self.name}): update to version {new_version}", - f"""## Description + # Add all changes and commit + Git.add_and_commit(self.name, short_sha) + + # Push changes to remote + Git.push(branch) + + # Create GitHub PR + GitHub.create_pr( + branch, + f"feat({self.name}): update to version {new_version}", + f"""## Description Update for **{self.desc}**: update to version [{new_version}]({status['head_url']}). Check out the [list of changes]({status['compare_url']}). -""" - ) +""", + ) - # Clean up repository - Git.clean_repo() - except (CommandRunner.Exception, shutil.Error) as e: - # Handle exception on automatic update - match type(e): - case CommandRunner.Exception: - # Print error message - print(f"Error running {e.stage} command: {e.returncode}", file=sys.stderr) - print(e.stderr, file=sys.stderr) - case shutil.Error: - print(f"Error copying files: {e}", file=sys.stderr) + # Clean up repository + Git.clean_repo() + except (CommandRunner.Exception, shutil.Error) as e: + # Handle exception on automatic update + match type(e): + case CommandRunner.Exception: + # Print error message + print( + f"Error running {e.stage} command: {e.returncode}", + file=sys.stderr, + ) + print(e.stderr, file=sys.stderr) + case shutil.Error: + print(f"Error copying files: {e}", file=sys.stderr) - try: - Git.clean_repo() - except CommandRunner.Exception as e: - print(f"Error reverting repository to clean state: {e}", file=sys.stderr) - sys.exit(1) + try: + Git.clean_repo() + except CommandRunner.Exception as e: + print( + f"Error reverting repository to clean state: {e}", + file=sys.stderr, + ) + sys.exit(1) - # Create a GitHub issue to notify maintainer - title = f"{self.path}: update to {new_version}" - body = ( - f"""## Description + # Create a GitHub issue to notify maintainer + title = f"{self.path}: update to {new_version}" + body = f"""## Description There is a new version of `{self.name}` {self.kind} available. New version: [{new_version}]({status['head_url']}) Check out the [list of changes]({status['compare_url']}). """ - ) - print(f"Creating GitHub issue", file=sys.stderr) - print(f"{title}\n\n{body}", file=sys.stderr) - GitHub.create_issue(title, body) - except Exception as e: - print(e, file=sys.stderr) + print("Creating GitHub issue", file=sys.stderr) + print(f"{title}\n\n{body}", file=sys.stderr) + GitHub.create_issue(title, body) + except Exception as e: + print(e, file=sys.stderr) - def __update_yaml(self, new_version: str) -> None: - dep_yaml = DependencyStore.update_dependency_version(self.path, new_version) - DependencyStore.write_store(DEPS_YAML_FILE, dep_yaml) + def __update_yaml(self, new_version: str) -> None: + dep_yaml = DependencyStore.update_dependency_version(self.path, new_version) + DependencyStore.write_store(DEPS_YAML_FILE, dep_yaml) - def __apply_upstream_changes(self) -> None: - # Patterns to ignore in copying files from upstream repo - GLOBAL_IGNORE = [ - ".git", - ".github", - ".gitignore" - ] + def __apply_upstream_changes(self) -> None: + # Patterns to ignore in copying files from upstream repo + GLOBAL_IGNORE = [".git", ".github", ".gitignore"] - path = os.path.abspath(self.path) - precopy = self.values.get("precopy") - postcopy = self.values.get("postcopy") + path = os.path.abspath(self.path) + precopy = self.values.get("precopy") + postcopy = self.values.get("postcopy") - repo = self.values["repo"] - branch = self.values["branch"] - remote_url = f"https://github.com/{repo}.git" - repo_dir = os.path.join(TMP_DIR, repo) + repo = self.values["repo"] + branch = self.values["branch"] + remote_url = f"https://github.com/{repo}.git" + repo_dir = os.path.join(TMP_DIR, repo) - # Clone repository - Git.clone(remote_url, branch, repo_dir, reclone=True) + # Clone repository + Git.clone(remote_url, branch, repo_dir, reclone=True) - # Run precopy on tmp repo - if precopy is not None: - print("Running precopy script:", end="\n ", file=sys.stderr) - print(precopy.replace("\n", "\n ", precopy.count("\n") - 1), file=sys.stderr) - CommandRunner.run_or_fail(["bash", "-c", precopy], cwd=repo_dir, stage="Precopy") + # Run precopy on tmp repo + if precopy is not None: + print("Running precopy script:", end="\n ", file=sys.stderr) + print( + precopy.replace("\n", "\n ", precopy.count("\n") - 1), file=sys.stderr + ) + CommandRunner.run_or_fail( + ["bash", "-c", precopy], cwd=repo_dir, stage="Precopy" + ) - # Copy files from upstream repo - print(f"Copying files from {repo_dir} to {path}", file=sys.stderr) - shutil.copytree(repo_dir, path, dirs_exist_ok=True, ignore=shutil.ignore_patterns(*GLOBAL_IGNORE)) + # Copy files from upstream repo + print(f"Copying files from {repo_dir} to {path}", file=sys.stderr) + shutil.copytree( + repo_dir, + path, + dirs_exist_ok=True, + ignore=shutil.ignore_patterns(*GLOBAL_IGNORE), + ) - # Run postcopy on our repository - if postcopy is not None: - print("Running postcopy script:", end="\n ", file=sys.stderr) - print(postcopy.replace("\n", "\n ", postcopy.count("\n") - 1), file=sys.stderr) - CommandRunner.run_or_fail(["bash", "-c", postcopy], cwd=path, stage="Postcopy") + # Run postcopy on our repository + if postcopy is not None: + print("Running postcopy script:", end="\n ", file=sys.stderr) + print( + postcopy.replace("\n", "\n ", postcopy.count("\n") - 1), + file=sys.stderr, + ) + CommandRunner.run_or_fail( + ["bash", "-c", postcopy], cwd=path, stage="Postcopy" + ) class Git: - default_branch = "master" + default_branch = "master" - @staticmethod - def clone(remote_url: str, branch: str, repo_dir: str, reclone=False): - # If repo needs to be fresh - if reclone and os.path.exists(repo_dir): - shutil.rmtree(repo_dir) + @staticmethod + def clone(remote_url: str, branch: str, repo_dir: str, reclone=False): + # If repo needs to be fresh + if reclone and os.path.exists(repo_dir): + shutil.rmtree(repo_dir) - # Clone repo in tmp directory and checkout branch - if not os.path.exists(repo_dir): - print(f"Cloning {remote_url} to {repo_dir} and checking out {branch}", file=sys.stderr) - CommandRunner.run_or_fail(["git", "clone", "--depth=1", "-b", branch, remote_url, repo_dir], stage="Clone") + # Clone repo in tmp directory and checkout branch + if not os.path.exists(repo_dir): + print( + f"Cloning {remote_url} to {repo_dir} and checking out {branch}", + file=sys.stderr, + ) + CommandRunner.run_or_fail( + ["git", "clone", "--depth=1", "-b", branch, remote_url, repo_dir], + stage="Clone", + ) - @staticmethod - def create_branch(path: str, version: str): - # Get current branch name - result = CommandRunner.run_or_fail(["git", "rev-parse", "--abbrev-ref", "HEAD"], stage="GetDefaultBranch") - Git.default_branch = result.stdout.decode("utf-8").strip() + @staticmethod + def create_branch(path: str, version: str): + # Get current branch name + result = CommandRunner.run_or_fail( + ["git", "rev-parse", "--abbrev-ref", "HEAD"], stage="GetDefaultBranch" + ) + Git.default_branch = result.stdout.decode("utf-8").strip() - # Create new branch and return created branch name - branch_name = f"update/{path}/{version}" - CommandRunner.run_or_fail(["git", "checkout", "-b", branch_name], stage="CreateBranch") - return branch_name + # Create new branch and return created branch name + branch_name = f"update/{path}/{version}" + CommandRunner.run_or_fail( + ["git", "checkout", "-b", branch_name], stage="CreateBranch" + ) + return branch_name - @staticmethod - def add_and_commit(scope: str, version: str): - user_name = os.environ.get("GIT_APP_NAME") - user_email = os.environ.get("GIT_APP_EMAIL") + @staticmethod + def add_and_commit(scope: str, version: str): + user_name = os.environ.get("GIT_APP_NAME") + user_email = os.environ.get("GIT_APP_EMAIL") - # Add all files to git staging - CommandRunner.run_or_fail(["git", "add", "-A", "-v"], stage="AddFiles") + # Add all files to git staging + CommandRunner.run_or_fail(["git", "add", "-A", "-v"], stage="AddFiles") - # Reset environment and git config - clean_env = os.environ.copy() - clean_env["LANG"]="C.UTF-8" - clean_env["GIT_CONFIG_GLOBAL"]="/dev/null" - clean_env["GIT_CONFIG_NOSYSTEM"]="1" + # Reset environment and git config + clean_env = os.environ.copy() + clean_env["LANG"] = "C.UTF-8" + clean_env["GIT_CONFIG_GLOBAL"] = "/dev/null" + clean_env["GIT_CONFIG_NOSYSTEM"] = "1" - # Commit with settings above - CommandRunner.run_or_fail([ - "git", - "-c", f"user.name={user_name}", - "-c", f"user.email={user_email}", - "commit", - "-m", f"feat({scope}): update to {version}" - ], stage="CreateCommit", env=clean_env) + # Commit with settings above + CommandRunner.run_or_fail( + [ + "git", + "-c", + f"user.name={user_name}", + "-c", + f"user.email={user_email}", + "commit", + "-m", + f"feat({scope}): update to {version}", + ], + stage="CreateCommit", + env=clean_env, + ) - @staticmethod - def push(branch: str): - CommandRunner.run_or_fail(["git", "push", "-u", "origin", branch], stage="PushBranch") + @staticmethod + def push(branch: str): + CommandRunner.run_or_fail( + ["git", "push", "-u", "origin", branch], stage="PushBranch" + ) - @staticmethod - def clean_repo(): - CommandRunner.run_or_fail(["git", "reset", "--hard", "HEAD"], stage="ResetRepository") - CommandRunner.run_or_fail(["git", "checkout", Git.default_branch], stage="CheckoutDefaultBranch") + @staticmethod + def clean_repo(): + CommandRunner.run_or_fail( + ["git", "reset", "--hard", "HEAD"], stage="ResetRepository" + ) + CommandRunner.run_or_fail( + ["git", "checkout", Git.default_branch], stage="CheckoutDefaultBranch" + ) class GitHub: - @staticmethod - def check_newer_tag(repo, current_tag) -> UpdateStatus: - # GET /repos/:owner/:repo/git/refs/tags - url = f"https://api.github.com/repos/{repo}/git/refs/tags" + @staticmethod + def check_newer_tag(repo, current_tag) -> UpdateStatus: + # GET /repos/:owner/:repo/git/refs/tags + url = f"https://api.github.com/repos/{repo}/git/refs/tags" - # Send a GET request to the GitHub API - response = requests.get(url) + # Send a GET request to the GitHub API + response = requests.get(url) - # If the request was successful - if response.status_code == 200: - # Parse the JSON response - data = response.json() + # If the request was successful + if response.status_code == 200: + # Parse the JSON response + data = response.json() - if len(data) == 0: - return { - "has_updates": False, - } + if len(data) == 0: + return { + "has_updates": False, + } - latest_ref = data[-1] - latest_tag = latest_ref["ref"].replace("refs/tags/", "") + latest_ref = data[-1] + latest_tag = latest_ref["ref"].replace("refs/tags/", "") - if latest_tag == current_tag: - return { - "has_updates": False, - } + if latest_tag == current_tag: + return { + "has_updates": False, + } - return { - "has_updates": True, - "version": latest_tag, - "compare_url": f"https://github.com/{repo}/compare/{current_tag}...{latest_tag}", - "head_ref": latest_ref["object"]["sha"], - "head_url": f"https://github.com/{repo}/releases/tag/{latest_tag}", - } - else: - # If the request was not successful, raise an exception - raise Exception(f"GitHub API request failed with status code {response.status_code}: {response.json()}") + return { + "has_updates": True, + "version": latest_tag, + "compare_url": f"https://github.com/{repo}/compare/{current_tag}...{latest_tag}", + "head_ref": latest_ref["object"]["sha"], + "head_url": f"https://github.com/{repo}/releases/tag/{latest_tag}", + } + else: + # If the request was not successful, raise an exception + raise Exception( + f"GitHub API request failed with status code {response.status_code}: {response.json()}" + ) - @staticmethod - def check_updates(repo, branch, version) -> UpdateStatus: - # TODO: add support for semver updating (based on tags) - # Check if upstream github repo has a new version - # GitHub API URL for comparing two commits - url = f"https://api.github.com/repos/{repo}/compare/{version}...{branch}" + @staticmethod + def check_updates(repo, branch, version) -> UpdateStatus: + # TODO: add support for semver updating (based on tags) + # Check if upstream github repo has a new version + # GitHub API URL for comparing two commits + url = f"https://api.github.com/repos/{repo}/compare/{version}...{branch}" - # Send a GET request to the GitHub API - response = requests.get(url) + # Send a GET request to the GitHub API + response = requests.get(url) - # If the request was successful - if response.status_code == 200: - # Parse the JSON response - data = response.json() + # If the request was successful + if response.status_code == 200: + # Parse the JSON response + data = response.json() - # If the base is behind the head, there is a newer version - has_updates = data["status"] != "identical" + # If the base is behind the head, there is a newer version + has_updates = data["status"] != "identical" - if not has_updates: - return { - "has_updates": False, - } + if not has_updates: + return { + "has_updates": False, + } - return { - "has_updates": data["status"] != "identical", - "version": data["commits"][-1]["sha"], - "compare_url": data["permalink_url"], - "head_ref": data["commits"][-1]["sha"], - "head_url": data["commits"][-1]["html_url"] - } - else: - # If the request was not successful, raise an exception - raise Exception(f"GitHub API request failed with status code {response.status_code}: {response.json()}") + return { + "has_updates": data["status"] != "identical", + "version": data["commits"][-1]["sha"], + "compare_url": data["permalink_url"], + "head_ref": data["commits"][-1]["sha"], + "head_url": data["commits"][-1]["html_url"], + } + else: + # If the request was not successful, raise an exception + raise Exception( + f"GitHub API request failed with status code {response.status_code}: {response.json()}" + ) - @staticmethod - def create_issue(title: str, body: str) -> None: - cmd = [ - "gh", - "issue", - "create", - "-t", title, - "-b", body - ] - CommandRunner.run_or_fail(cmd, stage="CreateIssue") + @staticmethod + def create_issue(title: str, body: str) -> None: + cmd = ["gh", "issue", "create", "-t", title, "-b", body] + CommandRunner.run_or_fail(cmd, stage="CreateIssue") - @staticmethod - def create_pr(branch: str, title: str, body: str) -> None: - cmd = [ - "gh", - "pr", - "create", - "-B", Git.default_branch, - "-H", branch, - "-t", title, - "-b", body - ] - CommandRunner.run_or_fail(cmd, stage="CreatePullRequest") + @staticmethod + def create_pr(branch: str, title: str, body: str) -> None: + cmd = [ + "gh", + "pr", + "create", + "-B", + Git.default_branch, + "-H", + branch, + "-t", + title, + "-b", + body, + ] + CommandRunner.run_or_fail(cmd, stage="CreatePullRequest") def main(): - # Load the YAML file - with open(DEPS_YAML_FILE, "r") as yaml_file: - data: DependencyYAML = yaml.safe_load(yaml_file) + # Load the YAML file + with open(DEPS_YAML_FILE, "r") as yaml_file: + data: DependencyYAML = yaml.safe_load(yaml_file) - if "dependencies" not in data: - raise Exception(f"dependencies.yml not properly formatted") + if "dependencies" not in data: + raise Exception("dependencies.yml not properly formatted") - # Cache YAML version - DependencyStore.set(data) + # Cache YAML version + DependencyStore.set(data) + + dependencies = data["dependencies"] + for path in dependencies: + dependency = Dependency(path, dependencies[path]) + dependency.update_or_notify() - dependencies = data["dependencies"] - for path in dependencies: - dependency = Dependency(path, dependencies[path]) - dependency.update_or_notify() if __name__ == "__main__": - main() + main() From a258eb4547e610899162526f754ce1bf88027112 Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Thu, 9 May 2024 18:27:01 +0200 Subject: [PATCH 61/79] fix(dependencies): improve typing --- .github/workflows/dependencies/updater.py | 36 +++++++++++++---------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/.github/workflows/dependencies/updater.py b/.github/workflows/dependencies/updater.py index 765cb26fe..9754cdf83 100644 --- a/.github/workflows/dependencies/updater.py +++ b/.github/workflows/dependencies/updater.py @@ -4,7 +4,7 @@ import subprocess import sys import timeit from copy import deepcopy -from typing import Optional, TypedDict +from typing import Literal, NotRequired, TypedDict import requests import yaml @@ -49,20 +49,24 @@ class DependencyDict(TypedDict): repo: str branch: str version: str - precopy: Optional[str] - postcopy: Optional[str] + precopy: NotRequired[str] + postcopy: NotRequired[str] class DependencyYAML(TypedDict): dependencies: dict[str, DependencyDict] -class UpdateStatus(TypedDict): - has_updates: bool - version: Optional[str] - compare_url: Optional[str] - head_ref: Optional[str] - head_url: Optional[str] +class UpdateStatusFalse(TypedDict): + has_updates: Literal[False] + + +class UpdateStatusTrue(TypedDict): + has_updates: Literal[True] + version: str + compare_url: str + head_ref: str + head_url: str class CommandRunner: @@ -105,7 +109,9 @@ class DependencyStore: with CodeTimer(f"store deepcopy: {path}"): store_copy = deepcopy(DependencyStore.store) - dependency = store_copy["dependencies"].get(path, {}) + dependency = store_copy["dependencies"].get(path) + if dependency is None: + raise ValueError(f"Dependency {path} {version} not found") dependency["version"] = version store_copy["dependencies"][path] = dependency @@ -171,7 +177,7 @@ class Dependency: else: status = GitHub.check_updates(repo, remote_branch, version) - if status["has_updates"]: + if status["has_updates"] is True: short_sha = status["head_ref"][:8] new_version = status["version"] if is_tag else short_sha @@ -212,10 +218,10 @@ Check out the [list of changes]({status['compare_url']}). case CommandRunner.Exception: # Print error message print( - f"Error running {e.stage} command: {e.returncode}", + f"Error running {e.stage} command: {e.returncode}", # pyright: ignore[reportAttributeAccessIssue] file=sys.stderr, ) - print(e.stderr, file=sys.stderr) + print(e.stderr, file=sys.stderr) # pyright: ignore[reportAttributeAccessIssue] case shutil.Error: print(f"Error copying files: {e}", file=sys.stderr) @@ -378,7 +384,7 @@ class Git: class GitHub: @staticmethod - def check_newer_tag(repo, current_tag) -> UpdateStatus: + def check_newer_tag(repo, current_tag) -> UpdateStatusFalse | UpdateStatusTrue: # GET /repos/:owner/:repo/git/refs/tags url = f"https://api.github.com/repos/{repo}/git/refs/tags" @@ -417,7 +423,7 @@ class GitHub: ) @staticmethod - def check_updates(repo, branch, version) -> UpdateStatus: + def check_updates(repo, branch, version) -> UpdateStatusFalse | UpdateStatusTrue: # TODO: add support for semver updating (based on tags) # Check if upstream github repo has a new version # GitHub API URL for comparing two commits From 423b9a8ded10b0d4a81d6134c4045d0b7e077eb5 Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Thu, 9 May 2024 19:20:11 +0200 Subject: [PATCH 62/79] feat(dependencies): add support for semver tags --- .../workflows/dependencies/requirements.txt | 1 + .github/workflows/dependencies/updater.py | 62 +++++++++++++++++-- 2 files changed, 57 insertions(+), 6 deletions(-) diff --git a/.github/workflows/dependencies/requirements.txt b/.github/workflows/dependencies/requirements.txt index 0ef3e54ca..7e840a74c 100644 --- a/.github/workflows/dependencies/requirements.txt +++ b/.github/workflows/dependencies/requirements.txt @@ -3,4 +3,5 @@ charset-normalizer==3.3.2 idna==3.7 PyYAML==6.0.1 requests==2.31.0 +semver==3.0.2 urllib3==2.2.1 diff --git a/.github/workflows/dependencies/updater.py b/.github/workflows/dependencies/updater.py index 9754cdf83..7e8e92ca9 100644 --- a/.github/workflows/dependencies/updater.py +++ b/.github/workflows/dependencies/updater.py @@ -1,13 +1,15 @@ import os +import re import shutil import subprocess import sys import timeit from copy import deepcopy -from typing import Literal, NotRequired, TypedDict +from typing import Literal, NotRequired, Optional, TypedDict import requests import yaml +from semver import Version # Get TMP_DIR variable from environment TMP_DIR = os.path.join(os.environ.get("TMP_DIR", "/tmp"), "ohmyzsh") @@ -16,6 +18,35 @@ DEPS_YAML_FILE = ".github/dependencies.yml" # Dry run flag DRY_RUN = os.environ.get("DRY_RUN", "0") == "1" +# utils for tag comparison +BASEVERSION = re.compile( + r"""[vV]? + (?P(0|[1-9])\d*) + (\. + (?P(0|[1-9])\d*) + (\. + (?P(0|[1-9])\d*) + )? + )? + """, + re.VERBOSE, +) + + +def coerce(version: str) -> Optional[Version]: + match = BASEVERSION.search(version) + if not match: + return None + + # BASEVERSION looks for `MAJOR.minor.patch` in the string given + # it fills with None if any of them is missing (for example `2.1`) + ver = { + key: 0 if value is None else value for key, value in match.groupdict().items() + } + # Version takes `major`, `minor`, `patch` arguments + ver = Version(**ver) # pyright: ignore[reportArgumentType] + return ver + class CodeTimer: def __init__(self, name=None): @@ -390,6 +421,11 @@ class GitHub: # Send a GET request to the GitHub API response = requests.get(url) + current_version = coerce(current_tag) + if current_version is None: + raise ValueError( + f"Stored {current_version} from {repo} does not follow semver" + ) # If the request was successful if response.status_code == 200: @@ -401,10 +437,27 @@ class GitHub: "has_updates": False, } - latest_ref = data[-1] + latest_ref = None + latest_version: Optional[Version] = None + for ref in data: + # we find the tag since GitHub returns it as plain git ref + tag_version = coerce(ref["ref"].replace("refs/tags/", "")) + if tag_version is None: + # we skip every tag that is not semver-complaint + continue + if latest_version is None or tag_version.compare(latest_version) > 0: + # if we have a "greater" semver version, set it as latest + latest_version = tag_version + latest_ref = ref + + # raise if no valid semver tag is found + if latest_ref is None or latest_version is None: + raise ValueError(f"No tags following semver found in {repo}") + + # we get the tag since GitHub returns it as plain git ref latest_tag = latest_ref["ref"].replace("refs/tags/", "") - if latest_tag == current_tag: + if latest_version.compare(current_version) <= 0: return { "has_updates": False, } @@ -424,9 +477,6 @@ class GitHub: @staticmethod def check_updates(repo, branch, version) -> UpdateStatusFalse | UpdateStatusTrue: - # TODO: add support for semver updating (based on tags) - # Check if upstream github repo has a new version - # GitHub API URL for comparing two commits url = f"https://api.github.com/repos/{repo}/compare/{version}...{branch}" # Send a GET request to the GitHub API From eb2ff84a2c8ae45b90d36e367c6bd6bc01f8464d Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Thu, 9 May 2024 19:52:50 +0200 Subject: [PATCH 63/79] fix(dependencies): avoid creating PR if it's already there --- .github/workflows/dependencies/updater.py | 42 +++++++++++++++++++---- 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/.github/workflows/dependencies/updater.py b/.github/workflows/dependencies/updater.py index 7e8e92ca9..6fa32e378 100644 --- a/.github/workflows/dependencies/updater.py +++ b/.github/workflows/dependencies/updater.py @@ -1,3 +1,4 @@ +import json import os import re import shutil @@ -213,8 +214,10 @@ class Dependency: new_version = status["version"] if is_tag else short_sha try: + branch_name = f"update/{self.path}/{new_version}" + # Create new branch - branch = Git.create_branch(self.path, new_version) + branch = Git.checkout_or_create_branch(branch_name) # Update dependencies.yml file self.__update_yaml( @@ -353,7 +356,7 @@ class Git: ) @staticmethod - def create_branch(path: str, version: str): + def checkout_or_create_branch(branch_name: str): # Get current branch name result = CommandRunner.run_or_fail( ["git", "rev-parse", "--abbrev-ref", "HEAD"], stage="GetDefaultBranch" @@ -361,10 +364,16 @@ class Git: Git.default_branch = result.stdout.decode("utf-8").strip() # Create new branch and return created branch name - branch_name = f"update/{path}/{version}" - CommandRunner.run_or_fail( - ["git", "checkout", "-b", branch_name], stage="CreateBranch" - ) + try: + # try to checkout already existing branch + CommandRunner.run_or_fail( + ["git", "checkout", branch_name], stage="CreateBranch" + ) + except CommandRunner.Exception: + # otherwise create new branch + CommandRunner.run_or_fail( + ["git", "checkout", "-b", branch_name], stage="CreateBranch" + ) return branch_name @staticmethod @@ -515,6 +524,27 @@ class GitHub: @staticmethod def create_pr(branch: str, title: str, body: str) -> None: + # first of all let's check if PR is already open + check_cmd = [ + "gh", + "pr", + "list", + "--state", + "open", + "--head", + branch, + "--json", + "title", + ] + # returncode is 0 also if no PRs are found + output = json.loads( + CommandRunner.run_or_fail(check_cmd, stage="CheckPullRequestOpen") + .stdout.decode("utf-8") + .strip() + ) + # we have PR in this case! + if len(output) > 0: + return cmd = [ "gh", "pr", From eff648aab021df0407dcd86126d2ab9db950d0f2 Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Thu, 9 May 2024 17:41:59 +0200 Subject: [PATCH 64/79] ci(dependencies): use `setup-python` and enable cron-based jobs --- .github/workflows/dependencies.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dependencies.yml b/.github/workflows/dependencies.yml index 2e2217e1c..fce666e4c 100644 --- a/.github/workflows/dependencies.yml +++ b/.github/workflows/dependencies.yml @@ -1,8 +1,8 @@ name: Update dependencies on: workflow_dispatch: {} - # schedule: - # - cron: '34 3 * * */8' + schedule: + - cron: '34 3 * * */8' jobs: check: @@ -18,6 +18,11 @@ jobs: with: app_id: ${{ secrets.OHMYZSH_APP_ID }} private_key: ${{ secrets.OHMYZSH_APP_PRIVATE_KEY }} + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" + cache: "pip" - name: Process dependencies env: GH_TOKEN: ${{ steps.generate_token.outputs.token }} From 1d31ff603706007e69aefe2c9ca198658e35b5dc Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Sun, 12 May 2024 12:30:22 +0200 Subject: [PATCH 65/79] ci(dependencies): fetch all branches --- .github/workflows/dependencies.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/dependencies.yml b/.github/workflows/dependencies.yml index fce666e4c..6bc8dc74d 100644 --- a/.github/workflows/dependencies.yml +++ b/.github/workflows/dependencies.yml @@ -2,7 +2,7 @@ name: Update dependencies on: workflow_dispatch: {} schedule: - - cron: '34 3 * * */8' + - cron: "34 3 * * */8" jobs: check: @@ -12,6 +12,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Authenticate as @ohmyzsh id: generate_token uses: ohmyzsh/github-app-token@v2 From 0493eab8ce02c4988a16cbe27ad61a20ed8a89df Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Sun, 12 May 2024 12:40:45 +0200 Subject: [PATCH 66/79] fix(dependencies): check if repo is clean before committing --- .github/workflows/dependencies/updater.py | 36 +++++++++++++---------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/.github/workflows/dependencies/updater.py b/.github/workflows/dependencies/updater.py index 6fa32e378..4533b7aeb 100644 --- a/.github/workflows/dependencies/updater.py +++ b/.github/workflows/dependencies/updater.py @@ -390,21 +390,27 @@ class Git: clean_env["GIT_CONFIG_GLOBAL"] = "/dev/null" clean_env["GIT_CONFIG_NOSYSTEM"] = "1" - # Commit with settings above - CommandRunner.run_or_fail( - [ - "git", - "-c", - f"user.name={user_name}", - "-c", - f"user.email={user_email}", - "commit", - "-m", - f"feat({scope}): update to {version}", - ], - stage="CreateCommit", - env=clean_env, - ) + # check if repo is clean (clean => no error, no commit) + try: + CommandRunner.run_or_fail( + ["git", "diff", "--exit-code"], stage="CheckRepoClean", env=clean_env + ) + except CommandRunner.Exception: + # Commit with settings above + CommandRunner.run_or_fail( + [ + "git", + "-c", + f"user.name={user_name}", + "-c", + f"user.email={user_email}", + "commit", + "-m", + f"feat({scope}): update to {version}", + ], + stage="CreateCommit", + env=clean_env, + ) @staticmethod def push(branch: str): From b1c5315a5fbc33624525e434ddbaec3bb30030e2 Mon Sep 17 00:00:00 2001 From: "ohmyzsh[bot]" <54982679+ohmyzsh[bot]@users.noreply.github.com> Date: Sun, 12 May 2024 12:42:59 +0200 Subject: [PATCH 67/79] feat(wd): update to version v0.6.1 (#12413) Co-authored-by: ohmyzsh[bot] <54982679+ohmyzsh[bot]@users.noreply.github.com> --- .github/dependencies.yml | 2 +- plugins/wd/README.md | 28 +++++++++++++++++++++++++++- plugins/wd/wd.plugin.zsh | 7 ++++++- plugins/wd/wd.sh | 37 +++++++++++++++++++++++++++++-------- 4 files changed, 63 insertions(+), 11 deletions(-) mode change 100644 => 100755 plugins/wd/wd.sh diff --git a/.github/dependencies.yml b/.github/dependencies.yml index a105f440d..6ae97ad4e 100644 --- a/.github/dependencies.yml +++ b/.github/dependencies.yml @@ -39,7 +39,7 @@ dependencies: plugins/wd: repo: mfaerevaag/wd branch: master - version: tag:v0.6.0 + version: tag:v0.6.1 precopy: | set -e rm -r test diff --git a/plugins/wd/README.md b/plugins/wd/README.md index 0ad74e805..0c71c0565 100644 --- a/plugins/wd/README.md +++ b/plugins/wd/README.md @@ -57,6 +57,24 @@ wd() { } ``` +### [Home Manager](https://github.com/nix-community/home-manager) + +Add the following to your `home.nix` then run `home-manager switch`: + +```nix +programs.zsh.plugins = [ + { + name = "wd"; + src = pkgs.fetchFromGitHub { + owner = "mfaerevaag"; + repo = "wd"; + rev = "v0.5.2"; + sha256 = "sha256-4yJ1qhqhNULbQmt6Z9G22gURfDLe30uV1ascbzqgdhg="; + }; + } +]; +``` + ### [zplug](https://github.com/zplug/zplug) ```zsh @@ -119,6 +137,14 @@ Also, you may have to force a rebuild of `zcompdump` by running: rm -f ~/.zcompdump; compinit ``` +## Browse + +If you want to make use of the `fzf`-powered browse feature to fuzzy search through all your warp points, set up a keybind in your `.zshrc`: + +```zsh +bindkey '^G' wd_browse +``` + ## Usage * Add warp point to current working directory: @@ -153,7 +179,7 @@ wd .. wd ... ``` -This is a wrapper for the zsh's `dirs` function. +This is a wrapper for the zsh's `dirs` function. _You might need to add `setopt AUTO_PUSHD` to your `.zshrc` if you are not using [oh-my-zsh](https://github.com/ohmyzsh/ohmyzsh)._ * Remove warp point: diff --git a/plugins/wd/wd.plugin.zsh b/plugins/wd/wd.plugin.zsh index ca2ca7c65..9e0c7ff13 100644 --- a/plugins/wd/wd.plugin.zsh +++ b/plugins/wd/wd.plugin.zsh @@ -8,8 +8,13 @@ # @github.com/mfaerevaag/wd # Handle $0 according to the standard: -# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html +# # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html 0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}" 0="${${(M)0:#/*}:-$PWD/$0}" eval "wd() { source '${0:A:h}/wd.sh' }" +wd > /dev/null +# Register the function as a Zsh widget +zle -N wd_browse +# Bind the widget to a key combination +bindkey '^G' wd_browse diff --git a/plugins/wd/wd.sh b/plugins/wd/wd.sh old mode 100644 new mode 100755 index 840e92d61..c4f422cbf --- a/plugins/wd/wd.sh +++ b/plugins/wd/wd.sh @@ -8,7 +8,7 @@ # @github.com/mfaerevaag/wd # version -readonly WD_VERSION=0.5.0 +readonly WD_VERSION=0.6.1 # colors readonly WD_BLUE="\033[96m" @@ -57,12 +57,11 @@ wd_print_msg() { if [[ -z $wd_quiet_mode ]] then - local color=$1 - local msg=$2 + local color="${1:-$WD_BLUE}" # Default to blue if no color is provided + local msg="$2" - if [[ $color == "" || $msg == "" ]] - then - print " ${WD_RED}*${WD_NOC} Could not print message. Sorry!" + if [[ -z "$msg" ]]; then + print "${WD_RED}*${WD_NOC} Could not print message. Sorry!" else print " ${color}*${WD_NOC} ${msg}" fi @@ -230,6 +229,20 @@ wd_remove() done } +wd_browse() { + if ! command -v fzf >/dev/null; then + echo "This functionality requires fzf. Please install fzf first." + return 1 + fi + local entries=("${(@f)$(sed "s:${HOME}:~:g" "$WD_CONFIG" | awk -F ':' '{print $1 " -> " $2}')}") + local selected_entry=$(printf '%s\n' "${entries[@]}" | fzf --height 40% --reverse) + if [[ -n $selected_entry ]]; then + local selected_point="${selected_entry%% ->*}" + selected_point=$(echo "$selected_point" | xargs) + wd $selected_point + fi +} + wd_list_all() { wd_print_msg "$WD_BLUE" "All warp points:" @@ -396,7 +409,9 @@ fi # disable extendedglob for the complete wd execution time setopt | grep -q extendedglob wd_extglob_is_set=$? -(( ! $wd_extglob_is_set )) && setopt noextendedglob +if (( wd_extglob_is_set == 0 )); then + setopt noextendedglob +fi # load warp points typeset -A points @@ -436,6 +451,10 @@ else wd_add "$2" "$wd_force_mode" break ;; + "-b"|"browse") + wd_browse + break + ;; "-e"|"export") wd_export_static_named_directories break @@ -484,7 +503,9 @@ fi # if not, next time warp will pick up variables from this run # remember, there's no sub shell -(( ! $wd_extglob_is_set )) && setopt extendedglob +if (( wd_extglob_is_set == 0 )); then + setopt extendedglob +fi unset wd_extglob_is_set unset wd_warp From a8a747e18abe41b26de0b892e888ad5c386abc3f Mon Sep 17 00:00:00 2001 From: Juho Kuisma Date: Wed, 15 May 2024 20:14:11 +0300 Subject: [PATCH 68/79] feat(fzf): add support for Fedora package (#12421) --- plugins/fzf/fzf.plugin.zsh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/plugins/fzf/fzf.plugin.zsh b/plugins/fzf/fzf.plugin.zsh index 48fea4f63..e244b4cfb 100644 --- a/plugins/fzf/fzf.plugin.zsh +++ b/plugins/fzf/fzf.plugin.zsh @@ -148,6 +148,27 @@ function fzf_setup_using_opensuse() { return 0 } +function fzf_setup_using_fedora() { + (( $+commands[fzf] )) || return 1 + + local completions="/usr/share/zsh/site-functions/fzf" + local key_bindings="/usr/share/fzf/shell/key-bindings.zsh" + + if [[ ! -f "$completions" || ! -f "$key_bindings" ]]; then + return 1 + fi + + if [[ -o interactive && "$DISABLE_FZF_AUTO_COMPLETION" != "true" ]]; then + source "$completions" 2>/dev/null + fi + + if [[ "$DISABLE_FZF_KEY_BINDINGS" != "true" ]]; then + source "$key_bindings" 2>/dev/null + fi + + return 0 +} + function fzf_setup_using_openbsd() { # openBSD installs fzf in /usr/local/bin/fzf if [[ "$OSTYPE" != openbsd* ]] || (( ! $+commands[fzf] )); then @@ -234,6 +255,7 @@ fzf_setup_using_fzf \ || fzf_setup_using_openbsd \ || fzf_setup_using_debian \ || fzf_setup_using_opensuse \ + || fzf_setup_using_fedora \ || fzf_setup_using_cygwin \ || fzf_setup_using_macports \ || fzf_setup_using_base_dir \ From fb91ca27a2d65b834e98a3986cfee73ad82ea412 Mon Sep 17 00:00:00 2001 From: Fritz Reichwald Date: Wed, 15 May 2024 19:27:21 +0200 Subject: [PATCH 69/79] feat(amuse): add whitespace before virtualenv (#12423) --- themes/amuse.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/amuse.zsh-theme b/themes/amuse.zsh-theme index d787fdaa4..cddbcd40d 100644 --- a/themes/amuse.zsh-theme +++ b/themes/amuse.zsh-theme @@ -17,7 +17,7 @@ $ ' RPROMPT='$(ruby_prompt_info)' VIRTUAL_ENV_DISABLE_PROMPT=0 -ZSH_THEME_VIRTUAL_ENV_PROMPT_PREFIX=" %{$fg[green]%}🐍" +ZSH_THEME_VIRTUAL_ENV_PROMPT_PREFIX=" %{$fg[green]%}🐍 " ZSH_THEME_VIRTUAL_ENV_PROMPT_SUFFIX="%{$reset_color%}" ZSH_THEME_VIRTUALENV_PREFIX=$ZSH_THEME_VIRTUAL_ENV_PROMPT_PREFIX ZSH_THEME_VIRTUALENV_SUFFIX=$ZSH_THEME_VIRTUAL_ENV_PROMPT_SUFFIX From a779d6563ffb2f0093b4b74c8d5ff0982fa3e930 Mon Sep 17 00:00:00 2001 From: Alessandro Miliucci Date: Thu, 16 May 2024 22:13:36 +0200 Subject: [PATCH 70/79] chore(template): propose add `.local/bin` to PATH (#12417) --- templates/zshrc.zsh-template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/zshrc.zsh-template b/templates/zshrc.zsh-template index 7e1c7997c..a73d60799 100644 --- a/templates/zshrc.zsh-template +++ b/templates/zshrc.zsh-template @@ -1,5 +1,5 @@ # If you come from bash you might have to change your $PATH. -# export PATH=$HOME/bin:/usr/local/bin:$PATH +# export PATH=$HOME/bin:$HOME/.local/bin:/usr/local/bin:$PATH # Path to your oh-my-zsh installation. export ZSH=$HOME/.oh-my-zsh From 309129f651eeeca62c3a3b7f6817f0ac601db9f0 Mon Sep 17 00:00:00 2001 From: Daniel Ochoja <37149152+Ochoja@users.noreply.github.com> Date: Tue, 21 May 2024 19:36:07 +0100 Subject: [PATCH 71/79] feat(agnoster): add `anaconda` env information (#12434) --- themes/agnoster.zsh-theme | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme index c2a542163..767a4ed50 100644 --- a/themes/agnoster.zsh-theme +++ b/themes/agnoster.zsh-theme @@ -227,6 +227,14 @@ prompt_virtualenv() { fi } +# Conda Virtualenv +promp_conda_virtualenv() { + if [[ -n $CONDA_PROMPT_MODIFIER ]]; then + prompt_segment black default ${CONDA_PROMPT_MODIFIER:1:-2} + fi +} + + # Status: # - was there an error # - am I root @@ -266,6 +274,7 @@ build_prompt() { prompt_bzr prompt_hg prompt_end + promp_conda_virtualenv } PROMPT='%{%f%b%k%}$(build_prompt) ' From 0621944db50aec931850806644b673e39b650163 Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Tue, 21 May 2024 20:43:26 +0200 Subject: [PATCH 72/79] fix(dependencies): only open PR if there are changes --- .github/workflows/dependencies/updater.py | 78 +++++++++++++---------- 1 file changed, 44 insertions(+), 34 deletions(-) diff --git a/.github/workflows/dependencies/updater.py b/.github/workflows/dependencies/updater.py index 4533b7aeb..e64d69939 100644 --- a/.github/workflows/dependencies/updater.py +++ b/.github/workflows/dependencies/updater.py @@ -228,21 +228,22 @@ class Dependency: self.__apply_upstream_changes() # Add all changes and commit - Git.add_and_commit(self.name, short_sha) + has_new_commit = Git.add_and_commit(self.name, short_sha) - # Push changes to remote - Git.push(branch) + if has_new_commit: + # Push changes to remote + Git.push(branch) - # Create GitHub PR - GitHub.create_pr( - branch, - f"feat({self.name}): update to version {new_version}", - f"""## Description + # Create GitHub PR + GitHub.create_pr( + branch, + f"feat({self.name}): update to version {new_version}", + f"""## Description -Update for **{self.desc}**: update to version [{new_version}]({status['head_url']}). -Check out the [list of changes]({status['compare_url']}). -""", - ) + Update for **{self.desc}**: update to version [{new_version}]({status['head_url']}). + Check out the [list of changes]({status['compare_url']}). + """, + ) # Clean up repository Git.clean_repo() @@ -377,7 +378,21 @@ class Git: return branch_name @staticmethod - def add_and_commit(scope: str, version: str): + def add_and_commit(scope: str, version: str) -> bool: + """ + Returns `True` if there were changes and were indeed commited. + Returns `False` if the repo was clean and no changes were commited. + """ + # check if repo is clean (clean => no error, no commit) + try: + CommandRunner.run_or_fail( + ["git", "diff", "--exit-code"], stage="CheckRepoClean" + ) + return False + except CommandRunner.Exception: + # if it's other kind of error just throw! + pass + user_name = os.environ.get("GIT_APP_NAME") user_email = os.environ.get("GIT_APP_EMAIL") @@ -390,27 +405,22 @@ class Git: clean_env["GIT_CONFIG_GLOBAL"] = "/dev/null" clean_env["GIT_CONFIG_NOSYSTEM"] = "1" - # check if repo is clean (clean => no error, no commit) - try: - CommandRunner.run_or_fail( - ["git", "diff", "--exit-code"], stage="CheckRepoClean", env=clean_env - ) - except CommandRunner.Exception: - # Commit with settings above - CommandRunner.run_or_fail( - [ - "git", - "-c", - f"user.name={user_name}", - "-c", - f"user.email={user_email}", - "commit", - "-m", - f"feat({scope}): update to {version}", - ], - stage="CreateCommit", - env=clean_env, - ) + # Commit with settings above + CommandRunner.run_or_fail( + [ + "git", + "-c", + f"user.name={user_name}", + "-c", + f"user.email={user_email}", + "commit", + "-m", + f"feat({scope}): update to {version}", + ], + stage="CreateCommit", + env=clean_env, + ) + return True @staticmethod def push(branch: str): From 04b66b230857fb9bc28af5e7590b09ff79f888fa Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Tue, 21 May 2024 20:46:54 +0200 Subject: [PATCH 73/79] chore(dependencies): PR wording --- .github/workflows/dependencies/updater.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/dependencies/updater.py b/.github/workflows/dependencies/updater.py index e64d69939..f85c9eda7 100644 --- a/.github/workflows/dependencies/updater.py +++ b/.github/workflows/dependencies/updater.py @@ -240,9 +240,9 @@ class Dependency: f"feat({self.name}): update to version {new_version}", f"""## Description - Update for **{self.desc}**: update to version [{new_version}]({status['head_url']}). - Check out the [list of changes]({status['compare_url']}). - """, +Update for **{self.desc}**: update to version [{new_version}]({status['head_url']}). +Check out the [list of changes]({status['compare_url']}). +""", ) # Clean up repository From f6b3fc84d192274f245a7322c3994767c5e68691 Mon Sep 17 00:00:00 2001 From: "ohmyzsh[bot]" <54982679+ohmyzsh[bot]@users.noreply.github.com> Date: Tue, 21 May 2024 20:48:54 +0200 Subject: [PATCH 74/79] feat(wd): update to version v0.7.0 (#12436) Co-authored-by: ohmyzsh[bot] <54982679+ohmyzsh[bot]@users.noreply.github.com> --- .github/dependencies.yml | 2 +- plugins/wd/README.md | 15 ++++++- plugins/wd/_wd.sh | 4 ++ plugins/wd/wd.plugin.zsh | 9 +++-- plugins/wd/wd.sh | 87 ++++++++++++++++++++++++++++++++-------- 5 files changed, 95 insertions(+), 22 deletions(-) diff --git a/.github/dependencies.yml b/.github/dependencies.yml index 6ae97ad4e..d3b269361 100644 --- a/.github/dependencies.yml +++ b/.github/dependencies.yml @@ -39,7 +39,7 @@ dependencies: plugins/wd: repo: mfaerevaag/wd branch: master - version: tag:v0.6.1 + version: tag:v0.7.0 precopy: | set -e rm -r test diff --git a/plugins/wd/README.md b/plugins/wd/README.md index 0c71c0565..bf19031f8 100644 --- a/plugins/wd/README.md +++ b/plugins/wd/README.md @@ -142,7 +142,7 @@ rm -f ~/.zcompdump; compinit If you want to make use of the `fzf`-powered browse feature to fuzzy search through all your warp points, set up a keybind in your `.zshrc`: ```zsh -bindkey '^G' wd_browse +bindkey ${FZF_WD_BINDKEY:-'^B'} fuzzy_wd_widget ``` ## Usage @@ -158,6 +158,19 @@ If a warp point with the same name exists, use `wd add foo --force` to overwrite **Note:** a warp point cannot contain colons, or consist of only spaces and dots. The first will conflict in how `wd` stores the warp points, and the second will conflict with other features, as below. +* Add warp point to any directory with default name: + +```zsh +wd addcd /foo/ bar +``` + +* Add warp point to any directory with a custom name: + +```zsh +wd addcd /foo/ +``` + + You can omit point name to automatically use the current directory's name instead. * From any directory, warp to `foo` with: diff --git a/plugins/wd/_wd.sh b/plugins/wd/_wd.sh index 52ecb12e6..46b032f78 100644 --- a/plugins/wd/_wd.sh +++ b/plugins/wd/_wd.sh @@ -31,6 +31,7 @@ function _wd() { commands=( 'add:Adds the current working directory to your warp points' + 'addcd:Adds a directory to your warp points' 'add!:Overwrites existing warp point' 'export:Export warp points as static named directories' 'rm:Removes the given warp point' @@ -63,6 +64,9 @@ function _wd() { add) _message 'Write the name of your warp point' && ret=0 ;; + addcd) + _message 'Write the name of your path' && ret=0 + ;; show) _describe -t points "Warp points" warp_points && ret=0 ;; diff --git a/plugins/wd/wd.plugin.zsh b/plugins/wd/wd.plugin.zsh index 9e0c7ff13..9910cb968 100644 --- a/plugins/wd/wd.plugin.zsh +++ b/plugins/wd/wd.plugin.zsh @@ -14,7 +14,8 @@ eval "wd() { source '${0:A:h}/wd.sh' }" wd > /dev/null -# Register the function as a Zsh widget -zle -N wd_browse -# Bind the widget to a key combination -bindkey '^G' wd_browse +zle -N wd_browse_widget +zle -N wd_restore_buffer +autoload -Uz add-zle-hook-widget +add-zle-hook-widget line-init wd_restore_buffer +bindkey ${FZF_WD_BINDKEY:-'^B'} wd_browse_widget diff --git a/plugins/wd/wd.sh b/plugins/wd/wd.sh index c4f422cbf..160ab3be3 100755 --- a/plugins/wd/wd.sh +++ b/plugins/wd/wd.sh @@ -8,7 +8,7 @@ # @github.com/mfaerevaag/wd # version -readonly WD_VERSION=0.6.1 +readonly WD_VERSION=0.7.0 # colors readonly WD_BLUE="\033[96m" @@ -59,7 +59,7 @@ wd_print_msg() then local color="${1:-$WD_BLUE}" # Default to blue if no color is provided local msg="$2" - + if [[ -z "$msg" ]]; then print "${WD_RED}*${WD_NOC} Could not print message. Sorry!" else @@ -74,18 +74,20 @@ wd_print_usage() Usage: wd [command] [point] Commands: - Warps to the directory specified by the warp point - Warps to the directory specified by the warp point with path appended - add Adds the current working directory to your warp points - add Adds the current working directory to your warp points with current directory's name - rm Removes the given warp point - rm Removes the given warp point with current directory's name - show Print path to given warp point - show Print warp points to current directory - list Print all stored warp points - ls Show files from given warp point (ls) - path Show the path to given warp point (pwd) - clean Remove points warping to nonexistent directories (will prompt unless --force is used) + Warps to the directory specified by the warp point + Warps to the directory specified by the warp point with path appended + add Adds the current working directory to your warp points + add Adds the current working directory to your warp points with current directory's name + addcd Adds a path to your warp points with the directory's name + addcd Adds a path to your warp points with a custom name + rm Removes the given warp point + rm Removes the given warp point with current directory's name + show Print path to given warp point + show Print warp points to current directory + list Print all stored warp points + ls Show files from given warp point (ls) + path Show the path to given warp point (pwd) + clean Remove points warping to nonexistent directories (will prompt unless --force is used) -v | --version Print version -d | --debug Exit after execution with exit codes (for testing) @@ -203,6 +205,28 @@ wd_add() fi } +wd_addcd() { + local folder="$1" + local point=$2 + local force=$3 + local currentdir=$PWD + + if [[ -z "$folder" ]]; then + wd_exit_fail "You must specify a path" + return + fi + + if [[ ! -d "$folder" ]]; then + wd_exit_fail "The directory does not exist" + return + fi + + cd "$folder" || return + wd_add "$point" "$force" + cd "$currentdir" || return +} + + wd_remove() { local point_list=$1 @@ -235,7 +259,15 @@ wd_browse() { return 1 fi local entries=("${(@f)$(sed "s:${HOME}:~:g" "$WD_CONFIG" | awk -F ':' '{print $1 " -> " $2}')}") - local selected_entry=$(printf '%s\n' "${entries[@]}" | fzf --height 40% --reverse) + local script_path="${${(%):-%x}:h}" + local wd_remove_output=$(mktemp "${TMPDIR:-/tmp}/wd.XXXXXXXXXX") + local entries_with_headers=("All warp points:" "Press enter to select. Press delete to remove" "${entries[@]}") + local fzf_bind="delete:execute(echo {} | awk -F ' -> ' '{print \$1}' | xargs -I {} "$script_path/wd.sh" rm {} > "$wd_remove_output")+abort" + local fzf_command=$(printf '%s\n' "${entries_with_headers[@]}" | fzf --height 100% --reverse --header-lines=2 --bind="$fzf_bind") + if [[ -e $wd_remove_output ]]; then + cat "$wd_remove_output" + rm "$wd_remove_output" + fi if [[ -n $selected_entry ]]; then local selected_point="${selected_entry%% ->*}" selected_point=$(echo "$selected_point" | xargs) @@ -243,6 +275,24 @@ wd_browse() { fi } +wd_browse_widget() { + if [[ -e $WD_CONFIG ]]; then + wd_browse + saved_buffer=$BUFFER + saved_cursor=$CURSOR + BUFFER= + zle redisplay + zle accept-line + fi +} + +wd_restore_buffer() { + BUFFER=$saved_buffer + CURSOR=$saved_cursor + saved_buffer= + saved_cursor=1 +} + wd_list_all() { wd_print_msg "$WD_BLUE" "All warp points:" @@ -371,7 +421,7 @@ wd_export_static_named_directories() { fi } -local WD_CONFIG=${WD_CONFIG:-$HOME/.warprc} +WD_CONFIG=${WD_CONFIG:-$HOME/.warprc} local WD_QUIET=0 local WD_EXIT_CODE=0 local WD_DEBUG=0 @@ -455,6 +505,10 @@ else wd_browse break ;; + "-c"|"--addcd"|"addcd") + wd_addcd "$2" "$3" "$wd_force_mode" + break + ;; "-e"|"export") wd_export_static_named_directories break @@ -510,6 +564,7 @@ fi unset wd_extglob_is_set unset wd_warp unset wd_add +unset wd_addcd unset wd_remove unset wd_show unset wd_list_all From dfb436b54a10c84156a548dded0506d474050a43 Mon Sep 17 00:00:00 2001 From: danielwerg <35052399+danielwerg@users.noreply.github.com> Date: Tue, 21 May 2024 21:58:43 +0300 Subject: [PATCH 75/79] feat(tldr): add tldr plugin (#12429) --- plugins/tldr/README.md | 15 +++++++++++++++ plugins/tldr/tldr.plugin.zsh | 19 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 plugins/tldr/README.md create mode 100644 plugins/tldr/tldr.plugin.zsh diff --git a/plugins/tldr/README.md b/plugins/tldr/README.md new file mode 100644 index 000000000..fb91d9d1f --- /dev/null +++ b/plugins/tldr/README.md @@ -0,0 +1,15 @@ +# tldr plugin + +This plugin adds a shortcut to insert tldr before the previous command. +Heavily inspired from [Man plugin](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/man). + +To use it, add `tldr` to the plugins array in your zshrc file: + +```zsh +plugins=(... tldr) +``` + +# Keyboard Shortcuts +| Shortcut | Description | +|------------------------------------|----------------------------------------------------------------------------| +| Esc + tldr | add tldr before the previous command to see the tldr page for this command | diff --git a/plugins/tldr/tldr.plugin.zsh b/plugins/tldr/tldr.plugin.zsh new file mode 100644 index 000000000..9f3de5f0c --- /dev/null +++ b/plugins/tldr/tldr.plugin.zsh @@ -0,0 +1,19 @@ +tldr-command-line() { + # if there is no command typed, use the last command + [[ -z "$BUFFER" ]] && zle up-history + + # if typed command begins with tldr, do nothing + [[ "$BUFFER" = tldr\ * ]] && return + + # get command and possible subcommand + # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion-Flags + local -a args + args=(${${(Az)BUFFER}[1]} ${${(Az)BUFFER}[2]}) + + BUFFER="tldr ${args[1]}" +} + +zle -N tldr-command-line +# Defined shortcut keys: [Esc]tldr +bindkey "\e"tldr tldr-command-line + From bbfb9853591312c180a0c417226e4ef899d4cf3a Mon Sep 17 00:00:00 2001 From: robinverduijn Date: Tue, 21 May 2024 22:39:12 -0700 Subject: [PATCH 76/79] chore(agnoster): typo (#12437) --- themes/agnoster.zsh-theme | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme index 767a4ed50..4445ad4a4 100644 --- a/themes/agnoster.zsh-theme +++ b/themes/agnoster.zsh-theme @@ -228,7 +228,7 @@ prompt_virtualenv() { } # Conda Virtualenv -promp_conda_virtualenv() { +prompt_conda_virtualenv() { if [[ -n $CONDA_PROMPT_MODIFIER ]]; then prompt_segment black default ${CONDA_PROMPT_MODIFIER:1:-2} fi @@ -274,7 +274,7 @@ build_prompt() { prompt_bzr prompt_hg prompt_end - promp_conda_virtualenv + prompt_conda_virtualenv } PROMPT='%{%f%b%k%}$(build_prompt) ' From c77a01dbe28acaa13e53c7dc78d6b798f3f42fc2 Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Wed, 22 May 2024 09:15:11 +0200 Subject: [PATCH 77/79] Revert "feat(agnoster): add `anaconda` env information (#12434)" This reverts commit 309129f651eeeca62c3a3b7f6817f0ac601db9f0. --- themes/agnoster.zsh-theme | 9 --------- 1 file changed, 9 deletions(-) diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme index 4445ad4a4..c2a542163 100644 --- a/themes/agnoster.zsh-theme +++ b/themes/agnoster.zsh-theme @@ -227,14 +227,6 @@ prompt_virtualenv() { fi } -# Conda Virtualenv -prompt_conda_virtualenv() { - if [[ -n $CONDA_PROMPT_MODIFIER ]]; then - prompt_segment black default ${CONDA_PROMPT_MODIFIER:1:-2} - fi -} - - # Status: # - was there an error # - am I root @@ -274,7 +266,6 @@ build_prompt() { prompt_bzr prompt_hg prompt_end - prompt_conda_virtualenv } PROMPT='%{%f%b%k%}$(build_prompt) ' From 41d2029dec256b9ef3869cb83699d88b94eb3c1d Mon Sep 17 00:00:00 2001 From: Rizky Ilham Pratama Date: Wed, 22 May 2024 15:17:06 +0800 Subject: [PATCH 78/79] feat(laravel): add aliases laravel 11 (#12354) --- plugins/laravel/README.md | 4 ++++ plugins/laravel/laravel.plugin.zsh | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/plugins/laravel/README.md b/plugins/laravel/README.md index a831a86b6..21eb89373 100644 --- a/plugins/laravel/README.md +++ b/plugins/laravel/README.md @@ -36,6 +36,10 @@ plugins=(... laravel) | `pamj` | `php artisan make:job` | | `paml` | `php artisan make:listener` | | `pamn` | `php artisan make:notification` | +| `pamcl` | `php artisan make:class` | +| `pamen` | `php artisan make:enum` | +| `pami` | `php artisan make:interface` | +| `pamtr` | `php artisan make:trait` | ## Clears diff --git a/plugins/laravel/laravel.plugin.zsh b/plugins/laravel/laravel.plugin.zsh index 319946f07..86ae27299 100644 --- a/plugins/laravel/laravel.plugin.zsh +++ b/plugins/laravel/laravel.plugin.zsh @@ -25,6 +25,10 @@ alias pamj='php artisan make:job' alias paml='php artisan make:listener' alias pamn='php artisan make:notification' alias pampp='php artisan make:provider' +alias pamcl='php artisan make:class' +alias pamen='php artisan make:enum' +alias pami='php artisan make:interface' +alias pamtr='php artisan make:trait' # Clears From 203369b0f9ec284e06b73f555a14fa5f02be5a0a Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Wed, 22 May 2024 15:36:03 +0200 Subject: [PATCH 79/79] ci(dependencies): run on sunday CET morning --- .github/workflows/dependencies.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dependencies.yml b/.github/workflows/dependencies.yml index 6bc8dc74d..6c7387089 100644 --- a/.github/workflows/dependencies.yml +++ b/.github/workflows/dependencies.yml @@ -2,7 +2,7 @@ name: Update dependencies on: workflow_dispatch: {} schedule: - - cron: "34 3 * * */8" + - cron: "0 6 * * 0" jobs: check: