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

Merge branch 'master' into master

parents afb02876 ebc700be
......@@ -6,7 +6,7 @@ function vundle-init () {
if [ ! -d ~/.vim/bundle/Vundle.vim/.git ] && [ ! -f ~/.vim/bundle/Vundle.vim/.git ]
then
git clone git://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
echo "\n\tRead about vim configuration for vundle at https://github.com/VundleVim/Vundle.vim\n"
fi
}
......
File mode changed from 100755 to 100644
# 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` | `!` |
......@@ -16,6 +16,9 @@ function web_search() {
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="
)
# check whether the search engine is supported
......@@ -49,6 +52,9 @@ alias github='web_search github'
alias baidu='web_search baidu'
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
alias wiki='web_search duckduckgo \!w'
......
......@@ -2,11 +2,11 @@
**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.
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
......@@ -75,7 +75,7 @@ This plugin adds [tab completion](http://wp-cli.org/#complete) for `wp-cli` as w
- wptp='wp theme path'
- wpts='wp theme search'
- wptst='wp theme status'
- wptu='wp theme updatet'
- wptu='wp theme update'
### User
- wpuac='wp user add-cap'
......@@ -101,7 +101,7 @@ This plugin adds [tab completion](http://wp-cli.org/#complete) for `wp-cli` as w
- wpwm='wp widget move'
- 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.
# WP-CLI
# A command line interface for WordPress
# http://wp-cli.org/
# https://wp-cli.org/
# Cache
......@@ -109,7 +109,7 @@ alias wptm='wp theme mod'
alias wptp='wp theme path'
alias wpts='wp theme search'
alias wptst='wp theme status'
alias wptu='wp theme updatet'
alias wptu='wp theme update'
# Transient
......
......@@ -19,7 +19,7 @@ plugins=(... xcode)
| xcdd | Purge all temporary build information | rm -rf ~/Library/Developer/Xcode/DerivedData/* |
| xcp | Show currently selected Xcode directory | xcode-select --print-path |
| xcsel | Select different Xcode directory by path | sudo xcode-select --switch |
| xx | Opens the files listed in Xcode | open -a "Xcode.app" |
## Functions
......@@ -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.
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`
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'
alias xcsel='sudo xcode-select --switch'
# original author: @subdigital
# source: http://gist.github.com/subdigital/5420709
# source: https://gist.github.com/subdigital/5420709
function xc {
local xcode_proj
if [[ $# == 0 ]]; then
......@@ -22,11 +22,25 @@ function xc {
fi
return 1
else
echo "Found ${xcode_proj[1]}"
open "${xcode_proj[1]}"
local active_path
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
}
# 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
# Uses naming convention:
# - different versions of Xcode are named Xcode-<version>.app or stored
......@@ -70,7 +84,7 @@ function xcselv {
function _omz_xcode_print_xcselv_usage {
cat << EOF >&2
Usage:
Usage:
xcselv <version>
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 |
| 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` |
| 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 |
#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'
)
_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 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 'script' scripts
}
_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'
;;
tag)
_arguments \
'1: :(ls add rm)' \
'*:: :->tag_args'
;;
team)
_arguments \
'1: :(create destroy add rm ls)' \
'*:: :->team_args'
;;
version)
_arguments \
'--new-version:version:' \
'--message:message:' \
'--no-git-tag-version'
;;
why)
_arguments \
'1:query:_files'
;;
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 sorted alphabetically
alias y="yarn "
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 yga="yarn global add"
alias ygls="yarn global list"
alias ygrm="yarn global remove"
alias ygu="yarn global upgrade"
alias yh="yarn help"
alias yo="yarn outdated"
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 yuc="yarn global upgrade && yarn cache clean"
alias yui="yarn upgrade-interactive"
_yarn ()
{
local -a _1st_arguments _dopts _dev _production
local expl
typeset -A opt_args
_dopts=(
'(--force)--force[This refetches all packages, even ones that were previously installed.]'
)
_installopts=(
'(--flat)--flat[Only allow one version of a package. On the first run this will prompt you to choose a single version for each package that is depended on at multiple version ranges.]'
'(--har)--har[Outputs an HTTP archive from all the network requests performed during the installation.]'
'(--no-lockfile)--no-lockfile[Don’t read or generate a yarn.lock lockfile.]'
'(--pure-lockfile)--pure-lockfile[Don’t generate a yarn.lock lockfile.]'
)
_dev=('(--dev)--dev[Save installed packages into the project"s package.json devDependencies]')
_production=('(--production)--production[Do not install project devDependencies]')
_1st_arguments=(
'help:Display help information about yarn' \
'init:Initialize for the development of a package.' \
'add:Add a package to use in your current package.' \
'install:Install all the dependencies listed within package.json in the local node_modules folder.' \
'publish:Publish a package to a package manager.' \
'remove:Remove a package that will no longer be used in your current package.' \
'cache:Clear the local cache. It will be populated again the next time yarn or yarn install is run.' \
'clean:Frees up space by removing unnecessary files and folders from dependencies.' \
'check:Verifies that versions of the package dependencies in the current project’s package.json matches that of yarn’s lock file.' \
'ls:List all installed packages.' \
'global:Makes binaries available to use on your operating system.' \
'info:<package> [<field>] - fetch information about a package and return it in a tree format.' \
'outdated:Checks for outdated package dependencies.' \
'run:Runs a defined package script.' \
'self-update:Updates Yarn to the latest version.' \
'upgrade:Upgrades packages to their latest version based on the specified range.' \
'why:<query> - Show information about why a package is installed.'
)
_arguments \
'*:: :->subcmds' && return 0
if (( CURRENT == 1 )); then
_describe -t commands "yarn subcommand" _1st_arguments
return
fi
case "$words[1]" in
add)
_arguments \
$_dopts \
$_dev \
$_production
;;
install)
_arguments \
$_installopts \
$_dopts \
$_dev \
$_no_color \
$_production
;;
update)
_arguments \
$_dopts
;;
remove)
_arguments \
$_dopts
;;
*)
_arguments \
;;
esac
}
compdef _yarn yarn
alias yup="yarn upgrade"
# 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 |
......@@ -22,6 +22,9 @@ OPTIONS
\fB\-c\fR
restrict matches to subdirectories of the current directory
.TP
\fB\-e\fR
echo the best match, don't cd
.TP
\fB\-h\fR
show a brief help message
.TP
......@@ -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.)
.RE
.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
.SS
Aging:
......
# 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
#
......@@ -21,6 +21,7 @@
# * z -r foo # cd to highest ranked dir matching foo
# * z -t foo # cd to most recently accessed dir matching foo
# * 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
[ -d "${_Z_DATA:-$HOME/.z}" ] && {
......@@ -31,9 +32,21 @@ _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
[ -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
if [ "$1" = "--add" ]; then
shift
......@@ -49,10 +62,7 @@ _z() {
# maintain the data file
local tempfile="$datafile.$RANDOM"
while read line; do
# only count directories
[ -d "${line%%\|*}" ] && echo $line
done < "$datafile" | awk -v path="$*" -v now="$(date +%s)" -F"|" '
_z_dirs | awk -v path="$*" -v now="$(date +%s)" -F"|" '
BEGIN {
rank[path] = 1
time[path] = now
......@@ -75,7 +85,7 @@ _z() {
} else for( x in rank ) print x "|" rank[x] "|" time[x]
}
' 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
env rm -f "$tempfile"
else
......@@ -85,17 +95,15 @@ _z() {
# tab completion
elif [ "$1" = "--complete" -a -s "$datafile" ]; then
while read line; do
[ -d "${line%%\|*}" ] && echo $line
done < "$datafile" | awk -v q="$2" -F"|" '
_z_dirs | awk -v q="$2" -F"|" '
BEGIN {
if( q == tolower(q) ) imatch = 1
q = substr(q, 3)
gsub(" ", ".*", q)
if( q == tolower(q) ) imatch = 1
gsub(/ /, ".*", q)
}
{
if( imatch ) {
if( tolower($1) ~ tolower(q) ) print $1
if( tolower($1) ~ q ) print $1
} else if( $1 ~ q ) print $1
}
' 2>/dev/null
......@@ -106,11 +114,12 @@ _z() {
--) while [ "$1" ]; do shift; local fnd="$fnd${fnd:+ }$1";done;;
-*) local opt=${1:1}; while [ "$opt" ]; do case ${opt:0:1} in
c) local fnd="^$PWD $fnd";;
h) echo "${_Z_CMD:-z} [-chlrtx] args" >&2; return;;
x) sed -i -e "\:^${PWD}|.*:d" "$datafile";;
e) local echo=1;;
h) echo "${_Z_CMD:-z} [-cehlrtx] args" >&2; return;;
l) local list=1;;
r) local typ="rank";;
t) local typ="recent";;
x) sed -i -e "\:^${PWD}|.*:d" "$datafile";;
esac; opt=${opt:1}; done;;
*) local fnd="$fnd${fnd:+ }$1";;
esac; local last=$1; [ "$#" -gt 0 ] && shift; done
......@@ -119,16 +128,14 @@ _z() {
# if we hit enter on a completion just go there
case "$last" in
# completions will always start with /
/*) [ -z "$list" -a -d "$last" ] && cd "$last" && return;;
/*) [ -z "$list" -a -d "$last" ] && builtin cd "$last" && return;;
esac
# no file yet
[ -f "$datafile" ] || return
local cd
cd="$(while read line; do
[ -d "${line%%\|*}" ] && echo $line
done < "$datafile" | awk -v t="$(date +%s)" -v list="$list" -v typ="$typ" -v q="$fnd" -F"|" '
cd="$( < <( _z_dirs ) awk -v t="$(date +%s)" -v list="$list" -v typ="$typ" -v q="$fnd" -F"|" '
function frecent(rank, time) {
# relate frequency and time
dx = t - time
......@@ -137,19 +144,21 @@ _z() {
if( dx < 604800 ) return rank / 2
return rank / 4
}
function output(files, out, common) {
function output(matches, best_match, common) {
# list or return the desired directory
if( list ) {
cmd = "sort -n >&2"
for( x in files ) {
if( files[x] ) printf "%-10s %s\n", files[x], x | cmd
for( x in matches ) {
if( matches[x] ) {
printf "%-10s %s\n", matches[x], x | cmd
}
}
if( common ) {
printf "%-10s %s\n", "common:", common > "/dev/stderr"
}
} else {
if( common ) out = common
print out
if( common ) best_match = common
print best_match
}
}
function common(matches) {
......@@ -160,11 +169,9 @@ _z() {
}
}
if( short == "/" ) return
# use a copy to escape special characters, as we want to return
# the original. yeah, this escaping is awful.
clean_short = short
gsub(/\[\(\)\[\]\|\]/, "\\\\&", clean_short)
for( x in matches ) if( matches[x] && x !~ clean_short ) return
for( x in matches ) if( matches[x] && index(x, short) != 1 ) {
return
}
return short
}
BEGIN {
......@@ -197,8 +204,10 @@ _z() {
}
}
')"
[ $? -gt 0 ] && return
[ "$cd" ] && cd "$cd"
[ $? -eq 0 ] && [ "$cd" ] && {
if [ "$echo" ]; then echo "$cd"; else builtin cd "$cd"; fi
}
fi
}
......@@ -212,11 +221,17 @@ if type compctl >/dev/null 2>&1; then
# populate directory list, avoid clobbering any other precmds.
if [ "$_Z_NO_RESOLVE_SYMLINKS" ]; then
_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
_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
[[ -n "${precmd_functions[(r)_z_precmd]}" ]] || {
......@@ -237,7 +252,7 @@ elif type complete >/dev/null 2>&1; then
[ "$_Z_NO_PROMPT_COMMAND" ] || {
# populate directory list. avoid clobbering other PROMPT_COMMANDs.
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
......@@ -2,33 +2,97 @@
#autoload
# in order to make this work, you will need to have the gem zeus installed
# zeus zsh completion, based on adb completion
# zeus zsh completion
local -a _1st_arguments
_1st_arguments=(
'console:Lets you interact with your Rails application from the command line. (alias = c)'
'cucumber:Runs cucumber.'
'dbconsole:Figures out which database you are using and drops you into whichever command line interface.'
'destroy:Figures out what generate did, and undoes it. (alias = d)'
'generate:Uses templates to create a whole lot of things. (alias = g)'
'rake:Execute rake tasks.'
'runner:Runs Ruby code in the context of Rails non-interactively. (alias = r)'
'server:Launches a small web server named WEBrick which comes bundled with Ruby. (alias = s)'
'start:Preloads the zeus environment'
'test:Runs RSpec tests. (alias = rspec, testrb)'
'version:Shows the version number.'
)
if [[ -e .zeus.sock ]]; then
_1st_arguments=(
'console:Lets you interact with your Rails application from the command line. (alias = c)'
'cucumber:Runs cucumber.'
'dbconsole:Figures out which database you are using and drops you into whichever command line interface.'
'destroy:Figures out what generate did, and undoes it. (alias = d)'
'generate:Uses templates to create a whole lot of things. (alias = g)'
'rake:Execute rake tasks.'
'runner:Runs Ruby code in the context of Rails non-interactively. (alias = r)'
'server:Launches a small web server named WEBrick which comes bundled with Ruby. (alias = s)'
'test:Runs RSpec tests. (alias = rspec, testrb)'
'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 -a pkgs installed_pkgs
local curcontext="$curcontext" state line
typeset -A opt_args
_arguments \
'*:: :->subcmds' && return 0
_arguments -C \
':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
GNU GENERAL PUBLIC LICENSE
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
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.
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, 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.
......@@ -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,
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
<http://www.gnu.org/licenses/>.
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
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
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>.
File mode changed from 100755 to 100644
# zsh_reload plugin
The zsh_reload plugin defines a function to reload the zsh session with
just a few keystrokes.
To use it, add `zsh_reload` to the plugins array in your zshrc file:
```zsh
plugins=(... zsh_reload)
```
## Usage
To reload the zsh session, just run `src`:
```zsh
$ vim ~/.zshrc # enabled a plugin
$ src
re-compiling /home/user/.zshrc.zwc: succeeded
re-compiling /home/user/.oh-my-zsh/cache/zcomp-host.zwc: succeeded
# you now have a fresh zsh session. happy hacking!
```
# reload zshrc
function src()
{
local cache=$ZSH_CACHE_DIR
autoload -U compinit zrecompile
compinit -d "$cache/zcomp-$HOST"
src() {
local cache="$ZSH_CACHE_DIR"
autoload -U compinit zrecompile
compinit -i -d "$cache/zcomp-$HOST"
for f in ~/.zshrc "$cache/zcomp-$HOST"; do
zrecompile -p $f && command rm -f $f.zwc.old
done
for f in ~/.zshrc "$cache/zcomp-$HOST"; do
zrecompile -p $f && command rm -f $f.zwc.old
done
source ~/.zshrc
# Use $SHELL if available; remove leading dash if login shell
[[ -n "$SHELL" ]] && exec ${SHELL#-} || exec zsh
}
......@@ -4,28 +4,31 @@
# Path to your oh-my-zsh installation.
export ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load. Optionally, if you set this to "random"
# it'll load a random theme each time that oh-my-zsh is loaded.
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
ZSH_THEME="robbyrussell"
# Set list of themes to load
# Setting this variable when ZSH_THEME=random
# cause zsh load theme from this variable instead of
# looking in ~/.oh-my-zsh/themes/
# An empty array have no effect
# Set list of themes to pick from when loading at random
# Setting this variable when ZSH_THEME=random will cause zsh to load
# a theme from this variable instead of looking in ~/.oh-my-zsh/themes/
# If set to an empty array, this variable will have no effect.
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )
# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"
# Uncomment the following line to use hyphen-insensitive completion. Case
# sensitive completion must be off. _ and - will be interchangeable.
# Uncomment the following line to use hyphen-insensitive completion.
# Case-sensitive completion must be off. _ and - will be interchangeable.
# HYPHEN_INSENSITIVE="true"
# Uncomment the following line to disable bi-weekly auto-update checks.
# DISABLE_AUTO_UPDATE="true"
# Uncomment the following line to automatically update without prompting.
# DISABLE_UPDATE_PROMPT="true"
# Uncomment the following line to change how often to auto-update (in days).
# export UPDATE_ZSH_DAYS=13
......@@ -48,19 +51,21 @@ ZSH_THEME="robbyrussell"
# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# You can set one of the optional three formats:
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# or set a custom format using the strftime function format specifications,
# see 'man strftime' for details.
# HIST_STAMPS="mm/dd/yyyy"
# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Which plugins would you like to load?
# Standard plugins can be found in ~/.oh-my-zsh/plugins/*
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(
git
)
plugins=(git)
source $ZSH/oh-my-zsh.sh
......@@ -81,9 +86,6 @@ source $ZSH/oh-my-zsh.sh
# Compilation flags
# export ARCHFLAGS="-arch x86_64"
# ssh
# export SSH_KEY_PATH="~/.ssh/rsa_id"
# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
......
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