Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
kareefardi committed Dec 31, 2021
2 parents 5ff95e8 + 116fc2f commit 3108d22
Show file tree
Hide file tree
Showing 130 changed files with 36,071 additions and 4,601 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins/genpass/ @atoponce
plugins/git-lfs/ @hellovietduc
plugins/gitfast/ @felipec
plugins/sdk/ @rgoldberg
plugins/shell-proxy/ @septs
plugins/universalarchive/ @Konfekt
plugins/wp-cli/ @joshmedeski
plugins/zoxide/ @ajeetdsouza
6 changes: 4 additions & 2 deletions .github/actions/spelling/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ acr
acroread
acs
acsc
acss
acsp
acss
actionformats
Adamantium
adb
Expand Down Expand Up @@ -312,6 +312,7 @@ bisd
bitboxer
bitbucket
bitswap
bitwarden
blkio
blockprofile
blockprofilerate
Expand Down Expand Up @@ -3119,6 +3120,7 @@ rbenv
rbenvdirs
rbfu
RBUFFER
rbw
rcfile
Rchive
rcs
Expand Down Expand Up @@ -4442,8 +4444,8 @@ zrr
zrs
zscore
zse
zsh'ed
zsh
zsh'ed
zshaddhistory
zshcmd
zshcommands
Expand Down
49 changes: 26 additions & 23 deletions lib/cli.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,10 @@ multi == 1 && length(\$0) > 0 {
{ print \$0 }
"

awk "$awk_script" ~/.zshrc > ~/.zshrc.new \
&& command mv -f ~/.zshrc ~/.zshrc.bck \
&& command mv -f ~/.zshrc.new ~/.zshrc
local zdot="${ZDOTDIR:-$HOME}"
awk "$awk_script" "$zdot/.zshrc" > "$zdot/.zshrc.new" \
&& command mv -f "$zdot/.zshrc" "$zdot/.zshrc.bck" \
&& command mv -f "$zdot/.zshrc.new" "$zdot/.zshrc"

# Exit if the new .zshrc file wasn't created correctly
[[ $? -eq 0 ]] || {
Expand All @@ -288,10 +289,10 @@ multi == 1 && length(\$0) > 0 {
}

# Exit if the new .zshrc file has syntax errors
if ! zsh -n ~/.zshrc; then
_omz::log error "broken syntax in ~/.zshrc. Rolling back changes..."
command mv -f ~/.zshrc ~/.zshrc.new
command mv -f ~/.zshrc.bck ~/.zshrc
if ! zsh -n "$zdot/.zshrc"; then
_omz::log error "broken syntax in '"${zdot/#$HOME/\~}/.zshrc"'. Rolling back changes..."
command mv -f "$zdot/.zshrc" "$zdot/.zshrc.new"
command mv -f "$zdot/.zshrc.bck" "$zdot/.zshrc"
return 1
fi

Expand Down Expand Up @@ -351,9 +352,10 @@ multi == 1 && /^[^#]*\)/ {
{ print \$0 }
"

awk "$awk_script" ~/.zshrc > ~/.zshrc.new \
&& command mv -f ~/.zshrc ~/.zshrc.bck \
&& command mv -f ~/.zshrc.new ~/.zshrc
local zdot="${ZDOTDIR:-$HOME}"
awk "$awk_script" "$zdot/.zshrc" > "$zdot/.zshrc.new" \
&& command mv -f "$zdot/.zshrc" "$zdot/.zshrc.bck" \
&& command mv -f "$zdot/.zshrc.new" "$zdot/.zshrc"

# Exit if the new .zshrc file wasn't created correctly
[[ $? -eq 0 ]] || {
Expand All @@ -363,10 +365,10 @@ multi == 1 && /^[^#]*\)/ {
}

# Exit if the new .zshrc file has syntax errors
if ! zsh -n ~/.zshrc; then
_omz::log error "broken syntax in ~/.zshrc. Rolling back changes..."
command mv -f ~/.zshrc ~/.zshrc.new
command mv -f ~/.zshrc.bck ~/.zshrc
if ! zsh -n "$zdot/.zshrc"; then
_omz::log error "broken syntax in '"${zdot/#$HOME/\~}/.zshrc"'. Rolling back changes..."
command mv -f "$zdot/.zshrc" "$zdot/.zshrc.new"
command mv -f "$zdot/.zshrc.bck" "$zdot/.zshrc"
return 1
fi

Expand Down Expand Up @@ -698,17 +700,18 @@ END {
}
'

awk "$awk_script" ~/.zshrc > ~/.zshrc.new \
local zdot="${ZDOTDIR:-$HOME}"
awk "$awk_script" "$zdot/.zshrc" > "$zdot/.zshrc.new" \
|| {
# Prepend ZSH_THEME= line to .zshrc if it doesn't exist
cat <<EOF
ZSH_THEME="$1" # set by \`omz\`
EOF
cat ~/.zshrc
} > ~/.zshrc.new \
&& command mv -f ~/.zshrc ~/.zshrc.bck \
&& command mv -f ~/.zshrc.new ~/.zshrc
cat "$zdot/.zshrc"
} > "$zdot/.zshrc.new" \
&& command mv -f "$zdot/.zshrc" "$zdot/.zshrc.bck" \
&& command mv -f "$zdot/.zshrc.new" "$zdot/.zshrc"

# Exit if the new .zshrc file wasn't created correctly
[[ $? -eq 0 ]] || {
Expand All @@ -718,10 +721,10 @@ EOF
}

# Exit if the new .zshrc file has syntax errors
if ! zsh -n ~/.zshrc; then
_omz::log error "broken syntax in ~/.zshrc. Rolling back changes..."
command mv -f ~/.zshrc ~/.zshrc.new
command mv -f ~/.zshrc.bck ~/.zshrc
if ! zsh -n "$zdot/.zshrc"; then
_omz::log error "broken syntax in '"${zdot/#$HOME/\~}/.zshrc"'. Rolling back changes..."
command mv -f "$zdot/.zshrc" "$zdot/.zshrc.new"
command mv -f "$zdot/.zshrc.bck" "$zdot/.zshrc"
return 1
fi

Expand Down
1 change: 1 addition & 0 deletions plugins/aliases/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__pycache__
21 changes: 11 additions & 10 deletions plugins/aliases/README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
## Aliases Cheatsheet
# Aliases cheatsheet

**Maintainer:** [@hqingyi](https://github.com/hqingyi)

With lots of 3rd-party amazing aliases installed, this plugin helps list the shortcuts
that are currently available based on the plugins you have enabled.

Enable this plugin by adding it to your `plugins` definition in `~/.zshrc`.
To use it, add `aliases` to the plugins array in your zshrc file:

```
plugins=(aliases)
```
```zsh
plugins=(aliases)
```

Requirements: Python needs to be installed.

### Usage
## Usage

```
acs: group all alias
acs $keywordquickly filter alias & highlight
```
- `acs`: show all aliases by group.

- `acs <keyword>`: filter aliases by `<keyword>` and highlight.

![screenshot](https://cloud.githubusercontent.com/assets/3602957/11581913/cb54fb8a-9a82-11e5-846b-5a67f67ad9ad.png)
9 changes: 5 additions & 4 deletions plugins/aliases/aliases.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
#
# - acs: alias cheatsheet
# group alias by command, pass addition argv to grep.
ALIASES_PLUGIN_ROOT=$(cd `dirname $0` && pwd)
function acs(){
which python >>/dev/null
[[ $? -eq 1 ]] && echo "[error]no python executable detected!" && return
alias | python $ALIASES_PLUGIN_ROOT/cheatsheet.py $@
(( $+commands[python] )) || {
echo "[error] No python executable detected"
return
}
alias | python ${functions_source[$0]:h}/cheatsheet.py $@
}
4 changes: 2 additions & 2 deletions plugins/ant/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

This plugin provides completion for [Ant](https://ant.apache.org/).

To use it add ant to the plugins array in your zshrc file.
To use it, add `ant` to the plugins array in your zshrc file:

```bash
```zsh
plugins=(... ant)
```

Expand Down
22 changes: 22 additions & 0 deletions plugins/ant/_ant
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#compdef ant

_ant_does_target_list_need_generating () {
[[ ! -f .ant_targets ]] && return 0
[[ build.xml -nt .ant_targets ]] && return 0
return 1
}

_ant () {
if [[ ! -f build.xml ]]; then
return
fi

if ! _ant_does_target_list_need_generating; then
return
fi

ant -p | awk -F " " 'NR > 5 { print lastTarget } { lastTarget = $1 }' >| .ant_targets
compadd -- "$(cat .ant_targets)"
}

_ant "$@"
18 changes: 2 additions & 16 deletions plugins/ant/ant.plugin.zsh
Original file line number Diff line number Diff line change
@@ -1,16 +1,2 @@
_ant_does_target_list_need_generating () {
[ ! -f .ant_targets ] && return 0;
[ build.xml -nt .ant_targets ] && return 0;
return 1;
}

_ant () {
if [ -f build.xml ]; then
if _ant_does_target_list_need_generating; then
ant -p | awk -F " " 'NR > 5 { print lastTarget }{lastTarget = $1}' > .ant_targets
fi
compadd -- `cat .ant_targets`
fi
}

compdef _ant ant
# Default to colored output
export ANT_ARGS='-logger org.apache.tools.ant.listener.AnsiColorLogger'
2 changes: 2 additions & 0 deletions plugins/arcanist/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ plugins=(... arcanist)
| ------- | ---------------------------------- |
| ara | `arc amend` |
| arb | `arc branch` |
| arbl | `arc bland` |
| arco | `arc cover` |
| arci | `arc commit` |
| ard | `arc diff` |
Expand All @@ -24,6 +25,7 @@ plugins=(... arcanist)
| ardpc | `arc diff --plan-changes` |
| are | `arc export` |
| arh | `arc help` |
| arho | `arc hotfix` |
| arl | `arc land` |
| arli | `arc lint` |
| arls | `arc list` |
Expand Down
2 changes: 2 additions & 0 deletions plugins/arcanist/arcanist.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

alias ara='arc amend'
alias arb='arc branch'
alias arbl='arc bland'
alias arco='arc cover'
alias arci='arc commit'

Expand All @@ -17,6 +18,7 @@ alias ardp='arc diff --preview' # creates a new diff in the phab interface

alias are='arc export'
alias arh='arc help'
alias arho='arc hotfix'
alias arl='arc land'
alias arli='arc lint'
alias arls='arc list'
Expand Down
22 changes: 15 additions & 7 deletions plugins/asdf/asdf.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,26 @@
ASDF_DIR="${ASDF_DIR:-$HOME/.asdf}"
ASDF_COMPLETIONS="$ASDF_DIR/completions"

# If not found, check for archlinux/AUR package (/opt/asdf-vm/)
if [[ ! -f "$ASDF_DIR/asdf.sh" || ! -f "$ASDF_COMPLETIONS/asdf.bash" ]] && [[ -f "/opt/asdf-vm/asdf.sh" ]]; then
ASDF_DIR="/opt/asdf-vm"
ASDF_COMPLETIONS="$ASDF_DIR"
fi

# If not found, check for Homebrew package
if [[ ! -f "$ASDF_DIR/asdf.sh" || ! -f "$ASDF_COMPLETIONS/asdf.bash" ]] && (( $+commands[brew] )); then
ASDF_DIR="$(brew --prefix asdf)"
ASDF_COMPLETIONS="$ASDF_DIR/etc/bash_completion.d"
brew_prefix="$(brew --prefix asdf)"
ASDF_DIR="${brew_prefix}/libexec"
ASDF_COMPLETIONS="${brew_prefix}/etc/bash_completion.d"
unset brew_prefix
fi

# Load command
if [[ -f "$ASDF_DIR/asdf.sh" ]]; then
. "$ASDF_DIR/asdf.sh"
. "$ASDF_DIR/asdf.sh"

# Load completions
if [[ -f "$ASDF_COMPLETIONS/asdf.bash" ]]; then
. "$ASDF_COMPLETIONS/asdf.bash"
fi
# Load completions
if [[ -f "$ASDF_COMPLETIONS/asdf.bash" ]]; then
. "$ASDF_COMPLETIONS/asdf.bash"
fi
fi
1 change: 1 addition & 0 deletions plugins/autojump/autojump.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ autojump_paths=(
/etc/profile.d/autojump.zsh # manual installation
/etc/profile.d/autojump.sh # Gentoo installation
/usr/local/share/autojump/autojump.zsh # FreeBSD installation
/usr/pkg/share/autojump/autojump.zsh # NetBSD installation
/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)
Expand Down
2 changes: 1 addition & 1 deletion plugins/bazel/_bazel
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ _get_build_targets() {
;;
esac
completions=(${$(_bazel_b query "kind(\"${rule_re}\", ${pkg}:all)" 2>/dev/null)##*:})
if ( (( ${#completions} > 0 )) && [[ $target_type != run ]] ); then
if ( (( ${#completions} > 0 )) && [[ $target_type != bin ]] ); then
completions+=(all)
fi
echo ${completions[*]}
Expand Down
3 changes: 2 additions & 1 deletion plugins/bundler/_bundler
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ case $state in
"check[Determine whether the requirements for your application are installed]" \
"list[Show all of the gems in the current bundle]" \
"show[Show the source location of a particular gem in the bundle]" \
"info[Show details of a particular gem in the bundle]" \
"outdated[Show all of the outdated gems in the current bundle]" \
"console[Start an IRB session in the context of the current bundle]" \
"open[Open an installed gem in the editor]" \
Expand Down Expand Up @@ -84,7 +85,7 @@ case $state in
'(--verbose)--verbose[Enable verbose output mode]'
ret=0
;;
(open|show)
(open|show|info)
_gems=( $(bundle show 2> /dev/null | sed -e '/^ \*/!d; s/^ \* \([^ ]*\) .*/\1/') )
if [[ $_gems != "" ]]; then
_values 'gems' $_gems && ret=0
Expand Down
10 changes: 1 addition & 9 deletions plugins/cargo/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
# cargo

This plugin adds completion for the Rust build tool [`Cargo`](https://github.com/rust-lang/cargo).

To use it, add `cargo` to the plugins array in your zshrc file:

```zsh
plugins=(... cargo)
```

Updated on March 3rd, 2019, from [Cargo 0.34.0](https://github.com/rust-lang/cargo/releases/tag/0.34.0).
**Deprecated: use the [`rust`](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/rust) plugin instead.**
38 changes: 15 additions & 23 deletions plugins/cargo/cargo.plugin.zsh
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
if (( $+commands[rustup] && $+commands[cargo] )); then
# remove old generated completion file
command rm -f "${0:A:h}/_cargo"

# generate new completion file
ver="$(cargo --version)"
ver_file="$ZSH_CACHE_DIR/cargo_version"
comp_file="$ZSH_CACHE_DIR/completions/_cargo"

mkdir -p "${comp_file:h}"
(( ${fpath[(Ie)${comp_file:h}]} )) || fpath=("${comp_file:h}" $fpath)

if [[ ! -f "$comp_file" || ! -f "$ver_file" || "$ver" != "$(< "$ver_file")" ]]; then
rustup completions zsh cargo >| "$comp_file"
echo "$ver" >| "$ver_file"
fi

declare -A _comps
autoload -Uz _cargo
_comps[cargo]=_cargo

unset ver ver_file comp_file
fi
print ${(%):-'%F{yellow}The `cargo` plugin is deprecated and has been moved to the `rust` plugin.'}
print ${(%):-'Please update your .zshrc to use the `%Brust%b` plugin instead.%f'}

# TODO: 2021-12-28: remove this block
# 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}}"
0="${${(M)0:#/*}:-$PWD/$0}"
# Remove old generated completion file
command rm -f "${0:A:h}/_cargo" "$ZSH_CACHE_DIR/cargo_version"

(( ${fpath[(Ie)$ZSH/plugins/rust]} )) || {
fpath=("$ZSH/plugins/rust" $fpath)
source "$ZSH/plugins/rust/rust.plugin.zsh"
}

0 comments on commit 3108d22

Please sign in to comment.