Unverified Commit 18ee5dff authored by Marc Cornellà's avatar Marc Cornellà Committed by GitHub
Browse files

Merge branch 'master' into clipboard

parents d81cd753 368198b7
# UFW plugin
This plugin adds completion for managing everybody's favorite Uncomplicated Firewall (UFW),
a simple interface for managing iptables. Learn more about [`UFW`](https://wiki.ubuntu.com/UncomplicatedFirewall).
To use it, add ufw to the plugins array of your zshrc file:
```
plugins=(... ufw)
```
Some of the commands include:
* `allow <port>/<optional: protocol>` add an allow rule
* `default` set default policy
* `delete <port>/<optional: protocol>` delete RULE
* `deny <port>/<optional: protocol>` add deny rule
* `disable` disables the firewall
* `enable` enables the firewall
...@@ -21,9 +21,9 @@ Original idea and aliases: [Ruslan Spivak](https://ruslanspivak.wordpress.com/20 ...@@ -21,9 +21,9 @@ Original idea and aliases: [Ruslan Spivak](https://ruslanspivak.wordpress.com/20
## Examples ## Examples
```zsh ```zsh
urlencode 'https://github.com/robbyrussell/oh-my-zsh/search?q=urltools&type=Code' urlencode 'https://github.com/ohmyzsh/ohmyzsh/search?q=urltools&type=Code'
# returns https%3A%2F%2Fgithub.com%2Frobbyrussell%2Foh-my-zsh%2Fsearch%3Fq%3Durltools%26type%3DCode # returns https%3A%2F%2Fgithub.com%2Fohmyzsh%2Fohmyzsh%2Fsearch%3Fq%3Durltools%26type%3DCode
urldecode 'https%3A%2F%2Fgithub.com%2Frobbyrussell%2Foh-my-zsh%2Fsearch%3Fq%3Durltools%26type%3DCode' urldecode 'https%3A%2F%2Fgithub.com%2Fohmyzsh%2Fohmyzsh%2Fsearch%3Fq%3Durltools%26type%3DCode'
# returns https://github.com/robbyrussell/oh-my-zsh/search?q=urltools&type=Code # returns https://github.com/ohmyzsh/ohmyzsh/search?q=urltools&type=Code
``` ```
...@@ -12,11 +12,11 @@ if [[ $(whence node) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHOD ...@@ -12,11 +12,11 @@ if [[ $(whence node) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHOD
alias urlencode='node -e "console.log(encodeURIComponent(process.argv[1]))"' alias urlencode='node -e "console.log(encodeURIComponent(process.argv[1]))"'
alias urldecode='node -e "console.log(decodeURIComponent(process.argv[1]))"' alias urldecode='node -e "console.log(decodeURIComponent(process.argv[1]))"'
elif [[ $(whence python3) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHOD" = "xpython" ) ]]; then elif [[ $(whence python3) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHOD" = "xpython" ) ]]; then
alias urlencode='python3 -c "import sys, urllib.parse as up; print(up.quote_plus(sys.argv[1]))"' alias urlencode='python3 -c "import sys; del sys.path[0]; import urllib.parse as up; print(up.quote_plus(sys.argv[1]))"'
alias urldecode='python3 -c "import sys, urllib.parse as up; print(up.unquote_plus(sys.argv[1]))"' alias urldecode='python3 -c "import sys; del sys.path[0]; import urllib.parse as up; print(up.unquote_plus(sys.argv[1]))"'
elif [[ $(whence python2) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHOD" = "xpython" ) ]]; then elif [[ $(whence python2) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHOD" = "xpython" ) ]]; then
alias urlencode='python2 -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1])"' alias urlencode='python2 -c "import sys; del sys.path[0]; import urllib as ul; print ul.quote_plus(sys.argv[1])"'
alias urldecode='python2 -c "import sys, urllib as ul; print ul.unquote_plus(sys.argv[1])"' alias urldecode='python2 -c "import sys; del sys.path[0]; import urllib as ul; print ul.unquote_plus(sys.argv[1])"'
elif [[ $(whence xxd) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHOD" = "xshell" ) ]]; then elif [[ $(whence xxd) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHOD" = "xshell" ) ]]; then
function urlencode() {echo $@ | tr -d "\n" | xxd -plain | sed "s/\(..\)/%\1/g"} function urlencode() {echo $@ | tr -d "\n" | xxd -plain | sed "s/\(..\)/%\1/g"}
function urldecode() {printf $(echo -n $@ | sed 's/\\/\\\\/g;s/\(%\)\([0-9a-fA-F][0-9a-fA-F]\)/\\x\2/g')"\n"} function urldecode() {printf $(echo -n $@ | sed 's/\\/\\\\/g;s/\(%\)\([0-9a-fA-F][0-9a-fA-F]\)/\\x\2/g')"\n"}
......
...@@ -8,3 +8,33 @@ To use it, add `vagrant` to the plugins array in your zshrc file: ...@@ -8,3 +8,33 @@ To use it, add `vagrant` to the plugins array in your zshrc file:
plugins=(... vagrant) plugins=(... vagrant)
``` ```
## Aliases
| Alias | Command |
|---------|------------------------------|
| `vgi` | `vagrant init` |
| `vup` | `vagrant up` |
| `vd` | `vagrant destroy` |
| `vdf` | `vagrant destroy -f` |
| `vssh` | `vagrant ssh` |
| `vsshc` | `vagrant ssh-config` |
| `vrdp` | `vagrant rdp` |
| `vh` | `vagrant halt` |
| `vssp` | `vagrant suspend` |
| `vst` | `vagrant status` |
| `vre` | `vagrant resume` |
| `vgs` | `vagrant global-status` |
| `vpr` | `vagrant provision` |
| `vr` | `vagrant reload` |
| `vrp` | `vagrant reload --provision` |
| `vp` | `vagrant push` |
| `vsh` | `vagrant share` |
| `vba` | `vagrant box add` |
| `vbr` | `vagrant box remove` |
| `vbl` | `vagrant box list` |
| `vbo` | `vagrant box outdated` |
| `vbu` | `vagrant box update` |
| `vpli` | `vagrant plugin install` |
| `vpll` | `vagrant plugin list` |
| `vplun` | `vagrant plugin uninstall` |
| `vplu` | `vagrant plugin update` |
...@@ -69,8 +69,8 @@ __box_list () ...@@ -69,8 +69,8 @@ __box_list ()
__vm_list () __vm_list ()
{ {
_wanted application expl 'command' compadd $(command grep Vagrantfile -oe '^[^#]*\.vm\.define *[:"]\([a-zA-Z0-9_-]\+\)' 2>/dev/null | awk '{print substr($2, 2)}') _wanted application expl 'command' compadd $(command grep "${VAGRANT_CWD:-.}/Vagrantfile" -oe '^[^#]*\.vm\.define *[:"]\([a-zA-Z0-9_-]\+\)' 2>/dev/null | awk '{print substr($2, 2)}')
_wanted application expl 'command' compadd $(command ls .vagrant/machines/ 2>/dev/null) _wanted application expl 'command' compadd $(command ls "${VAGRANT_CWD:-.}/.vagrant/machines/" 2>/dev/null)
} }
__vagrant-box () __vagrant-box ()
......
alias vgi="vagrant init"
alias vup="vagrant up"
alias vd="vagrant destroy"
alias vdf="vagrant destroy -f"
alias vssh="vagrant ssh"
alias vsshc="vagrant ssh-config"
alias vrdp="vagrant rdp"
alias vh="vagrant halt"
alias vssp="vagrant suspend"
alias vst="vagrant status"
alias vre="vagrant resume"
alias vgs="vagrant global-status"
alias vpr="vagrant provision"
alias vr="vagrant reload"
alias vrp="vagrant reload --provision"
alias vp="vagrant push"
alias vsh="vagrant share"
alias vba="vagrant box add"
alias vbr="vagrant box remove"
alias vbl="vagrant box list"
alias vbo="vagrant box outdated"
alias vbu="vagrant box update"
alias vpli="vagrant plugin install"
alias vpll="vagrant plugin list"
alias vplun="vagrant plugin uninstall"
alias vplu="vagrant plugin update"
# Virtualenvwrapper plugin
This plugin loads Python's [virtualenvwrapper](https://virtualenvwrapper.readthedocs.io/en/latest/) shell tools.
To use it, add `virtualenvwrapper` to the plugins array in your zshrc file:
```zsh
plugins=(... virtualenvwrapper)
```
## Usage
The plugin allows to automatically activate virtualenvs on cd into git repositories with a matching name:
```
➜ github $ cd ansible
(ansible) ➜ ansible git:(devel) $ cd docs
(ansible) ➜ docs git:(devel) $ cd ..
(ansible) ➜ ansible git:(devel) $ cd ..
➜ github $
```
We can override this by having a `.venv` file in the directory containing a differently named virtualenv:
```
➜ github $ cat ansible/.venv
myvirtualenv
➜ github $ cd ansible
(myvirtualenv) ➜ ansible git:(devel) $ cd ..
➜ github $
```
We can disable this behaviour by setting `DISABLE_VENV_CD=1` before Oh My Zsh is sourced:
```zsh
DISABLE_VENV_CD=1
plugins=(... virtualenvwrapper)
source $ZSH/oh-my-zsh.sh
```
virtualenvwrapper='virtualenvwrapper.sh' function {
virtualenvwrapper_lazy='virtualenvwrapper_lazy.sh' # search in these locations for the init script:
for f in $commands[virtualenvwrapper_lazy.sh] \
$commands[virtualenvwrapper.sh] \
/usr/share/virtualenvwrapper/virtualenvwrapper{_lazy,}.sh \
/usr/local/bin/virtualenvwrapper{_lazy,}.sh \
/etc/bash_completion.d/virtualenvwrapper \
/usr/share/bash-completion/completions/virtualenvwrapper
do
if [[ -f $f ]]; then
source $f
return
fi
done
print "[oh-my-zsh] virtualenvwrapper plugin: Cannot find virtualenvwrapper.sh.\n"\
"Please install with \`pip install virtualenvwrapper\`" >&2
}
if (( $+commands[$virtualenvwrapper_lazy] )); then
function {
setopt local_options
unsetopt equals
virtualenvwrapper=${${virtualenvwrapper_lazy}:c}
source ${${virtualenvwrapper_lazy}:c}
[[ -z "$WORKON_HOME" ]] && WORKON_HOME="$HOME/.virtualenvs"
}
elif (( $+commands[$virtualenvwrapper] )); then
function {
setopt local_options
unsetopt equals
source ${${virtualenvwrapper}:c}
}
elif [[ -f "/usr/local/bin/virtualenvwrapper.sh" ]]; then
function {
setopt local_options
unsetopt equals
virtualenvwrapper="/usr/local/bin/virtualenvwrapper.sh"
source "/usr/local/bin/virtualenvwrapper.sh"
}
elif [[ -f "/etc/bash_completion.d/virtualenvwrapper" ]]; then
function {
setopt local_options
unsetopt equals
virtualenvwrapper="/etc/bash_completion.d/virtualenvwrapper"
source "/etc/bash_completion.d/virtualenvwrapper"
}
else
print "[oh-my-zsh] virtualenvwrapper plugin: Cannot find ${virtualenvwrapper}.\n"\
"Please install with \`pip install virtualenvwrapper\`" >&2
return
fi
if ! type workon &>/dev/null; then if ! type workon &>/dev/null; then
print "[oh-my-zsh] virtualenvwrapper plugin: shell function 'workon' not defined.\n"\ print "[oh-my-zsh] virtualenvwrapper plugin: shell function 'workon' not defined.\n"\
"Please check ${virtualenvwrapper}" >&2 "Please check ${virtualenvwrapper}" >&2
return return
fi fi
if [[ "$WORKON_HOME" == "" ]]; then if [[ -z "$WORKON_HOME" ]]; then
print "[oh-my-zsh] \$WORKON_HOME is not defined so plugin virtualenvwrapper will not work" >&2 WORKON_HOME="$HOME/.virtualenvs"
return
fi fi
if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then
...@@ -77,6 +58,12 @@ if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then ...@@ -77,6 +58,12 @@ if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then
else else
ENV_NAME="" ENV_NAME=""
fi 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
deactivate && unset CD_VIRTUAL_ENV
fi
if [[ "$ENV_NAME" != "" ]]; then if [[ "$ENV_NAME" != "" ]]; then
# Activate the environment only if it is not already active # Activate the environment only if it is not already active
if [[ "$VIRTUAL_ENV" != "$WORKON_HOME/$ENV_NAME" ]]; then if [[ "$VIRTUAL_ENV" != "$WORKON_HOME/$ENV_NAME" ]]; then
...@@ -86,17 +73,12 @@ if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then ...@@ -86,17 +73,12 @@ if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then
source $ENV_NAME/bin/activate && export CD_VIRTUAL_ENV="$ENV_NAME" source $ENV_NAME/bin/activate && export CD_VIRTUAL_ENV="$ENV_NAME"
fi fi
fi fi
elif [[ -n $CD_VIRTUAL_ENV && -n $VIRTUAL_ENV ]]; then
# We've just left the repo, deactivate the environment
# Note: this only happens if the virtualenv was activated automatically
deactivate && unset CD_VIRTUAL_ENV
fi fi
fi fi
} }
# Append workon_cwd to the chpwd_functions array, so it will be called on cd # Append workon_cwd to the chpwd_functions array, so it will be called on cd
# http://zsh.sourceforge.net/Doc/Release/Functions.html # http://zsh.sourceforge.net/Doc/Release/Functions.html
if ! (( $chpwd_functions[(I)workon_cwd] )); then autoload -U add-zsh-hook
chpwd_functions+=(workon_cwd) add-zsh-hook chpwd workon_cwd
fi
fi fi
# VS code # VS Code
This plugin makes interaction between the command line and the code editor easier. This plugin makes interaction between the command line and the VS Code editor easier.
To start using it, add the `vscode` plugin to your `plugins` array in `~/.zshrc`: To start using it, add the `vscode` plugin to your `plugins` array in `~/.zshrc`:
...@@ -8,9 +8,20 @@ To start using it, add the `vscode` plugin to your `plugins` array in `~/.zshrc` ...@@ -8,9 +8,20 @@ To start using it, add the `vscode` plugin to your `plugins` array in `~/.zshrc`
plugins=(... vscode) plugins=(... vscode)
``` ```
If you are using [Visual Studio Code Insiders](https://code.visualstudio.com/insiders/), ## Requirements
add the following line in the oh-my-zsh settings section (between the `ZSH_THEME` and
the `plugins=()` line). This will make the plugin use the Insiders version instead. To use VS Code in the terminal **in macOS**, first you need to install the `code` command in the PATH,
otherwise you might receive this message: `zsh: command not found: code`.
[As the docs say](https://code.visualstudio.com/docs/setup/mac#_launching-from-the-command-line), open
the Command Palette via (F1 or ⇧⌘P) and type shell command to find the Shell Command:
> Install 'code' command in PATH
## VS Code Insiders
🍏 **If you are only using [VS Code Insiders](https://code.visualstudio.com/insiders/), the plugin will automatically bind to your Insiders installation.**
But, if you have both Stable and Insiders versions and want to configure the plugin to just use the Insiders version, add the following line in the oh-my-zsh settings section (between the `ZSH_THEME` and the `plugins=()` line). This will make the plugin use the Insiders version instead.
```zsh ```zsh
ZSH_THEME=... ZSH_THEME=...
......
# VScode zsh plugin # VScode zsh plugin
# author: https://github.com/MarsiBarsi # Authors:
# https://github.com/MarsiBarsi (original author)
# https://github.com/babakks
# Use main Visual Studio Code version by default # Use the stable VS Code release, unless the Insiders version is the only
: ${VSCODE:=code} # available installation
if ! which code > /dev/null && which code-insiders > /dev/null; then
: ${VSCODE:=code-insiders}
else
: ${VSCODE:=code}
fi
# Define aliases
alias vsc="$VSCODE ." alias vsc="$VSCODE ."
alias vsca="$VSCODE --add" alias vsca="$VSCODE --add"
alias vscd="$VSCODE --diff" alias vscd="$VSCODE --diff"
......
...@@ -13,7 +13,7 @@ wd ...@@ -13,7 +13,7 @@ wd
### oh-my-zsh ### oh-my-zsh
`wd` comes bundled with [oh-my-zshell](https://github.com/robbyrussell/oh-my-zsh)! `wd` comes bundled with [oh-my-zshell](https://github.com/ohmyzsh/ohmyzsh)!
Just add the plugin in your `~/.zshrc` file: Just add the plugin in your `~/.zshrc` file:
...@@ -53,7 +53,7 @@ Run either in terminal: ...@@ -53,7 +53,7 @@ Run either in terminal:
#### Completion #### Completion
If you're NOT using [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh) and you want to utilize the zsh-completion feature, you will also need to add the path to your `wd` installation (`~/bin/wd` if you used the automatic installer) to your `fpath`. E.g. in your `~/.zshrc`: If you're NOT using [oh-my-zsh](https://github.com/ohmyzsh/ohmyzsh) and you want to utilize the zsh-completion feature, you will also need to add the path to your `wd` installation (`~/bin/wd` if you used the automatic installer) to your `fpath`. E.g. in your `~/.zshrc`:
fpath=(~/path/to/wd $fpath) fpath=(~/path/to/wd $fpath)
...@@ -85,7 +85,7 @@ Also, you may have to force a rebuild of `zcompdump` by running: ...@@ -85,7 +85,7 @@ Also, you may have to force a rebuild of `zcompdump` by running:
$ wd ... $ wd ...
This is a wrapper for the zsh `dirs` function. This is a wrapper for the zsh `dirs` function.
(You might need `setopt AUTO_PUSHD` in your `.zshrc` if you hare not using [oh-my-zshell](https://github.com/robbyrussell/oh-my-zsh)). (You might need `setopt AUTO_PUSHD` in your `.zshrc` if you hare not using [oh-my-zshell](https://github.com/ohmyzsh/ohmyzsh)).
* Remove warp point test point: * Remove warp point test point:
......
#!/bin/zsh
# WARP DIRECTORY # WARP DIRECTORY
# ============== # ==============
# oh-my-zsh plugin # oh-my-zsh plugin
# #
# @github.com/mfaerevaag/wd # @github.com/mfaerevaag/wd
wd() { eval "wd() { source '${0:A:h}/wd.sh' }"
. $ZSH/plugins/wd/wd.sh
}
...@@ -39,6 +39,7 @@ Available search contexts are: ...@@ -39,6 +39,7 @@ Available search contexts are:
| `qwant` | `https://www.qwant.com/?q=` | | `qwant` | `https://www.qwant.com/?q=` |
| `givero` | `https://www.givero.com/search?q=` | | `givero` | `https://www.givero.com/search?q=` |
| `stackoverflow` | `https://stackoverflow.com/search?q=` | | `stackoverflow` | `https://stackoverflow.com/search?q=` |
| `wolframalpha` | `https://wolframalpha.com/input?i=` |
Also there are aliases for bang-searching DuckDuckGo: Also there are aliases for bang-searching DuckDuckGo:
......
...@@ -19,6 +19,7 @@ function web_search() { ...@@ -19,6 +19,7 @@ function web_search() {
qwant "https://www.qwant.com/?q=" qwant "https://www.qwant.com/?q="
givero "https://www.givero.com/search?q=" givero "https://www.givero.com/search?q="
stackoverflow "https://stackoverflow.com/search?q=" stackoverflow "https://stackoverflow.com/search?q="
wolframalpha "https://www.wolframalpha.com/input/?i="
) )
# check whether the search engine is supported # check whether the search engine is supported
...@@ -55,6 +56,7 @@ alias goodreads='web_search goodreads' ...@@ -55,6 +56,7 @@ alias goodreads='web_search goodreads'
alias qwant='web_search qwant' alias qwant='web_search qwant'
alias givero='web_search givero' alias givero='web_search givero'
alias stackoverflow='web_search stackoverflow' alias stackoverflow='web_search stackoverflow'
alias wolframalpha='web_search wolframalpha'
#add your own !bang searches here #add your own !bang searches here
alias wiki='web_search duckduckgo \!w' alias wiki='web_search duckduckgo \!w'
......
...@@ -19,6 +19,7 @@ plugins=(... yarn) ...@@ -19,6 +19,7 @@ plugins=(... yarn)
| yap | `yarn add --peer` | Install a package in peerDependencies (`package.json`) | | yap | `yarn add --peer` | Install a package in peerDependencies (`package.json`) |
| yb | `yarn build` | Run the build script defined in `package.json` | | yb | `yarn build` | Run the build script defined in `package.json` |
| ycc | `yarn cache clean` | Clean yarn's global cache of packages | | ycc | `yarn cache clean` | Clean yarn's global cache of packages |
| yd | `yarn dev` | Run the dev script defined in `package.json` |
| yga | `yarn global add` | Install packages globally on your operating system | | yga | `yarn global add` | Install packages globally on your operating system |
| ygls | `yarn global list` | Lists global installed packages | | ygls | `yarn global list` | Lists global installed packages |
| ygrm | `yarn global remove` | Remove global installed packages from your OS | | ygrm | `yarn global remove` | Remove global installed packages from your OS |
...@@ -26,6 +27,7 @@ plugins=(... yarn) ...@@ -26,6 +27,7 @@ plugins=(... yarn)
| yh | `yarn help` | Show help for a yarn command | | yh | `yarn help` | Show help for a yarn command |
| yi | `yarn init` | Interactively creates or updates a package.json file | | yi | `yarn init` | Interactively creates or updates a package.json file |
| yin | `yarn install` | Install dependencies defined in `package.json` | | yin | `yarn install` | Install dependencies defined in `package.json` |
| yln | `yarn lint` | Run the lint script defined in `package.json` |
| yls | `yarn list` | List installed packages | | yls | `yarn list` | List installed packages |
| yout | `yarn outdated` | Check for outdated package dependencies | | yout | `yarn outdated` | Check for outdated package dependencies |
| yp | `yarn pack` | Create a compressed gzip archive of package dependencies | | yp | `yarn pack` | Create a compressed gzip archive of package dependencies |
...@@ -34,6 +36,10 @@ plugins=(... yarn) ...@@ -34,6 +36,10 @@ plugins=(... yarn)
| ys | `yarn serve` | Start the dev server | | ys | `yarn serve` | Start the dev server |
| yst | `yarn start` | Run the start script defined in `package.json` | | yst | `yarn start` | Run the start script defined in `package.json` |
| yt | `yarn test` | Run the test script defined in `package.json` | | yt | `yarn test` | Run the test script defined in `package.json` |
| ytc | `yarn test --coverage` | Run the test script defined in `package.json` with coverage |
| yuc | `yarn global upgrade && yarn cache clean` | Upgrade global packages and clean yarn's global cache | | yuc | `yarn global upgrade && yarn cache clean` | Upgrade global packages and clean yarn's global cache |
| yui | `yarn upgrade-interactive` | Prompt for which outdated packages to upgrade | | yui | `yarn upgrade-interactive` | Prompt for which outdated packages to upgrade |
| yup | `yarn upgrade` | Upgrade packages to their latest version | | yup | `yarn upgrade` | Upgrade packages to their latest version |
| yv | `yarn version` | Update the version of your package |
| yw | `yarn workspace` | Run a command within a single workspace. |
| yws | `yarn workspaces` | Run a command within all defined workspaces. |
...@@ -71,7 +71,7 @@ _global_commands=( ...@@ -71,7 +71,7 @@ _global_commands=(
'bin:Displays the location of the yarn bin folder' 'bin:Displays the location of the yarn bin folder'
'remove:Remove installed package from dependencies updating package.json' 'remove:Remove installed package from dependencies updating package.json'
'upgrade:Upgrades packages to their latest version based on the specified range' 'upgrade:Upgrades packages to their latest version based on the specified range'
'upgrade-interactive' 'upgrade-interactive:Interactively upgrade packages'
) )
_yarn_commands_scripts() { _yarn_commands_scripts() {
...@@ -81,9 +81,23 @@ _yarn_commands_scripts() { ...@@ -81,9 +81,23 @@ _yarn_commands_scripts() {
} }
_yarn_scripts() { _yarn_scripts() {
local -a scripts local -a commands binaries scripts
scripts=($(yarn run --json 2>/dev/null | sed -E '/Commands available|possibleCommands/!d;s/.*Commands available from binary scripts: ([^"]+)".*/\1/;s/.*"items":\[([^]]+).*/\1/;s/[" ]//g' | tr , '\n' | sed -e 's/:/\\:/g')) local -a scriptNames scriptCommands
_describe 'script' scripts local i runJSON
runJSON=$(yarn run --json 2>/dev/null)
# Some sed utilities (e.g. Mac OS / BSD) don't interpret `\n` in a replacement
# pattern as a newline. See https://superuser.com/q/307165
binaries=($(sed -E '/Commands available/!d;s/.*Commands available from binary scripts: ([^"]+)".*/\1/;s/.*"items":\[([^]]+).*/\1/;s/[" ]//g;s/:/\\:/g;s/,/\'$'\n/g' <<< "$runJSON"))
scriptNames=($(sed -E '/possibleCommands/!d;s/.*"items":\[([^]]+).*/\1/;s/[" ]//g;s/:/\\:/g;s/,/\'$'\n/g' <<< "$runJSON"))
scriptCommands=("${(@f)$(sed -E '/possibleCommands/!d;s/.*"hints":\{(.+")\}.*/\1/;s/"[^"]+"://g;s/:/\\:/g;s/","/\'$'\n/g;s/(^"|"$)//g' <<< "$runJSON")}")
for (( i=1; i <= $#scriptNames; i++ )); do
scripts+=("${scriptNames[$i]}:${scriptCommands[$i]}")
done
commands=($scripts $binaries)
_describe 'command' commands
} }
_yarn_global_commands() { _yarn_global_commands() {
...@@ -240,7 +254,8 @@ _yarn() { ...@@ -240,7 +254,8 @@ _yarn() {
run) run)
_arguments \ _arguments \
'1: :_yarn_scripts' '1: :_yarn_scripts' \
'*:: :_default'
;; ;;
tag) tag)
...@@ -255,6 +270,11 @@ _yarn() { ...@@ -255,6 +270,11 @@ _yarn() {
'*:: :->team_args' '*:: :->team_args'
;; ;;
upgrade-interactive)
_arguments \
'--latest:use the version tagged latest in the registry:'
;;
version) version)
_arguments \ _arguments \
'--new-version:version:' \ '--new-version:version:' \
...@@ -266,6 +286,10 @@ _yarn() { ...@@ -266,6 +286,10 @@ _yarn() {
_arguments \ _arguments \
'1:query:_files' '1:query:_files'
;; ;;
*)
_default
;;
esac esac
;; ;;
esac esac
......
...@@ -4,6 +4,7 @@ alias yad="yarn add --dev" ...@@ -4,6 +4,7 @@ alias yad="yarn add --dev"
alias yap="yarn add --peer" alias yap="yarn add --peer"
alias yb="yarn build" alias yb="yarn build"
alias ycc="yarn cache clean" alias ycc="yarn cache clean"
alias yd="yarn dev"
alias yga="yarn global add" alias yga="yarn global add"
alias ygls="yarn global list" alias ygls="yarn global list"
alias ygrm="yarn global remove" alias ygrm="yarn global remove"
...@@ -11,6 +12,7 @@ alias ygu="yarn global upgrade" ...@@ -11,6 +12,7 @@ alias ygu="yarn global upgrade"
alias yh="yarn help" alias yh="yarn help"
alias yi="yarn init" alias yi="yarn init"
alias yin="yarn install" alias yin="yarn install"
alias yln="yarn lint"
alias yls="yarn list" alias yls="yarn list"
alias yout="yarn outdated" alias yout="yarn outdated"
alias yp="yarn pack" alias yp="yarn pack"
...@@ -19,6 +21,10 @@ alias yrun="yarn run" ...@@ -19,6 +21,10 @@ alias yrun="yarn run"
alias ys="yarn serve" alias ys="yarn serve"
alias yst="yarn start" alias yst="yarn start"
alias yt="yarn test" alias yt="yarn test"
alias ytc="yarn test --coverage"
alias yuc="yarn global upgrade && yarn cache clean" alias yuc="yarn global upgrade && yarn cache clean"
alias yui="yarn upgrade-interactive" alias yui="yarn upgrade-interactive"
alias yup="yarn upgrade" alias yup="yarn upgrade"
alias yv="yarn version"
alias yw="yarn workspace"
alias yws="yarn workspaces"
# Yii plugin
The plugin adds autocomplete commands and subcommands for [yii](https://www.yiiframework.com/).
To use it, add `yii` to the plugins array of your zshrc file:
```
plugins=(... yii)
```
## Aliases
| Alias | Command |
|--------|----------------------|
| yiic | `protected/yiic` |
...@@ -89,7 +89,7 @@ _z() { ...@@ -89,7 +89,7 @@ _z() {
if [ $? -ne 0 -a -f "$datafile" ]; then if [ $? -ne 0 -a -f "$datafile" ]; then
env rm -f "$tempfile" env rm -f "$tempfile"
else else
[ "$_Z_OWNER" ] && chown $_Z_OWNER:$(id -ng $_Z_OWNER) "$tempfile" [ "$_Z_OWNER" ] && chown $_Z_OWNER:"$(id -ng $_Z_OWNER)" "$tempfile"
env mv -f "$tempfile" "$datafile" || env rm -f "$tempfile" env mv -f "$tempfile" "$datafile" || env rm -f "$tempfile"
fi fi
...@@ -110,20 +110,21 @@ _z() { ...@@ -110,20 +110,21 @@ _z() {
else else
# list/go # list/go
local echo fnd last list opt typ
while [ "$1" ]; do case "$1" in while [ "$1" ]; do case "$1" in
--) while [ "$1" ]; do shift; local fnd="$fnd${fnd:+ }$1";done;; --) while [ "$1" ]; do shift; fnd="$fnd${fnd:+ }$1";done;;
-*) local opt=${1:1}; while [ "$opt" ]; do case ${opt:0:1} in -*) opt=${1:1}; while [ "$opt" ]; do case ${opt:0:1} in
c) local fnd="^$PWD $fnd";; c) fnd="^$PWD $fnd";;
e) local echo=1;; e) echo=1;;
h) echo "${_Z_CMD:-z} [-cehlrtx] args" >&2; return;; h) echo "${_Z_CMD:-z} [-cehlrtx] args" >&2; return;;
l) local list=1;; l) list=1;;
r) local typ="rank";; r) typ="rank";;
t) local typ="recent";; t) typ="recent";;
x) sed -i -e "\:^${PWD}|.*:d" "$datafile";; x) sed -i -e "\:^${PWD}|.*:d" "$datafile";;
esac; opt=${opt:1}; done;; esac; opt=${opt:1}; done;;
*) local fnd="$fnd${fnd:+ }$1";; *) fnd="$fnd${fnd:+ }$1";;
esac; local last=$1; [ "$#" -gt 0 ] && shift; done esac; last=$1; [ "$#" -gt 0 ] && shift; done
[ "$fnd" -a "$fnd" != "^$PWD " ] || local list=1 [ "$fnd" -a "$fnd" != "^$PWD " ] || list=1
# if we hit enter on a completion just go there # if we hit enter on a completion just go there
case "$last" in case "$last" in
...@@ -147,7 +148,7 @@ _z() { ...@@ -147,7 +148,7 @@ _z() {
function output(matches, best_match, common) { function output(matches, best_match, common) {
# list or return the desired directory # list or return the desired directory
if( list ) { if( list ) {
cmd = "sort -n >&2" cmd = "sort -g >&2"
for( x in matches ) { for( x in matches ) {
if( matches[x] ) { if( matches[x] ) {
printf "%-10s %s\n", matches[x], x | cmd printf "%-10s %s\n", matches[x], x | cmd
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
* `zcu` aliases `zeus cucumber` * `zcu` aliases `zeus cucumber`
* `zucumber` aliases `zeus cucumber` * `zucumber` aliases `zeus cucumber`
* `zwip` aliases `zeus cucumber --profile wip`
* `zspec` aliases `zeus rspec` * `zspec` aliases `zeus rspec`
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment