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

Merge branch 'master' into fabric_task_description

parents 225425fe 40df67bc
...@@ -3,16 +3,17 @@ wd ...@@ -3,16 +3,17 @@ wd
[![Build Status](https://travis-ci.org/mfaerevaag/wd.png?branch=master)](https://travis-ci.org/mfaerevaag/wd) [![Build Status](https://travis-ci.org/mfaerevaag/wd.png?branch=master)](https://travis-ci.org/mfaerevaag/wd)
`wd` (*warp directory*) lets you jump to custom directories in zsh, without using `cd`. Why? Because `cd` seems ineffecient when the folder is frequently visited or has a long path. `wd` (*warp directory*) lets you jump to custom directories in zsh, without using `cd`. Why? Because `cd` seems inefficient when the folder is frequently visited or has a long path.
*NOTE*: If you are not using zsh, check out the `ruby` branch which has `wd` implemented as a gem. ![tty.gif](https://raw.githubusercontent.com/mfaerevaag/wd/master/tty.gif)
*NEWS*: If you are not using zsh, check out the c-port, [wd-c](https://github.com/mfaerevaag/wd-c), which works with all shells using wrapper functions.
### Setup ### Setup
### oh-my-zsh ### oh-my-zsh
`wd` comes bundles with [oh-my-zshell](https://github.com/robbyrussell/oh-my-zsh)! `wd` comes bundled with [oh-my-zshell](https://github.com/robbyrussell/oh-my-zsh)!
Just add the plugin in your `~/.zshrc` file: Just add the plugin in your `~/.zshrc` file:
...@@ -27,6 +28,10 @@ Run either in terminal: ...@@ -27,6 +28,10 @@ Run either in terminal:
* `wget --no-check-certificate https://github.com/mfaerevaag/wd/raw/master/install.sh -O - | sh` * `wget --no-check-certificate https://github.com/mfaerevaag/wd/raw/master/install.sh -O - | sh`
##### Arch ([AUR](https://aur.archlinux.org/))
# yaourt -S zsh-plugin-wd-git
#### Manual #### Manual
...@@ -48,7 +53,7 @@ Run either in terminal: ...@@ -48,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 utelize 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/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`:
fpath=(~/path/to/wd $fpath) fpath=(~/path/to/wd $fpath)
...@@ -66,7 +71,9 @@ Also, you may have to force a rebuild of `zcompdump` by running: ...@@ -66,7 +71,9 @@ Also, you may have to force a rebuild of `zcompdump` by running:
If a warp point with the same name exists, use `add!` to overwrite it. If a warp point with the same name exists, use `add!` to overwrite it.
Note, a warp point cannot contain colons, or only consist of only spaces and dots. The first will conflict in how `wd` stores the warp points, and the second will conflict other features, as below. Note, a warp point cannot contain colons, or only 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.
You can omit point name to use the current directory's name instead.
* From an other directory (not necessarily), warp to `foo` with: * From an other directory (not necessarily), warp to `foo` with:
...@@ -84,6 +91,8 @@ Also, you may have to force a rebuild of `zcompdump` by running: ...@@ -84,6 +91,8 @@ Also, you may have to force a rebuild of `zcompdump` by running:
$ wd rm foo $ wd rm foo
You can omit point name to use the current directory's name instead.
* List all warp points (stored in `~/.warprc`): * List all warp points (stored in `~/.warprc`):
$ wd list $ wd list
...@@ -143,8 +152,8 @@ The project is licensed under the [MIT-license](https://github.com/mfaerevaag/wd ...@@ -143,8 +152,8 @@ The project is licensed under the [MIT-license](https://github.com/mfaerevaag/wd
### Finally ### Finally
If you have issues, feedback or improvements, don't hesitate to report it or submit a pull-request. In the case of an issue, we would much appreciate if you would include a failing test in `test/tests.sh`. Explanation on how to run the tests, read the section "Testing" in this README. If you have issues, feedback or improvements, don't hesitate to report it or submit a pull-request. In the case of an issue, we would much appreciate if you would include a failing test in `test/tests.sh`. For an explanation on how to run the tests, read the section "Testing" in this README.
Credit to [altschuler](https://github.com/altschuler) for awesome idea. Credit to [altschuler](https://github.com/altschuler) for an awesome idea.
Hope you enjoy! Hope you enjoy!
...@@ -16,6 +16,19 @@ function _wd() { ...@@ -16,6 +16,19 @@ function _wd() {
warp_points=( "${(f)mapfile[$CONFIG]//$HOME/~}" ) warp_points=( "${(f)mapfile[$CONFIG]//$HOME/~}" )
typeset -A points
while read -r line
do
arr=(${(s,:,)line})
name=${arr[1]}
target_path=${arr[2]}
# replace ~ from path to fix completion (#17)
target_path=${target_path/#\~/$HOME}
points[$name]=$target_path
done < $CONFIG
commands=( commands=(
'add:Adds the current working directory to your warp points' 'add:Adds the current working directory to your warp points'
'add!:Overwrites existing warp point' 'add!:Overwrites existing warp point'
...@@ -34,13 +47,15 @@ function _wd() { ...@@ -34,13 +47,15 @@ function _wd() {
'1: :->first_arg' \ '1: :->first_arg' \
'2: :->second_arg' && ret=0 '2: :->second_arg' && ret=0
local target=$words[2]
case $state in case $state in
first_arg) first_arg)
_describe -t warp_points "Warp points" warp_points && ret=0 _describe -t warp_points "Warp points" warp_points && ret=0
_describe -t commands "Commands" commands && ret=0 _describe -t commands "Commands" commands && ret=0
;; ;;
second_arg) second_arg)
case $words[2] in case $target in
add\!|rm) add\!|rm)
_describe -t points "Warp points" warp_points && ret=0 _describe -t points "Warp points" warp_points && ret=0
;; ;;
...@@ -56,6 +71,10 @@ function _wd() { ...@@ -56,6 +71,10 @@ function _wd() {
path) path)
_describe -t points "Warp points" warp_points && ret=0 _describe -t points "Warp points" warp_points && ret=0
;; ;;
*)
# complete sub directories from the warp point
_path_files -W "(${points[$target]})" -/ && ret=0
;;
esac esac
;; ;;
esac esac
......
#!/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
}
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
# @github.com/mfaerevaag/wd # @github.com/mfaerevaag/wd
# version # version
readonly WD_VERSION=0.4.2 readonly WD_VERSION=0.4.6
# colors # colors
readonly WD_BLUE="\033[96m" readonly WD_BLUE="\033[96m"
...@@ -72,25 +72,28 @@ wd_print_msg() ...@@ -72,25 +72,28 @@ wd_print_msg()
wd_print_usage() wd_print_usage()
{ {
cat <<- EOF cat <<- EOF
Usage: wd [command] <point> Usage: wd [command] [point]
Commands: Commands:
add <point> Adds the current working directory to your warp points add <point> Adds the current working directory to your warp points
add! <point> Overwrites existing warp point add Adds the current working directory to your warp points with current directory's name
rm <point> Removes the given warp point add! <point> Overwrites existing warp point
show Print warp points to current directory add! Overwrites existing warp point with current directory's name
show <point> Print path to given warp point rm <point> Removes the given warp point
list Print all stored warp points rm Removes the given warp point with current directory's name
ls <point> Show files from given warp point show <point> Print path to given warp point
path <point> Show the path to given warp point show Print warp points to current directory
clean! Remove points warping to nonexistent directories list Print all stored warp points
ls <point> Show files from given warp point (ls)
-v | --version Print version path <point> Show the path to given warp point (pwd)
-d | --debug Exit after execution with exit codes (for testing) clean! Remove points warping to nonexistent directories
-c | --config Specify config file (default ~/.warprc)
-q | --quiet Suppress all output -v | --version Print version
-d | --debug Exit after execution with exit codes (for testing)
help Show this extremely helpful text -c | --config Specify config file (default ~/.warprc)
-q | --quiet Suppress all output
help Show this extremely helpful text
EOF EOF
} }
...@@ -131,10 +134,11 @@ wd_getdir() ...@@ -131,10 +134,11 @@ wd_getdir()
wd_warp() wd_warp()
{ {
local point=$1 local point=$1
local sub=$2
if [[ $point =~ "^\.+$" ]] if [[ $point =~ "^\.+$" ]]
then then
if [ $#1 < 2 ] if [[ $#1 < 2 ]]
then then
wd_exit_warn "Warping to current directory?" wd_exit_warn "Warping to current directory?"
else else
...@@ -143,7 +147,12 @@ wd_warp() ...@@ -143,7 +147,12 @@ wd_warp()
fi fi
elif [[ ${points[$point]} != "" ]] elif [[ ${points[$point]} != "" ]]
then then
cd ${points[$point]/#\~/$HOME} if [[ $sub != "" ]]
then
cd ${points[$point]/#\~/$HOME}/$sub
else
cd ${points[$point]/#\~/$HOME}
fi
else else
wd_exit_fail "Unknown warp point '${point}'" wd_exit_fail "Unknown warp point '${point}'"
fi fi
...@@ -154,6 +163,11 @@ wd_add() ...@@ -154,6 +163,11 @@ wd_add()
local force=$1 local force=$1
local point=$2 local point=$2
if [[ $point == "" ]]
then
point=$(basename $PWD)
fi
if [[ $point =~ "^[\.]+$" ]] if [[ $point =~ "^[\.]+$" ]]
then then
wd_exit_fail "Warp point cannot be just dots" wd_exit_fail "Warp point cannot be just dots"
...@@ -163,10 +177,7 @@ wd_add() ...@@ -163,10 +177,7 @@ wd_add()
elif [[ $point == *:* ]] elif [[ $point == *:* ]]
then then
wd_exit_fail "Warp point cannot contain colons" wd_exit_fail "Warp point cannot contain colons"
elif [[ $point == "" ]] elif [[ ${points[$point]} == "" ]] || $force
then
wd_exit_fail "Warp point cannot be empty"
elif [[ ${points[$2]} == "" ]] || $force
then then
wd_remove $point > /dev/null wd_remove $point > /dev/null
printf "%q:%s\n" "${point}" "${PWD/#$HOME/~}" >> $WD_CONFIG printf "%q:%s\n" "${point}" "${PWD/#$HOME/~}" >> $WD_CONFIG
...@@ -185,6 +196,11 @@ wd_remove() ...@@ -185,6 +196,11 @@ wd_remove()
{ {
local point=$1 local point=$1
if [[ $point == "" ]]
then
point=$(basename $PWD)
fi
if [[ ${points[$point]} != "" ]] if [[ ${points[$point]} != "" ]]
then then
local config_tmp=$WD_CONFIG.tmp local config_tmp=$WD_CONFIG.tmp
...@@ -294,7 +310,7 @@ wd_clean() { ...@@ -294,7 +310,7 @@ wd_clean() {
key=${arr[1]} key=${arr[1]}
val=${arr[2]} val=${arr[2]}
if [ -d "$val" ] if [ -d "${val/#\~/$HOME}" ]
then then
wd_tmp=$wd_tmp"\n"`echo $line` wd_tmp=$wd_tmp"\n"`echo $line`
else else
...@@ -356,7 +372,8 @@ while read -r line ...@@ -356,7 +372,8 @@ while read -r line
do do
arr=(${(s,:,)line}) arr=(${(s,:,)line})
key=${arr[1]} key=${arr[1]}
val=${arr[2]} # join the rest, in case the path contains colons
val=${(j,:,)arr[2,-1]}
points[$key]=$val points[$key]=$val
done < $WD_CONFIG done < $WD_CONFIG
...@@ -424,7 +441,7 @@ else ...@@ -424,7 +441,7 @@ else
break break
;; ;;
*) *)
wd_warp $o wd_warp $o $2
break break
;; ;;
--) --)
......
# web-search plugin
This plugin adds aliases for searching with Google, Wiki, Bing, YouTube and other popular services.
Open your `~/.zshrc` file and enable the `web-search` plugin:
```zsh
plugins=( ... web-search)
```
## Usage
You can use the `web-search` plugin in these two forms:
* `web_search <context> <term> [more terms if you want]`
* `<context> <term> [more terms if you want]`
For example, these two are equivalent:
```zsh
$ web_search google oh-my-zsh
$ google oh-my-zsh
```
Available search contexts are:
| Context | URL |
|-----------------------|------------------------------------------|
| `bing` | `https://www.bing.com/search?q=` |
| `google` | `https://www.google.com/search?q=` |
| `yahoo` | `https://search.yahoo.com/search?p=` |
| `ddg` or `duckduckgo` | `https://www.duckduckgo.com/?q=` |
| `sp` or `startpage` | `https://www.startpage.com/do/search?q=` |
| `yandex` | `https://yandex.ru/yandsearch?text=` |
| `github` | `https://github.com/search?q=` |
| `baidu` | `https://www.baidu.com/s?wd=` |
| `ecosia` | `https://www.ecosia.org/search?q=` |
| `goodreads` | `https://www.goodreads.com/search?q=` |
| `qwant` | `https://www.qwant.com/?q=` |
| `givero` | `https://www.givero.com/search?q=` |
| `stackoverflow` | `https://stackoverflow.com/search?q=` |
Also there are aliases for bang-searching DuckDuckGo:
| Context | Bang |
|-----------|-------|
| `wiki` | `!w` |
| `news` | `!n` |
| `youtube` | `!yt` |
| `map` | `!m` |
| `image` | `!i` |
| `ducky` | `!` |
...@@ -15,6 +15,10 @@ function web_search() { ...@@ -15,6 +15,10 @@ function web_search() {
github "https://github.com/search?q=" github "https://github.com/search?q="
baidu "https://www.baidu.com/s?wd=" baidu "https://www.baidu.com/s?wd="
ecosia "https://www.ecosia.org/search?q=" ecosia "https://www.ecosia.org/search?q="
goodreads "https://www.goodreads.com/search?q="
qwant "https://www.qwant.com/?q="
givero "https://www.givero.com/search?q="
stackoverflow "https://stackoverflow.com/search?q="
) )
# check whether the search engine is supported # check whether the search engine is supported
...@@ -47,6 +51,10 @@ alias yandex='web_search yandex' ...@@ -47,6 +51,10 @@ alias yandex='web_search yandex'
alias github='web_search github' alias github='web_search github'
alias baidu='web_search baidu' alias baidu='web_search baidu'
alias ecosia='web_search ecosia' alias ecosia='web_search ecosia'
alias goodreads='web_search goodreads'
alias qwant='web_search qwant'
alias givero='web_search givero'
alias stackoverflow='web_search stackoverflow'
#add your own !bang searches here #add your own !bang searches here
alias wiki='web_search duckduckgo \!w' alias wiki='web_search duckduckgo \!w'
......
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
**Maintainer:** [joshmedeski](https://github.com/joshmedeski) **Maintainer:** [joshmedeski](https://github.com/joshmedeski)
WordPress Command Line Interface (http://wp-cli.org/) WordPress Command Line Interface (https://wp-cli.org/)
WP-CLI is a set of command-line tools for managing WordPress installations. You can update plugins, set up multisite installs and much more, without using a web browser. WP-CLI is a set of command-line tools for managing WordPress installations. You can update plugins, set up multisite installs and much more, without using a web browser.
This plugin adds [tab completion](http://wp-cli.org/#complete) for `wp-cli` as well as several aliases. This plugin adds [tab completion](https://wp-cli.org/#tab-completions) for `wp-cli` as well as several aliases.
## List of Aliases ## List of Aliases
...@@ -75,7 +75,7 @@ This plugin adds [tab completion](http://wp-cli.org/#complete) for `wp-cli` as w ...@@ -75,7 +75,7 @@ This plugin adds [tab completion](http://wp-cli.org/#complete) for `wp-cli` as w
- wptp='wp theme path' - wptp='wp theme path'
- wpts='wp theme search' - wpts='wp theme search'
- wptst='wp theme status' - wptst='wp theme status'
- wptu='wp theme updatet' - wptu='wp theme update'
### User ### User
- wpuac='wp user add-cap' - wpuac='wp user add-cap'
...@@ -101,7 +101,7 @@ This plugin adds [tab completion](http://wp-cli.org/#complete) for `wp-cli` as w ...@@ -101,7 +101,7 @@ This plugin adds [tab completion](http://wp-cli.org/#complete) for `wp-cli` as w
- wpwm='wp widget move' - wpwm='wp widget move'
- wpwu='wp widget update' - wpwu='wp widget update'
The entire list of wp-cli commands can be found here: http://wp-cli.org/commands/ The entire list of wp-cli commands can be found here: https://wp-cli.org/commands/
I only included the commands that are most used. Please feel free to contribute to this project if you want more commands. I only included the commands that are most used. Please feel free to contribute to this project if you want more commands.
# WP-CLI # WP-CLI
# A command line interface for WordPress # A command line interface for WordPress
# http://wp-cli.org/ # https://wp-cli.org/
# Cache # Cache
...@@ -109,7 +109,7 @@ alias wptm='wp theme mod' ...@@ -109,7 +109,7 @@ alias wptm='wp theme mod'
alias wptp='wp theme path' alias wptp='wp theme path'
alias wpts='wp theme search' alias wpts='wp theme search'
alias wptst='wp theme status' alias wptst='wp theme status'
alias wptu='wp theme updatet' alias wptu='wp theme update'
# Transient # Transient
......
...@@ -19,7 +19,7 @@ plugins=(... xcode) ...@@ -19,7 +19,7 @@ plugins=(... xcode)
| xcdd | Purge all temporary build information | rm -rf ~/Library/Developer/Xcode/DerivedData/* | | xcdd | Purge all temporary build information | rm -rf ~/Library/Developer/Xcode/DerivedData/* |
| xcp | Show currently selected Xcode directory | xcode-select --print-path | | xcp | Show currently selected Xcode directory | xcode-select --print-path |
| xcsel | Select different Xcode directory by path | sudo xcode-select --switch | | xcsel | Select different Xcode directory by path | sudo xcode-select --switch |
| xx | Opens the files listed in Xcode | open -a "Xcode.app" |
## Functions ## Functions
...@@ -29,6 +29,10 @@ plugins=(... xcode) ...@@ -29,6 +29,10 @@ plugins=(... xcode)
Opens the current directory in Xcode as an Xcode project. This will open one of the `.xcworkspace` and `.xcodeproj` files that it can find in the current working directory. You can also specify a directory to look in for the Xcode files. Opens the current directory in Xcode as an Xcode project. This will open one of the `.xcworkspace` and `.xcodeproj` files that it can find in the current working directory. You can also specify a directory to look in for the Xcode files.
Returns 1 if it didn't find any relevant files. Returns 1 if it didn't find any relevant files.
### `xx`
Opens the files listed in Xcode, multiple files are opened in a multi-file browser.
### `simulator` ### `simulator`
Opens the iOS Simulator from your command line, dependent on whichever is the active developer directory for Xcode. (That is, it respects the `xcsel` setting.) Opens the iOS Simulator from your command line, dependent on whichever is the active developer directory for Xcode. (That is, it respects the `xcsel` setting.)
......
...@@ -4,7 +4,7 @@ alias xcp='xcode-select --print-path' ...@@ -4,7 +4,7 @@ alias xcp='xcode-select --print-path'
alias xcsel='sudo xcode-select --switch' alias xcsel='sudo xcode-select --switch'
# original author: @subdigital # original author: @subdigital
# source: http://gist.github.com/subdigital/5420709 # source: https://gist.github.com/subdigital/5420709
function xc { function xc {
local xcode_proj local xcode_proj
if [[ $# == 0 ]]; then if [[ $# == 0 ]]; then
...@@ -22,11 +22,25 @@ function xc { ...@@ -22,11 +22,25 @@ function xc {
fi fi
return 1 return 1
else else
echo "Found ${xcode_proj[1]}" local active_path
open "${xcode_proj[1]}" active_path=$(xcode-select -p)
active_path=${active_path%%/Contents/Developer*}
echo "Found ${xcode_proj[1]}. Opening with ${active_path}"
open -a "$active_path" "${xcode_proj[1]}"
fi fi
} }
# Opens a file or files in the Xcode IDE. Multiple files are opened in multi-file browser
# original author: @possen
function xx {
if [[ $# == 0 ]]; then
echo "Specify file(s) to open in xcode."
return 1
fi
echo "${xcode_files}"
open -a "Xcode.app" "$@"
}
# "XCode-SELect by Version" - select Xcode by just version number # "XCode-SELect by Version" - select Xcode by just version number
# Uses naming convention: # Uses naming convention:
# - different versions of Xcode are named Xcode-<version>.app or stored # - different versions of Xcode are named Xcode-<version>.app or stored
...@@ -70,7 +84,7 @@ function xcselv { ...@@ -70,7 +84,7 @@ function xcselv {
function _omz_xcode_print_xcselv_usage { function _omz_xcode_print_xcselv_usage {
cat << EOF >&2 cat << EOF >&2
Usage: Usage:
xcselv <version> xcselv <version>
xcselv [options] xcselv [options]
......
# Yarn plugin
This plugin adds completion for the [Yarn package manager](https://yarnpkg.com/en/),
as well as some aliases for common Yarn commands.
To use it, add `yarn` to the plugins array in your zshrc file:
```zsh
plugins=(... yarn)
```
## Aliases
| Alias | Command | Description |
|-------|-------------------------------------------|-------------------------------------------------------------|
| y | `yarn` | The Yarn command |
| ya | `yarn add` | Install a package in dependencies (`package.json`) |
| yad | `yarn add --dev` | Install a package in devDependencies (`package.json`) |
| yap | `yarn add --peer` | Install a package in peerDependencies (`package.json`) |
| yb | `yarn build` | Run the build script defined in `package.json` |
| 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 |
| ygls | `yarn global list` | Lists global installed packages |
| ygrm | `yarn global remove` | Remove global installed packages from your OS |
| ygu | `yarn global upgrade` | Upgrade packages installed globally to their latest version |
| yh | `yarn help` | Show help for a yarn command |
| yi | `yarn init` | Interactively creates or updates a package.json file |
| yin | `yarn install` | Install dependencies defined in `package.json` |
| yls | `yarn list` | List installed packages |
| yout | `yarn outdated` | Check for outdated package dependencies |
| yp | `yarn pack` | Create a compressed gzip archive of package dependencies |
| yrm | `yarn remove` | Remove installed packages |
| yrun | `yarn run` | Run a defined package script |
| ys | `yarn serve` | Start the dev server |
| yst | `yarn start` | Run the start 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 |
| yui | `yarn upgrade-interactive` | Prompt for which outdated packages to upgrade |
| 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. |
#compdef yarn
# ------------------------------------------------------------------------------
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the zsh-users nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# ------------------------------------------------------------------------------
# Description
# -----------
#
# Completion script for yarn (https://yarnpkg.com/)
#
# ------------------------------------------------------------------------------
# Authors
# -------
#
# * Massimiliano Torromeo <massimiliano.torromeo@gmail.com>
#
# ------------------------------------------------------------------------------
_commands=(
'access'
'autoclean:Clean and remove unnecessary files from package dependencies'
'cache:List or clean every cached package'
"check:Verify package dependencies agains yarn's lock file"
'config:Manages the yarn configuration files'
'generate-lock-entry:Generates a lock file entry'
'global:Install packages globally on your operating system'
'help:Show information about a command'
'import:Generate yarn.lock from an existing npm-installed node_modules folder'
'info:Show information about a package'
'init:Interactively creates or updates a package.json file'
'install:Install all the dependencies listed within package.json'
'licenses:List licenses for installed packages'
'link:Symlink a package folder during development'
'list:List installed packages'
'login:Store registry username and email'
'logout:Clear registry username and email'
'outdated:Check for outdated package dependencies'
'owner:Manage package owners'
'pack:Create a compressed gzip archive of package dependencies'
'publish:Publish a package to the npm registry'
'run:Run a defined package script'
'tag:Add, remove, or list tags on a package'
'team:Maintain team memberships'
'unlink:Unlink a previously created symlink for a package'
'version:Update the package version'
'versions:Display version information of currently installed Yarn, Node.js, and its dependencies'
'why:Show information about why a package is installed'
)
_global_commands=(
'add:Installs a package and any packages that it depends on'
'bin:Displays the location of the yarn bin folder'
'remove:Remove installed package from dependencies updating package.json'
'upgrade:Upgrades packages to their latest version based on the specified range'
'upgrade-interactive:Interactively upgrade packages'
)
_yarn_commands_scripts() {
local -a 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'))
_describe 'command or script' _commands -- _global_commands -- scripts
}
_yarn_scripts() {
local -a commands binaries scripts
local -a scriptNames scriptCommands
local i runJSON
runJSON=$(yarn run --json 2>/dev/null)
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() {
local -a cmds
cmds=('ls:List installed packages')
_describe 'command' _global_commands
}
_yarn_commands() {
_describe 'command' _commands -- _global_commands
}
_yarn() {
local context state state_descr line
typeset -A opt_args
_arguments \
'(-h --help)'{-h,--help}'[output usage information]' \
'(-V --version)'{-V,--version}'[output the version number]' \
'--verbose[output verbose messages on internal operations]' \
'--offline[trigger an error if any required dependencies are not available in local cache]' \
'--prefer-offline[use network only if dependencies are not available in local cache]' \
'--strict-semver' \
'--json' \
"--ignore-scripts[don't run lifecycle scripts]" \
'--har[save HAR output of network traffic]' \
'--ignore-platform[ignore platform checks]' \
'--ignore-engines[ignore engines check]' \
'--ignore-optional[ignore optional dependencies]' \
'--force[install and build packages even if they were built before, overwrite lockfile]' \
'--skip-integrity-check[run install without checking if node_modules is installed]' \
'--check-files[install will verify file tree of packages for consistency]' \
"--no-bin-links[don't generate bin links when setting up packages]" \
'--flat[only allow one version of a package]' \
'(--prod --production)'{--prod,--production} \
"--no-lockfile[don't read or generate a lockfile]" \
"--pure-lockfile[don't generate a lockfile]" \
"--frozen-lockfile[don't generate a lockfile and fail if an update is needed]" \
'--link-duplicates[create hardlinks to the repeated modules in node_modules]' \
'--global-folder=[modules folder]:folder:_files -/' \
'--modules-folder=[rather than installing modules into the node_modules folder relative to the cwd, output them here]:folder:_files -/' \
'--cache-folder=[specify a custom folder to store the yarn cache]:folder:_files -/' \
'--mutex=[use a mutex to ensure only one yarn instance is executing]:type[\:specifier]' \
'--no-emoji[disable emoji in output]' \
'(-s --silent)'{-s,--silent}'[skip Yarn console logs, other types of logs (script output) will be printed]' \
'--proxy=:host:_hosts' \
'--https-proxy=:host:_hosts' \
'--no-progress[disable progress bar]' \
'--network-concurrency=[maximum number of concurrent network requests]:number' \
'--network-timeout=[TCP timeout for network requests]:milliseconds' \
'--non-interactive[do not show interactive prompts]' \
'1: :_yarn_commands_scripts' \
'*:: :->command_args'
case $state in
command_args)
case $words[1] in
help)
_arguments \
'1: :_yarn_commands' \
;;
access)
_arguments \
'1: :(public restricted grant revoke ls-packages ls-collaborators edit)'
;;
add)
_arguments \
'(-D --dev)'{-D,--dev}'[install packages in devDependencies]' \
'(-P --peer)'{-P,--peer}'[install packages in peerDependencies]' \
'(-O --optional)'{-O,--optional}'[install packages in optionalDependencies]' \
'(-E --exact)'{-E,--exact}'[install packages as exact versions]' \
'(-T --tilde)'{-T,--tilde}'[install the most recent release of the packages that have the same minor version]' \
'*:package-name:'
;;
cache)
_arguments \
'1: :(ls dir clean)'
;;
check)
_arguments \
'--integrity' \
'--verify-tree'
;;
config)
_arguments \
'1: :(set get delete list)' \
'*:: :->config_args'
;;
global)
_arguments \
'--prefix=[bin prefix to use to install binaries]' \
'1: :_yarn_global_commands' \
'*:: :->command_args'
;;
info)
_arguments \
'1:package:' \
'2:field'
;;
init)
_arguments \
'(-y --yes)'{-y,--yes}'[install packages in devDependencies]'
;;
licenses)
_arguments \
'1: :(ls generate-disclaimer)' \
;;
link|unlink|outdated)
_arguments \
'1:package' \
;;
list)
_arguments \
'--depth[Limit the depth of the shown dependencies]:depth'
;;
owner)
_arguments \
'1: :(ls add rm)' \
'*:: :->owner_args'
;;
pack)
_arguments \
'(-f --filename)'{-f,--filename}':filename:_files'
;;
publish)
_arguments \
'--new-version:version:' \
'--message:message:' \
'--no-git-tag-version' \
'--access:access:' \
'--tag:tag:' \
'1: :_files'
;;
remove|upgrade)
_arguments \
'*:package:'
;;
run)
_arguments \
'1: :_yarn_scripts' \
'*:: :_default'
;;
tag)
_arguments \
'1: :(ls add rm)' \
'*:: :->tag_args'
;;
team)
_arguments \
'1: :(create destroy add rm ls)' \
'*:: :->team_args'
;;
upgrade-interactive)
_arguments \
'--latest:use the version tagged latest in the registry:'
;;
version)
_arguments \
'--new-version:version:' \
'--message:message:' \
'--no-git-tag-version'
;;
why)
_arguments \
'1:query:_files'
;;
*)
_default
;;
esac
;;
esac
case $state in
config_args)
case $words[1] in
get|delete)
_arguments \
'1:key:'
;;
set)
_arguments \
'(-g --global)'{-g,--global} \
'1:key:' \
'2:value:'
;;
esac
;;
owner_args)
case $words[1] in
ls)
_arguments \
'1:package:'
;;
add|rm)
_arguments \
'1:user:' \
'2:package:'
;;
esac
;;
tag_args)
case $words[1] in
ls)
_arguments \
'1:package'
;;
add|rm)
_arguments \
'1:package:' \
'2:tag:'
;;
esac
;;
team_args)
case $words[1] in
create|destroy|ls)
_arguments \
'1:scope\:team:'
;;
add|rm)
_arguments \
'1:scope\:team:' \
'2:user:'
;;
esac
;;
esac
}
_yarn "$@"
# Local Variables:
# mode: Shell-Script
# sh-indentation: 2
# indent-tabs-mode: nil
# sh-basic-offset: 2
# End:
# vim: ft=zsh sw=2 ts=2 et
alias y="yarn"
alias ya="yarn add"
alias yad="yarn add --dev"
alias yap="yarn add --peer"
alias yb="yarn build"
alias ycc="yarn cache clean"
alias yd="yarn dev"
alias yga="yarn global add"
alias ygls="yarn global list"
alias ygrm="yarn global remove"
alias ygu="yarn global upgrade"
alias yh="yarn help"
alias yi="yarn init"
alias yin="yarn install"
alias yls="yarn list"
alias yout="yarn outdated"
alias yp="yarn pack"
alias yrm="yarn remove"
alias yrun="yarn run"
alias ys="yarn serve"
alias yst="yarn start"
alias yt="yarn test"
alias ytc="yarn test --coverage"
alias yuc="yarn global upgrade && yarn cache clean"
alias yui="yarn upgrade-interactive"
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` |
# Yum plugin
This plugin adds useful aliases for common [Yum](http://yum.baseurl.org/) commands.
To use it, add `yum` to the plugins array in your zshrc file:
```
plugins=(... yum)
```
## Aliases
| Alias | Command | Description |
|-------|-----------------------------------|------------------------------|
| ys | `yum search` | Search package |
| yp | `yum info` | Show package info |
| yl | `yum list` | List packages |
| ygl | `yum grouplist` | List package groups |
| yli | `yum list installed` | Print all installed packages |
| ymc | `yum makecache` | Rebuild the yum package list |
| yu | `sudo yum update` | Upgrade packages |
| yi | `sudo yum install` | Install package |
| ygi | `sudo yum groupinstall` | Install package group |
| yr | `sudo yum remove` | Remove package |
| ygr | `sudo yum groupremove` | Remove pagage group |
| yrl | `sudo yum remove --remove-leaves` | Remove package and leaves |
| yc | `sudo yum clean all` | Clean yum cache |
...@@ -125,7 +125,7 @@ ENVIRONMENT ...@@ -125,7 +125,7 @@ ENVIRONMENT
Directories must be full paths without trailing slashes. Directories must be full paths without trailing slashes.
The environment variable $_Z_OWNER can be set to your username, to The environment variable $_Z_OWNER can be set to your username, to
allow usage of z when your sudo enviroment keeps $HOME set. allow usage of z when your sudo environment keeps $HOME set.
FILES FILES
Data is stored in $HOME/.z. This can be overridden by setting the Data is stored in $HOME/.z. This can be overridden by setting the
......
...@@ -22,6 +22,9 @@ OPTIONS ...@@ -22,6 +22,9 @@ OPTIONS
\fB\-c\fR \fB\-c\fR
restrict matches to subdirectories of the current directory restrict matches to subdirectories of the current directory
.TP .TP
\fB\-e\fR
echo the best match, don't cd
.TP
\fB\-h\fR \fB\-h\fR
show a brief help message show a brief help message
.TP .TP
...@@ -90,7 +93,8 @@ Set \fB$_Z_OWNER\fR to allow usage when in 'sudo -s' mode. ...@@ -90,7 +93,8 @@ Set \fB$_Z_OWNER\fR to allow usage when in 'sudo -s' mode.
(These settings should go in .bashrc/.zshrc before the line added above.) (These settings should go in .bashrc/.zshrc before the line added above.)
.RE .RE
.RS .RS
Install the provided man page \fBz.1\fR somewhere like \fB/usr/local/man/man1\fR. Install the provided man page \fBz.1\fR somewhere in your \f$MANPATH, like
\fB/usr/local/man/man1\fR.
.RE .RE
.SS .SS
Aging: Aging:
...@@ -151,7 +155,7 @@ directory trees to exclude from tracking. \fB$HOME\fR is always excluded. ...@@ -151,7 +155,7 @@ directory trees to exclude from tracking. \fB$HOME\fR is always excluded.
Directories must be full paths without trailing slashes. Directories must be full paths without trailing slashes.
.P .P
The environment variable \fB$_Z_OWNER\fR can be set to your username, to The environment variable \fB$_Z_OWNER\fR can be set to your username, to
allow usage of \fBz\fR when your sudo enviroment keeps \fB$HOME\fR set. allow usage of \fBz\fR when your sudo environment keeps \fB$HOME\fR set.
.SH .SH
FILES FILES
Data is stored in \fB$HOME/.z\fR. This can be overridden by setting the Data is stored in \fB$HOME/.z\fR. This can be overridden by setting the
......
# Copyright (c) 2009 rupa deadwyler under the WTFPL license # Copyright (c) 2009 rupa deadwyler. Licensed under the WTFPL license, Version 2
# maintains a jump-list of the directories you actually use # maintains a jump-list of the directories you actually use
# #
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
# * z -r foo # cd to highest ranked dir matching foo # * z -r foo # cd to highest ranked dir matching foo
# * z -t foo # cd to most recently accessed dir matching foo # * z -t foo # cd to most recently accessed dir matching foo
# * z -l foo # list matches instead of cd # * z -l foo # list matches instead of cd
# * z -e foo # echo the best match, don't cd
# * z -c foo # restrict matches to subdirs of $PWD # * z -c foo # restrict matches to subdirs of $PWD
[ -d "${_Z_DATA:-$HOME/.z}" ] && { [ -d "${_Z_DATA:-$HOME/.z}" ] && {
...@@ -31,9 +32,21 @@ _z() { ...@@ -31,9 +32,21 @@ _z() {
local datafile="${_Z_DATA:-$HOME/.z}" local datafile="${_Z_DATA:-$HOME/.z}"
# if symlink, dereference
[ -h "$datafile" ] && datafile=$(readlink "$datafile")
# bail if we don't own ~/.z and $_Z_OWNER not set # bail if we don't own ~/.z and $_Z_OWNER not set
[ -z "$_Z_OWNER" -a -f "$datafile" -a ! -O "$datafile" ] && return [ -z "$_Z_OWNER" -a -f "$datafile" -a ! -O "$datafile" ] && return
_z_dirs () {
local line
while read line; do
# only count directories
[ -d "${line%%\|*}" ] && echo "$line"
done < "$datafile"
return 0
}
# add entries # add entries
if [ "$1" = "--add" ]; then if [ "$1" = "--add" ]; then
shift shift
...@@ -49,10 +62,7 @@ _z() { ...@@ -49,10 +62,7 @@ _z() {
# maintain the data file # maintain the data file
local tempfile="$datafile.$RANDOM" local tempfile="$datafile.$RANDOM"
while read line; do _z_dirs | awk -v path="$*" -v now="$(date +%s)" -F"|" '
# only count directories
[ -d "${line%%\|*}" ] && echo $line
done < "$datafile" | awk -v path="$*" -v now="$(date +%s)" -F"|" '
BEGIN { BEGIN {
rank[path] = 1 rank[path] = 1
time[path] = now time[path] = now
...@@ -75,60 +85,58 @@ _z() { ...@@ -75,60 +85,58 @@ _z() {
} else for( x in rank ) print x "|" rank[x] "|" time[x] } else for( x in rank ) print x "|" rank[x] "|" time[x]
} }
' 2>/dev/null >| "$tempfile" ' 2>/dev/null >| "$tempfile"
# do our best to avoid clobbering the datafile in a race condition # do our best to avoid clobbering the datafile in a race condition.
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
# tab completion # tab completion
elif [ "$1" = "--complete" -a -s "$datafile" ]; then elif [ "$1" = "--complete" -a -s "$datafile" ]; then
while read line; do _z_dirs | awk -v q="$2" -F"|" '
[ -d "${line%%\|*}" ] && echo $line
done < "$datafile" | awk -v q="$2" -F"|" '
BEGIN { BEGIN {
if( q == tolower(q) ) imatch = 1
q = substr(q, 3) q = substr(q, 3)
gsub(" ", ".*", q) if( q == tolower(q) ) imatch = 1
gsub(/ /, ".*", q)
} }
{ {
if( imatch ) { if( imatch ) {
if( tolower($1) ~ tolower(q) ) print $1 if( tolower($1) ~ q ) print $1
} else if( $1 ~ q ) print $1 } else if( $1 ~ q ) print $1
} }
' 2>/dev/null ' 2>/dev/null
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";;
h) echo "${_Z_CMD:-z} [-chlrtx] args" >&2; return;; e) echo=1;;
h) echo "${_Z_CMD:-z} [-cehlrtx] args" >&2; return;;
l) list=1;;
r) typ="rank";;
t) typ="recent";;
x) sed -i -e "\:^${PWD}|.*:d" "$datafile";; x) sed -i -e "\:^${PWD}|.*:d" "$datafile";;
l) local list=1;;
r) local typ="rank";;
t) local typ="recent";;
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
# completions will always start with / # completions will always start with /
/*) [ -z "$list" -a -d "$last" ] && cd "$last" && return;; /*) [ -z "$list" -a -d "$last" ] && builtin cd "$last" && return;;
esac esac
# no file yet # no file yet
[ -f "$datafile" ] || return [ -f "$datafile" ] || return
local cd local cd
cd="$(while read line; do cd="$( < <( _z_dirs ) awk -v t="$(date +%s)" -v list="$list" -v typ="$typ" -v q="$fnd" -F"|" '
[ -d "${line%%\|*}" ] && echo $line
done < "$datafile" | awk -v t="$(date +%s)" -v list="$list" -v typ="$typ" -v q="$fnd" -F"|" '
function frecent(rank, time) { function frecent(rank, time) {
# relate frequency and time # relate frequency and time
dx = t - time dx = t - time
...@@ -137,19 +145,21 @@ _z() { ...@@ -137,19 +145,21 @@ _z() {
if( dx < 604800 ) return rank / 2 if( dx < 604800 ) return rank / 2
return rank / 4 return rank / 4
} }
function output(files, out, 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 files ) { for( x in matches ) {
if( files[x] ) printf "%-10s %s\n", files[x], x | cmd if( matches[x] ) {
printf "%-10s %s\n", matches[x], x | cmd
}
} }
if( common ) { if( common ) {
printf "%-10s %s\n", "common:", common > "/dev/stderr" printf "%-10s %s\n", "common:", common > "/dev/stderr"
} }
} else { } else {
if( common ) out = common if( common ) best_match = common
print out print best_match
} }
} }
function common(matches) { function common(matches) {
...@@ -160,11 +170,9 @@ _z() { ...@@ -160,11 +170,9 @@ _z() {
} }
} }
if( short == "/" ) return if( short == "/" ) return
# use a copy to escape special characters, as we want to return for( x in matches ) if( matches[x] && index(x, short) != 1 ) {
# the original. yeah, this escaping is awful. return
clean_short = short }
gsub(/\[\(\)\[\]\|\]/, "\\\\&", clean_short)
for( x in matches ) if( matches[x] && x !~ clean_short ) return
return short return short
} }
BEGIN { BEGIN {
...@@ -197,8 +205,10 @@ _z() { ...@@ -197,8 +205,10 @@ _z() {
} }
} }
')" ')"
[ $? -gt 0 ] && return
[ "$cd" ] && cd "$cd" [ $? -eq 0 ] && [ "$cd" ] && {
if [ "$echo" ]; then echo "$cd"; else builtin cd "$cd"; fi
}
fi fi
} }
...@@ -212,11 +222,17 @@ if type compctl >/dev/null 2>&1; then ...@@ -212,11 +222,17 @@ if type compctl >/dev/null 2>&1; then
# populate directory list, avoid clobbering any other precmds. # populate directory list, avoid clobbering any other precmds.
if [ "$_Z_NO_RESOLVE_SYMLINKS" ]; then if [ "$_Z_NO_RESOLVE_SYMLINKS" ]; then
_z_precmd() { _z_precmd() {
_z --add "${PWD:a}" (_z --add "${PWD:a}" &)
# Reference $RANDOM to refresh its value inside the subshell
# Otherwise, multiple runs get the same value
: $RANDOM
} }
else else
_z_precmd() { _z_precmd() {
_z --add "${PWD:A}" (_z --add "${PWD:A}" &)
# Reference $RANDOM to refresh its value inside the subshell
# Otherwise, multiple runs get the same value
: $RANDOM
} }
fi fi
[[ -n "${precmd_functions[(r)_z_precmd]}" ]] || { [[ -n "${precmd_functions[(r)_z_precmd]}" ]] || {
...@@ -237,7 +253,7 @@ elif type complete >/dev/null 2>&1; then ...@@ -237,7 +253,7 @@ elif type complete >/dev/null 2>&1; then
[ "$_Z_NO_PROMPT_COMMAND" ] || { [ "$_Z_NO_PROMPT_COMMAND" ] || {
# populate directory list. avoid clobbering other PROMPT_COMMANDs. # populate directory list. avoid clobbering other PROMPT_COMMANDs.
grep "_z --add" <<< "$PROMPT_COMMAND" >/dev/null || { grep "_z --add" <<< "$PROMPT_COMMAND" >/dev/null || {
PROMPT_COMMAND="$PROMPT_COMMAND"$'\n''_z --add "$(command pwd '$_Z_RESOLVE_SYMLINKS' 2>/dev/null)" 2>/dev/null;' PROMPT_COMMAND="$PROMPT_COMMAND"$'\n''(_z --add "$(command pwd '$_Z_RESOLVE_SYMLINKS' 2>/dev/null)" 2>/dev/null &);'
} }
} }
fi fi
...@@ -2,33 +2,97 @@ ...@@ -2,33 +2,97 @@
#autoload #autoload
# in order to make this work, you will need to have the gem zeus installed # in order to make this work, you will need to have the gem zeus installed
# zeus zsh completion
# zeus zsh completion, based on adb completion
local -a _1st_arguments local -a _1st_arguments
_1st_arguments=( if [[ -e .zeus.sock ]]; then
'console:Lets you interact with your Rails application from the command line. (alias = c)' _1st_arguments=(
'cucumber:Runs cucumber.' 'console:Lets you interact with your Rails application from the command line. (alias = c)'
'dbconsole:Figures out which database you are using and drops you into whichever command line interface.' 'cucumber:Runs cucumber.'
'destroy:Figures out what generate did, and undoes it. (alias = d)' 'dbconsole:Figures out which database you are using and drops you into whichever command line interface.'
'generate:Uses templates to create a whole lot of things. (alias = g)' 'destroy:Figures out what generate did, and undoes it. (alias = d)'
'rake:Execute rake tasks.' 'generate:Uses templates to create a whole lot of things. (alias = g)'
'runner:Runs Ruby code in the context of Rails non-interactively. (alias = r)' 'rake:Execute rake tasks.'
'server:Launches a small web server named WEBrick which comes bundled with Ruby. (alias = s)' 'runner:Runs Ruby code in the context of Rails non-interactively. (alias = r)'
'start:Preloads the zeus environment' 'server:Launches a small web server named WEBrick which comes bundled with Ruby. (alias = s)'
'test:Runs RSpec tests. (alias = rspec, testrb)' 'test:Runs RSpec tests. (alias = rspec, testrb)'
'version:Shows the version number.' 'version:Shows the version number.'
) )
else
_1st_arguments=(
'start:Preloads the zeus environment'
'init:Generate a zeus.json file'
)
fi
_rails_generate_arguments() {
generate_arguments=(
controller
generator
helper
integration_test
mailer
migration
model
observer
performance_test
plugin
resource
scaffold
scaffold_controller
session_migration
stylesheets
)
}
_rake_does_task_list_need_generating () {
if [ ! -f .rake_tasks ]; then return 0;
else
accurate=$(stat -f%m .rake_tasks)
changed=$(stat -f%m Rakefile)
return $(expr $accurate '>=' $changed)
fi
}
_zrake ()
{
local expl
declare -a tasks
if [ -f Rakefile ]; then
if _rake_does_task_list_need_generating; then
echo "\nGenerating .rake_tasks..." > /dev/stderr
rake --silent --tasks | cut -d " " -f 2 > .rake_tasks
fi
tasks=(`cat .rake_tasks`)
_wanted tasks expl 'rake' compadd $tasks
fi
}
local expl local expl
local -a pkgs installed_pkgs local curcontext="$curcontext" state line
typeset -A opt_args
_arguments \ _arguments -C \
'*:: :->subcmds' && return 0 ':command:->command' \
'*::options:->options'
if (( CURRENT == 1 )); then
_describe -t commands "zeus subcommand" _1st_arguments
return
fi
_files case $state in
(command)
_describe -t commands "zeus subcommand" _1st_arguments
return
;;
(options)
case $line[1] in
(rake)
_zrake
;;
(generate|g|destroy|d)
_rails_generate_arguments
_wanted generate_arguments expl 'all generate' compadd -a generate_arguments
;;
esac
;;
esac
...@@ -27,7 +27,7 @@ GPLv3 License ...@@ -27,7 +27,7 @@ GPLv3 License
GNU GENERAL PUBLIC LICENSE GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007 Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed. of this license document, but changing it is not allowed.
...@@ -671,7 +671,7 @@ the "copyright" line and a pointer to where the full notice is found. ...@@ -671,7 +671,7 @@ the "copyright" line and a pointer to where the full notice is found.
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail. Also add information on how to contact you by electronic and paper mail.
...@@ -690,11 +690,11 @@ might be different; for a GUI interface, you would use an "about box". ...@@ -690,11 +690,11 @@ might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school, You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary. if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>. <https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>. <https://www.gnu.org/philosophy/why-not-lgpl.html>.
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