Merge remote-tracking branch 'upstream/master' into zsh_update_dir

This commit is contained in:
Alexandr Kozlinskiy 2016-10-12 09:40:07 +02:00
commit 2b86e174f6
68 changed files with 3953 additions and 969 deletions

View File

@ -2,9 +2,15 @@
<img src="https://s3.amazonaws.com/ohmyzsh/oh-my-zsh-logo.png" alt="Oh My Zsh"> <img src="https://s3.amazonaws.com/ohmyzsh/oh-my-zsh-logo.png" alt="Oh My Zsh">
</p> </p>
Oh My Zsh is an open source, community-driven framework for managing your [zsh](http://www.zsh.org/) configuration. That sounds boring. Let's try this again. Oh My Zsh is an open source, community-driven framework for managing your [zsh](http://www.zsh.org/) configuration.
__Oh My Zsh is a way of life!__ Once installed, your terminal prompt will become the talk of the town _or your money back!_ Each time you interact with your command prompt, you'll be able to take advantage of the hundreds of bundled plugins and pretty themes. Strangers will come up to you in cafés and ask you, _"that is amazing. are you some sort of genius?"_ Finally, you'll begin to get the sort of attention that you always felt that you deserved. ...or maybe you'll just use the time that you saved to start flossing more often. That sounds boring. Let's try this again.
__Oh My Zsh is a way of life!__
Once installed, your terminal shell will become the talk of the town _or your money back!_ With each keystroke in your command prompt, you'll take advantage of the hundreds of powerful plugins and beautiful themes. Strangers will come up to you in cafés and ask you, _"that is amazing! are you some sort of genius?"_
Finally, you'll begin to get the sort of attention that you have always felt you deserved. ...or maybe you'll use the time that you're saving to start flossing more often.
To learn more, visit [ohmyz.sh](http://ohmyz.sh) and follow [@ohmyzsh](https://twitter.com/ohmyzsh) on Twitter. To learn more, visit [ohmyz.sh](http://ohmyz.sh) and follow [@ohmyzsh](https://twitter.com/ohmyzsh) on Twitter.
@ -202,7 +208,10 @@ Thank you so much!
## Follow Us ## Follow Us
We have an [@ohmyzsh](https://twitter.com/ohmyzsh) Twitter account. You should follow it. We're on the social medias.
* [@ohmyzsh](https://twitter.com/ohmyzsh) on Twitter. You should follow it.
* [Oh My Zsh](https://www.facebook.com/Oh-My-Zsh-296616263819290/) on Facebook.
## Merchandise ## Merchandise
@ -211,3 +220,9 @@ We have [stickers](http://shop.planetargon.com/products/ohmyzsh-stickers-set-of-
## License ## License
Oh My Zsh is released under the [MIT license](LICENSE.txt). Oh My Zsh is released under the [MIT license](LICENSE.txt).
## About Planet Argon
![Planet Argon](http://pa-github-assets.s3.amazonaws.com/PARGON_logo_digital_COL-small.jpg)
Oh My Zsh was started by the team at [Planet Argon](https://www.planetargon.com/?utm_source=github), a [Ruby on Rails development agency](https://www.planetargon.com/skills/ruby-on-rails-development?utm_source=github).

View File

@ -31,13 +31,13 @@ function clipcopy() {
cat $file > /dev/clipboard cat $file > /dev/clipboard
fi fi
else else
if which xclip &>/dev/null; then if (( $+commands[xclip] )); then
if [[ -z $file ]]; then if [[ -z $file ]]; then
xclip -in -selection clipboard xclip -in -selection clipboard
else else
xclip -in -selection clipboard $file xclip -in -selection clipboard $file
fi fi
elif which xsel &>/dev/null; then elif (( $+commands[xsel] )); then
if [[ -z $file ]]; then if [[ -z $file ]]; then
xsel --clipboard --input xsel --clipboard --input
else else
@ -74,9 +74,9 @@ function clippaste() {
elif [[ $OSTYPE == cygwin* ]]; then elif [[ $OSTYPE == cygwin* ]]; then
cat /dev/clipboard cat /dev/clipboard
else else
if which xclip &>/dev/null; then if (( $+commands[xclip] )); then
xclip -out -selection clipboard xclip -out -selection clipboard
elif which xsel &>/dev/null; then elif (( $+commands[xsel] )); then
xsel --clipboard --output xsel --clipboard --output
else else
print "clipcopy: Platform $OSTYPE not supported or xclip/xsel not installed" >&2 print "clipcopy: Platform $OSTYPE not supported or xclip/xsel not installed" >&2

View File

@ -1,4 +1,7 @@
# fixme - the load process here seems a bit bizarre # fixme - the load process here seems a bit bizarre
zmodload -i zsh/complist
WORDCHARS=''
unsetopt menu_complete # do not autoselect the first completion entry unsetopt menu_complete # do not autoselect the first completion entry
unsetopt flowcontrol unsetopt flowcontrol
@ -6,32 +9,26 @@ setopt auto_menu # show completion menu on succesive tab press
setopt complete_in_word setopt complete_in_word
setopt always_to_end setopt always_to_end
WORDCHARS=''
zmodload -i zsh/complist
## case-insensitive (all),partial-word and then substring completion
if [ "x$CASE_SENSITIVE" = "xtrue" ]; then
zstyle ':completion:*' matcher-list 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
unset CASE_SENSITIVE
else
if [ "x$HYPHEN_INSENSITIVE" = "xtrue" ]; then
zstyle ':completion:*' matcher-list 'm:{a-zA-Z-_}={A-Za-z_-}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
unset HYPHEN_INSENSITIVE
else
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
fi
fi
zstyle ':completion:*' list-colors ''
# should this be in keybindings? # should this be in keybindings?
bindkey -M menuselect '^o' accept-and-infer-next-history bindkey -M menuselect '^o' accept-and-infer-next-history
zstyle ':completion:*:*:*:*:*' menu select zstyle ':completion:*:*:*:*:*' menu select
# case insensitive (all), partial-word and substring completion
if [[ "$CASE_SENSITIVE" = true ]]; then
zstyle ':completion:*' matcher-list 'r:|=*' 'l:|=* r:|=*'
else
if [[ "$HYPHEN_INSENSITIVE" = true ]]; then
zstyle ':completion:*' matcher-list 'm:{a-zA-Z-_}={A-Za-z_-}' 'r:|=*' 'l:|=* r:|=*'
else
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|=*' 'l:|=* r:|=*'
fi
fi
unset CASE_SENSITIVE HYPHEN_INSENSITIVE
zstyle ':completion:*' list-colors ''
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01' zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01'
if [ "$OSTYPE[0,7]" = "solaris" ]
then if [[ "$OSTYPE" = solaris* ]]; then
zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm" zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm"
else else
zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm -w -w" zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm -w -w"

View File

@ -76,16 +76,21 @@ function git_current_branch() {
# Gets the number of commits ahead from remote # Gets the number of commits ahead from remote
function git_commits_ahead() { function git_commits_ahead() {
if $(command git rev-parse --git-dir > /dev/null 2>&1); then if command git rev-parse --git-dir &>/dev/null; then
local COMMITS="$(git rev-list --count @{upstream}..HEAD)" local commits="$(git rev-list --count @{upstream}..HEAD)"
echo "$ZSH_THEME_GIT_COMMITS_AHEAD_PREFIX$COMMITS$ZSH_THEME_GIT_COMMITS_AHEAD_SUFFIX" if [[ "$commits" != 0 ]]; then
echo "$ZSH_THEME_GIT_COMMITS_AHEAD_PREFIX$commits$ZSH_THEME_GIT_COMMITS_AHEAD_SUFFIX"
fi
fi fi
} }
# Gets the number of commits behind remote # Gets the number of commits behind remote
function git_commits_behind() { function git_commits_behind() {
if $(command git rev-parse --git-dir > /dev/null 2>&1); then if command git rev-parse --git-dir &>/dev/null; then
echo $(git rev-list --count HEAD..@{upstream}) local commits="$(git rev-list --count HEAD..@{upstream})"
if [[ "$commits" != 0 ]]; then
echo "$ZSH_THEME_GIT_COMMITS_BEHIND_PREFIX$commits$ZSH_THEME_GIT_COMMITS_BEHIND_SUFFIX"
fi
fi fi
} }
@ -160,13 +165,13 @@ function git_prompt_status() {
if $(echo "$INDEX" | grep '^UU ' &> /dev/null); then if $(echo "$INDEX" | grep '^UU ' &> /dev/null); then
STATUS="$ZSH_THEME_GIT_PROMPT_UNMERGED$STATUS" STATUS="$ZSH_THEME_GIT_PROMPT_UNMERGED$STATUS"
fi fi
if $(echo "$INDEX" | grep '^## .*ahead' &> /dev/null); then if $(echo "$INDEX" | grep '^## [^ ]\+ .*ahead' &> /dev/null); then
STATUS="$ZSH_THEME_GIT_PROMPT_AHEAD$STATUS" STATUS="$ZSH_THEME_GIT_PROMPT_AHEAD$STATUS"
fi fi
if $(echo "$INDEX" | grep '^## .*behind' &> /dev/null); then if $(echo "$INDEX" | grep '^## [^ ]\+ .*behind' &> /dev/null); then
STATUS="$ZSH_THEME_GIT_PROMPT_BEHIND$STATUS" STATUS="$ZSH_THEME_GIT_PROMPT_BEHIND$STATUS"
fi fi
if $(echo "$INDEX" | grep '^## .*diverged' &> /dev/null); then if $(echo "$INDEX" | grep '^## [^ ]\+ .*diverged' &> /dev/null); then
STATUS="$ZSH_THEME_GIT_PROMPT_DIVERGED$STATUS" STATUS="$ZSH_THEME_GIT_PROMPT_DIVERGED$STATUS"
fi fi
echo $STATUS echo $STATUS

View File

@ -1,36 +1,42 @@
# ls colors # ls colors
autoload -U colors && colors autoload -U colors && colors
export LSCOLORS="Gxfxcxdxbxegedabagacad"
# Enable ls colors # Enable ls colors
if [ "$DISABLE_LS_COLORS" != "true" ] export LSCOLORS="Gxfxcxdxbxegedabagacad"
then
# Find the option for using colors in ls, depending on the version: Linux or BSD if [[ "$DISABLE_LS_COLORS" != "true" ]]; then
if [[ "$(uname -s)" == "NetBSD" ]]; then # Find the option for using colors in ls, depending on the version
if [[ "$OSTYPE" == netbsd* ]]; then
# On NetBSD, test if "gls" (GNU ls) is installed (this one supports colors); # On NetBSD, test if "gls" (GNU ls) is installed (this one supports colors);
# otherwise, leave ls as is, because NetBSD's ls doesn't support -G # otherwise, leave ls as is, because NetBSD's ls doesn't support -G
gls --color -d . &>/dev/null 2>&1 && alias ls='gls --color=tty' gls --color -d . &>/dev/null && alias ls='gls --color=tty'
elif [[ "$(uname -s)" == "OpenBSD" ]]; then elif [[ "$OSTYPE" == openbsd* ]]; then
# On OpenBSD, "gls" (ls from GNU coreutils) and "colorls" (ls from base, # On OpenBSD, "gls" (ls from GNU coreutils) and "colorls" (ls from base,
# with color and multibyte support) are available from ports. "colorls" # with color and multibyte support) are available from ports. "colorls"
# will be installed on purpose and can't be pulled in by installing # will be installed on purpose and can't be pulled in by installing
# coreutils, so prefer it to "gls". # coreutils, so prefer it to "gls".
gls --color -d . &>/dev/null 2>&1 && alias ls='gls --color=tty' gls --color -d . &>/dev/null && alias ls='gls --color=tty'
colorls -G -d . &>/dev/null 2>&1 && alias ls='colorls -G' colorls -G -d . &>/dev/null && alias ls='colorls -G'
elif [[ "$OSTYPE" == darwin* ]]; then
gls --color -d . &>/dev/null && alias ls='gls --color=tty' || alias ls='ls -G'
else else
ls --color -d . &>/dev/null 2>&1 && alias ls='ls --color=tty' || alias ls='ls -G' # For GNU ls, we use the default ls color theme. They can later be overwritten by themes.
if [[ -z "$LS_COLORS" ]]; then
(( $+commands[dircolors] )) && eval "$(dircolors -b)"
fi
ls --color -d . &>/dev/null && alias ls='ls --color=tty' || alias ls='ls -G'
# Take advantage of $LS_COLORS for completion as well.
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
fi fi
fi fi
setopt auto_cd setopt auto_cd
setopt multios setopt multios
setopt prompt_subst
if [[ x$WINDOW != x ]] [[ -n "$WINDOW" ]] && SCREEN_NO="%B$WINDOW%b " || SCREEN_NO=""
then
SCREEN_NO="%B$WINDOW%b "
else
SCREEN_NO=""
fi
# Apply theming defaults # Apply theming defaults
PS1="%n@%m:%~%# " PS1="%n@%m:%~%# "
@ -40,6 +46,3 @@ ZSH_THEME_GIT_PROMPT_PREFIX="git:(" # Prefix at the very beginning of th
ZSH_THEME_GIT_PROMPT_SUFFIX=")" # At the very end of the prompt ZSH_THEME_GIT_PROMPT_SUFFIX=")" # At the very end of the prompt
ZSH_THEME_GIT_PROMPT_DIRTY="*" # Text to display if the branch is dirty ZSH_THEME_GIT_PROMPT_DIRTY="*" # Text to display if the branch is dirty
ZSH_THEME_GIT_PROMPT_CLEAN="" # Text to display if the branch is clean ZSH_THEME_GIT_PROMPT_CLEAN="" # Text to display if the branch is clean
# Setup the prompt with pretty colors
setopt prompt_subst

View File

@ -27,6 +27,30 @@
| yasu | yaourt -Syua --no-confirm | Same as `yaupg`, but without confirmation | | yasu | yaourt -Syua --no-confirm | Same as `yaupg`, but without confirmation |
| upgrade | yaourt -Syu | Sync with repositories before upgrading packages | | upgrade | yaourt -Syu | Sync with repositories before upgrading packages |
### PACAUR
| Alias | Command | Description |
|---------|------------------------------------|---------------------------------------------------------------------|
| pain | pacaur -S | Install packages from the repositories |
| pains | pacaur -U | Install a package from a local file |
| painsd | pacaur -S --asdeps | Install packages as dependencies of another package |
| paloc | pacaur -Qi | Display information about a package in the local database |
| palocs | pacaur -Qs | Search for packages in the local database |
| palst | pacaur -Qe | List installed packages including from AUR (tagged as "local") |
| pamir | pacaur -Syy | Force refresh of all package lists after updating mirrorlist |
| paorph | pacaur -Qtd | Remove orphans using pacaur |
| pare | pacaur -R | Remove packages, keeping its settings and dependencies |
| parem | pacaur -Rns | Remove packages, including its settings and unneeded dependencies |
| parep | pacaur -Si | Display information about a package in the repositories |
| pareps | pacaur -Ss | Search for packages in the repositories |
| paupd | pacaur -Sy && sudo abs && sudo aur | Update and refresh local package, ABS and AUR databases |
| paupd | pacaur -Sy && sudo abs | Update and refresh the local package and ABS databases |
| paupd | pacaur -Sy && sudo aur | Update and refresh the local package and AUR databases |
| paupd | pacaur -Sy | Update and refresh the local package database |
| paupg | pacaur -Syua | Sync with repositories before upgrading all packages (from AUR too) |
| pasu | pacaur -Syua --no-confirm | Same as `paupg`, but without confirmation |
| upgrade | pacaur -Syu | Sync with repositories before upgrading packages |
#### PACMAN #### PACMAN
| Alias | Command | Description | | Alias | Command | Description |
@ -67,3 +91,5 @@
- Martin Putniorz - mputniorz@gmail.com - Martin Putniorz - mputniorz@gmail.com
- MatthR3D - matthr3d@gmail.com - MatthR3D - matthr3d@gmail.com
- ornicar - thibault.duplessis@gmail.com - ornicar - thibault.duplessis@gmail.com
- Juraj Fiala - doctorjellyface@riseup.net
- Majora320 (Moses Miller) - Majora320@gmail.com

View File

@ -1,15 +1,7 @@
if ! (( $+commands[yaourt] )); then if (( $+commands[yaourt] )); then
upgrade() {
sudo pacman -Syu
}
else
upgrade () {
yaourt -Syu
}
alias yaconf='yaourt -C' alias yaconf='yaourt -C'
alias yaupg='yaourt -Syua' alias yaupg='yaourt -Syua'
alias yasu='yaourt --Syua --no-confirm' alias yasu='yaourt -Syua --noconfirm'
alias yain='yaourt -S' alias yain='yaourt -S'
alias yains='yaourt -U' alias yains='yaourt -U'
alias yare='yaourt -R' alias yare='yaourt -R'
@ -35,6 +27,47 @@ else
fi fi
fi fi
if (( $+commands[pacaur] )); then
alias paupg='pacaur -Syua'
alias pasu='pacaur -Syua --noconfirm'
alias pain='pacaur -S'
alias pains='pacaur -U'
alias pare='pacaur -R'
alias parem='pacaur -Rns'
alias parep='pacaur -Si'
alias pareps='pacaur -Ss'
alias paloc='pacaur -Qi'
alias palocs='pacaur -Qs'
alias palst='pacaur -Qe'
alias paorph='pacaur -Qtd'
alias painsd='pacaur -S --asdeps'
alias pamir='pacaur -Syy'
if (( $+commands[abs] && $+commands[aur] )); then
alias paupd='pacaur -Sy && sudo abs && sudo aur'
elif (( $+commands[abs] )); then
alias paupd='pacaur -Sy && sudo abs'
elif (( $+commands[aur] )); then
alias paupd='pacaur -Sy && sudo aur'
else
alias paupd='pacaur -Sy'
fi
fi
if (( $+commands[pacaur] )); then
upgrade() {
pacaur -Syu
}
elif (( $+commands[yaourt] )); then
upgrade() {
yaourt -Syu
}
else
upgrade() {
sudo pacman -Syu
}
fi
# Pacman - https://wiki.archlinux.org/index.php/Pacman_Tips # Pacman - https://wiki.archlinux.org/index.php/Pacman_Tips
alias pacupg='sudo pacman -Syu' alias pacupg='sudo pacman -Syu'
alias pacin='sudo pacman -S' alias pacin='sudo pacman -S'

View File

@ -1,7 +1,7 @@
# Activates autoenv or reports its failure # Activates autoenv or reports its failure
() { () {
if ! type autoenv_init >/dev/null; then if ! type autoenv_init >/dev/null; then
for d (~/.autoenv /usr/local/opt/autoenv); do for d (~/.autoenv /usr/local/opt/autoenv /usr/local/bin); do
if [[ -e $d/activate.sh ]]; then if [[ -e $d/activate.sh ]]; then
autoenv_dir=$d autoenv_dir=$d
break break

View File

@ -64,15 +64,15 @@ if [[ "$OSTYPE" = darwin* ]] ; then
[[ $(ioreg -rc "AppleSmartBattery"| grep '^.*"IsCharging"\ =\ ' | sed -e 's/^.*"IsCharging"\ =\ //') == "Yes" ]] [[ $(ioreg -rc "AppleSmartBattery"| grep '^.*"IsCharging"\ =\ ' | sed -e 's/^.*"IsCharging"\ =\ //') == "Yes" ]]
} }
elif [[ $(uname) == "Linux" ]] ; then elif [[ "$OSTYPE" = linux* ]] ; then
function battery_is_charging() { function battery_is_charging() {
! [[ $(acpi 2&>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ! [[ $(acpi 2>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]]
} }
function battery_pct() { function battery_pct() {
if (( $+commands[acpi] )) ; then if (( $+commands[acpi] )) ; then
echo "$(acpi | cut -f2 -d ',' | tr -cd '[:digit:]')" echo "$(acpi 2>/dev/null | cut -f2 -d ',' | tr -cd '[:digit:]')"
fi fi
} }
@ -85,14 +85,14 @@ elif [[ $(uname) == "Linux" ]] ; then
} }
function battery_time_remaining() { function battery_time_remaining() {
if [[ $(acpi 2&>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then if [[ $(acpi 2>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then
echo $(acpi | cut -f3 -d ',') echo $(acpi 2>/dev/null | cut -f3 -d ',')
fi fi
} }
function battery_pct_prompt() { function battery_pct_prompt() {
b=$(battery_pct_remaining) b=$(battery_pct_remaining)
if [[ $(acpi 2&>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then if [[ $(acpi 2>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then
if [ $b -gt 50 ] ; then if [ $b -gt 50 ] ; then
color='green' color='green'
elif [ $b -gt 20 ] ; then elif [ $b -gt 20 ] ; then

View File

@ -1,84 +0,0 @@
# Autocompletion for homebrew-cask.
#
# This script intercepts calls to the brew plugin and adds autocompletion
# for the cask subcommand.
#
# Author: https://github.com/pstadler
compdef _brew-cask brew
_brew-cask()
{
local curcontext="$curcontext" state line
typeset -A opt_args
_arguments -C \
':command:->command' \
':subcmd:->subcmd' \
'*::options:->options'
case $state in
(command)
__call_original_brew
cask_commands=(
'cask:manage casks'
)
_describe -t commands 'brew cask command' cask_commands ;;
(subcmd)
case "$line[1]" in
cask)
if (( CURRENT == 3 )); then
local -a subcommands
subcommands=(
"alfred:used to modify Alfred's scope to include the Caskroom"
'audit:verifies installability of casks'
'checklinks:checks for bad cask links'
'cleanup:cleans up cached downloads'
'create:creates a cask of the given name and opens it in an editor'
'doctor:checks for configuration issues'
'edit:edits the cask of the given name'
'fetch:downloads Cask resources to local cache'
'home:opens the homepage of the cask of the given name'
'info:displays information about the cask of the given name'
'install:installs the cask of the given name'
'list:with no args, lists installed casks; given installed casks, lists installed files'
'search:searches all known casks'
'uninstall:uninstalls the cask of the given name'
"update:a synonym for 'brew update'"
)
_describe -t commands "brew cask subcommand" subcommands
fi ;;
*)
__call_original_brew ;;
esac ;;
(options)
local -a casks installed_casks
local expl
case "$line[2]" in
list|uninstall)
__brew_installed_casks
_wanted installed_casks expl 'installed casks' compadd -a installed_casks ;;
audit|edit|home|info|install)
__brew_all_casks
_wanted casks expl 'all casks' compadd -a casks ;;
esac ;;
esac
}
__brew_all_casks() {
casks=(`brew cask search`)
}
__brew_installed_casks() {
installed_casks=(`brew cask list`)
}
__call_original_brew()
{
local ret=1
_call_function ret _brew
compdef _brew-cask brew
}

View File

@ -1,145 +0,0 @@
#compdef brew
#autoload
# imported from https://github.com/Homebrew/homebrew/blob/29f73d2212c2b202fe25f69dcbf440d8391fa4c9/Library/Contributions/brew_zsh_completion.zsh
# Brew ZSH completion function
# Drop this somewhere in your $fpath (like /usr/share/zsh/site-functions)
# and rename it _brew
#
# altered from _fink
_brew_all_formulae() {
formulae=(`brew search`)
}
_brew_installed_formulae() {
installed_formulae=(`brew list`)
}
_brew_installed_taps() {
installed_taps=(`brew tap`)
}
_brew_official_taps() {
official_taps=(`brew tap --list-official`)
}
_brew_pinned_taps() {
pinned_taps=(`brew tap --list-pinned`)
}
_brew_outdated_formulae() {
outdated_formulae=(`brew outdated`)
}
local -a _1st_arguments
_1st_arguments=(
'audit:check formulae for Homebrew coding style'
'cat:display formula file for a formula'
'cleanup:uninstall unused and old versions of packages'
'commands:show a list of commands'
'config:show homebrew and system configuration'
'create:create a new formula'
'deps:list dependencies and dependants of a formula'
'desc:display a description of a formula'
'doctor:audits your installation for common issues'
'edit:edit a formula'
'fetch:download formula resources to the cache'
'gist-logs:generate a gist of the full build logs'
'home:visit the homepage of a formula or the brew project'
'info:information about a formula'
'install:install a formula'
'reinstall:install a formula anew; re-using its current options'
'leaves:show installed formulae that are not dependencies of another installed formula'
'link:link a formula'
'linkapps:symlink .app bundles provided by formulae into /Applications'
'list:list files in a formula or not-installed formulae'
'log:git commit log for a formula'
'missing:check all installed formuale for missing dependencies.'
'migrate:migrate renamed formula to new name'
'outdated:list formulae for which a newer version is available'
'pin:pin specified formulae'
'postinstall:perform post_install for a given formula'
'prune:remove dead links'
'remove:remove a formula'
'search:search for a formula (/regex/ or string)'
'switch:switch between different versions of a formula'
'tap:tap a new formula repository from GitHub, or list existing taps'
'tap-info:information about a tap'
'tap-pin:pin a tap'
'tap-unpin:unpin a tap'
'test-bot:test a formula and build a bottle'
'uninstall:uninstall a formula'
'unlink:unlink a formula'
'unlinkapps:remove symlinked .app bundles provided by formulae from /Applications'
'unpin:unpin specified formulae'
'untap:remove a tapped repository'
'update:fetch latest version of Homebrew and all formulae'
'upgrade:upgrade outdated formulae'
'uses:show formulae which depend on a formula'
`brew commands --quiet --include-aliases`
)
local expl
local -a formulae installed_formulae installed_taps official_taps outdated_formulae
_arguments \
'(-v)-v[verbose]' \
'(--cellar)--cellar[brew cellar]' \
'(--env)--env[brew environment]' \
'(--repository)--repository[brew repository]' \
'(--version)--version[version information]' \
'(--prefix)--prefix[where brew lives on this system]' \
'(--cache)--cache[brew cache]' \
'*:: :->subcmds' && return 0
if (( CURRENT == 1 )); then
_describe -t commands "brew subcommand" _1st_arguments
return
fi
case "$words[1]" in
install|reinstall|audit|home|homepage|log|info|abv|uses|cat|deps|desc|edit|options|switch)
_brew_all_formulae
_wanted formulae expl 'all formulae' compadd -a formulae ;;
linkapps|unlinkapps)
_arguments \
'(--local)--local[operate on ~/Applications instead of /Applications]' \
'1: :->forms' && return 0
if [[ "$state" == forms ]]; then
_brew_installed_formulae
_wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae
fi ;;
list|ls)
_arguments \
'(--unbrewed)--unbrewed[files in brew --prefix not controlled by brew]' \
'(--pinned)--pinned[list all versions of pinned formulae]' \
'(--versions)--versions[list all installed versions of a formula]' \
'1: :->forms' && return 0
if [[ "$state" == forms ]]; then
_brew_installed_formulae
_wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae
fi ;;
remove|rm|uninstall|unlink|cleanup|link|ln|pin|unpin)
_brew_installed_formulae
_wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae ;;
search|-S)
_arguments \
'(--macports)--macports[search the macports repository]' \
'(--fink)--fink[search the fink repository]' ;;
untap|tap-info|tap-pin)
_brew_installed_taps
_wanted installed_taps expl 'installed taps' compadd -a installed_taps ;;
tap)
_brew_official_taps
_wanted official_taps expl 'official taps' compadd -a official_taps ;;
tap-unpin)
_brew_pinned_taps
_wanted pinned_taps expl 'pinned taps' compadd -a pinned_taps ;;
upgrade)
_brew_outdated_formulae
_wanted outdated_formulae expl 'outdated formulae' compadd -a outdated_formulae ;;
esac

11
plugins/cargo/README.md Normal file
View File

@ -0,0 +1,11 @@
# cargo
This plugin adds completion for the Rust build tool [`cargo`](https://github.com/rust-lang/cargo).
To use it, add `cargo` to the plugins array in your zshrc file:
```zsh
plugins=(... cargo)
```
Updated on October 4th, 2016.

497
plugins/cargo/_cargo Normal file
View File

@ -0,0 +1,497 @@
#compdef cargo
typeset -A opt_args
autoload -U regexp-replace
_cargo() {
_arguments \
'(- 1 *)'{-h,--help}'[show help message]' \
'(- 1 *)'--list'[list installed commands]' \
'(- 1 *)'{-v,--verbose}'[use verbose output]' \
'(- 1 *)'--color'[colorization option]' \
'(- 1 *)'{-V,--version}'[show version information]' \
'1: :_cargo_cmds' \
'*:: :->args'
case $state in
args)
case $words[1] in
bench)
_arguments \
'--features=[space separated feature list]' \
'--all-features[enable all available features]' \
'(-h, --help)'{-h,--help}'[show help message]' \
'(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \
"${command_scope_spec[@]}" \
'--manifest-path=[path to manifest]: :_files -/' \
'--no-default-features[do not build the default features]' \
'--no-run[compile but do not run]' \
'(-p,--package)'{-p=,--package=}'[package to run benchmarks for]:packages:_get_package_names' \
'--target=[target triple]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'--color=:colorization option:(auto always never)' \
;;
build)
_arguments \
'--features=[space separated feature list]' \
'--all-features[enable all available features]' \
'(-h, --help)'{-h,--help}'[show help message]' \
'(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \
"${command_scope_spec[@]}" \
'--manifest-path=[path to manifest]: :_files -/' \
'--no-default-features[do not build the default features]' \
'(-p,--package)'{-p=,--package=}'[package to build]:packages:_get_package_names' \
'--release=[build in release mode]' \
'--target=[target triple]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'--color=:colorization option:(auto always never)' \
;;
clean)
_arguments \
'(-h, --help)'{-h,--help}'[show help message]' \
'--manifest-path=[path to manifest]: :_files -/' \
'(-p,--package)'{-p=,--package=}'[package to clean]:packages:_get_package_names' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'--release[whether or not to clean release artifacts]' \
'--target=[target triple(default:all)]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'--color=:colorization option:(auto always never)' \
;;
doc)
_arguments \
'--features=[space separated feature list]' \
'--all-features[enable all available features]' \
'(-h, --help)'{-h,--help}'[show help message]' \
'(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \
'--manifest-path=[path to manifest]: :_files -/' \
'--no-deps[do not build docs for dependencies]' \
'--no-default-features[do not build the default features]' \
'--open[open docs in browser after the build]' \
'(-p, --package)'{-p,--package}'=[package to document]' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'--release[build artifacts in release mode, with optimizations]' \
'--target=[build for the target triple]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'--color=:colorization option:(auto always never)' \
;;
fetch)
_arguments \
'(-h, --help)'{-h,--help}'[show help message]' \
'--manifest-path=[path to manifest]: :_files -/' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'--color=:colorization option:(auto always never)' \
;;
generate-lockfile)
_arguments \
'(-h, --help)'{-h,--help}'[show help message]' \
'--manifest-path=[path to manifest]: :_files -/' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'--color=:colorization option:(auto always never)' \
;;
git-checkout)
_arguments \
'(-h, --help)'{-h,--help}'[show help message]' \
'q(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'--reference=[REF]' \
'--url=[URL]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'--color=:colorization option:(auto always never)' \
;;
help)
_arguments \
'(-h, --help)'{-h,--help}'[show help message]' \
'*: :_cargo_cmds' \
;;
init)
_arguments \
'--bin[use binary template]' \
'--vcs:initialize a new repo with a given VCS:(git hg none)' \
'(-h, --help)'{-h,--help}'[show help message]' \
'--name=[set the resulting package name]' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'--color=:colorization option:(auto always never)' \
;;
install)
_arguments \
'--bin=[only install the specified binary]' \
'--branch=[branch to use when installing from git]' \
'--color=:colorization option:(auto always never)' \
'--debug[build in debug mode instead of release mode]' \
'--example[install the specified example instead of binaries]' \
'--features=[space separated feature list]' \
'--all-features[enable all available features]' \
'--git=[URL from which to install the crate]' \
'(-h, --help)'{-h,--help}'[show help message]' \
'(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \
'--no-default-features[do not build the default features]' \
'--path=[local filesystem path to crate to install]' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'--rev=[specific commit to use when installing from git]' \
'--root=[directory to install packages into]' \
'--tag=[tag to use when installing from git]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'--vers=[version to install from crates.io]' \
;;
locate-project)
_arguments \
'(-h, --help)'{-h,--help}'[show help message]' \
'--manifest-path=[path to manifest]: :_files -/' \
;;
login)
_arguments \
'(-h, --help)'{-h,--help}'[show help message]' \
'--host=[Host to set the token for]' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'--color=:colorization option:(auto always never)' \
;;
metadata)
_arguments \
'(-h, --help)'{-h,--help}'[show help message]' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
"--no-deps[output information only about the root package and don't fetch dependencies]" \
'--no-default-features[do not include the default feature]' \
'--manifest-path=[path to manifest]: :_files -/' \
'--features=[space separated feature list]' \
'--all-features[enable all available features]' \
'--format-version=[format version(default: 1)]' \
'--color=:colorization option:(auto always never)' \
;;
new)
_arguments \
'--bin[use binary template]' \
'--vcs:initialize a new repo with a given VCS:(git hg none)' \
'(-h, --help)'{-h,--help}'[show help message]' \
'--name=[set the resulting package name]' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'--color=:colorization option:(auto always never)' \
;;
owner)
_arguments \
'(-a, --add)'{-a,--add}'[add owner LOGIN]' \
'(-h, --help)'{-h,--help}'[show help message]' \
'--index[registry index]' \
'(-l, --list)'{-l,--list}'[list owners of a crate]' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'(-r, --remove)'{-r,--remove}'[remove owner LOGIN]' \
'--token[API token to use when authenticating]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'--color=:colorization option:(auto always never)' \
;;
package)
_arguments \
'(-h, --help)'{-h,--help}'[show help message]' \
'(-l, --list)'{-l,--list}'[print files included in a package without making one]' \
'--manifest-path=[path to manifest]: :_files -/' \
'--no-metadata[ignore warnings about a lack of human-usable metadata]' \
'--no-verify[do not build to verify contents]' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'--color=:colorization option:(auto always never)' \
;;
pkgid)
_arguments \
'(-h, --help)'{-h,--help}'[show help message]' \
'--manifest-path=[path to manifest]: :_files -/' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'--color=:colorization option:(auto always never)' \
;;
publish)
_arguments \
'(-h, --help)'{-h,--help}'[show help message]' \
'--host=[Host to set the token for]' \
'--manifest-path=[path to manifest]: :_files -/' \
'--no-verify[Do not verify tarball until before publish]' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'--token[token to use when uploading]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'--color=:colorization option:(auto always never)' \
;;
read-manifest)
_arguments \
'(-h, --help)'{-h,--help}'[show help message]' \
'--manifest-path=[path to manifest]: :_files -/' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'--color=:colorization option:(auto always never)' \
;;
run)
_arguments \
'--example=[name of the bin target]' \
'--features=[space separated feature list]' \
'--all-features[enable all available features]' \
'(-h, --help)'{-h,--help}'[show help message]' \
'(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \
'--manifest-path=[path to manifest]: :_files -/' \
'--bin=[name of the bin target]' \
'--no-default-features[do not build the default features]' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'--release=[build in release mode]' \
'--target=[target triple]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'--color=:colorization option:(auto always never)' \
'*: :_normal' \
;;
rustc)
_arguments \
'--color=:colorization option:(auto always never)' \
'--features=[features to compile for the package]' \
'--all-features[enable all available features]' \
'(-h, --help)'{-h,--help}'[show help message]' \
'(-j, --jobs)'{-j,--jobs}'=[number of parallel jobs, defaults to # of CPUs]' \
'--manifest-path=[path to the manifest to fetch dependencies for]' \
'--no-default-features[do not compile default features for the package]' \
'(-p, --package)'{-p,--package}'=[profile to compile for]' \
'--profile=[profile to build the selected target for]' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'--release[build artifacts in release mode, with optimizations]' \
'--target=[target triple which compiles will be for]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
"${command_scope_spec[@]}" \
;;
rustdoc)
_arguments \
'--color=:colorization option:(auto always never)' \
'--features=[space-separated list of features to also build]' \
'--all-features[enable all available features]' \
'(-h, --help)'{-h,--help}'[show help message]' \
'(-j, --jobs)'{-j,--jobs}'=[number of parallel jobs, defaults to # of CPUs]' \
'--manifest-path=[path to the manifest to document]' \
'--no-default-features[do not build the `default` feature]' \
'--open[open the docs in a browser after the operation]' \
'(-p, --package)'{-p,--package}'=[package to document]' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'--release[build artifacts in release mode, with optimizations]' \
'--target=[build for the target triple]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
"${command_scope_spec[@]}" \
;;
search)
_arguments \
'--color=:colorization option:(auto always never)' \
'(-h, --help)'{-h,--help}'[show help message]' \
'--host=[host of a registry to search in]' \
'--limit=[limit the number of results]' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
;;
test)
_arguments \
'--features=[space separated feature list]' \
'--all-features[enable all available features]' \
'(-h, --help)'{-h,--help}'[show help message]' \
'(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \
'--manifest-path=[path to manifest]: :_files -/' \
'--test=[test name]: :_test_names' \
'--no-default-features[do not build the default features]' \
'--no-fail-fast[run all tests regardless of failure]' \
'--no-run[compile but do not run]' \
'(-p,--package)'{-p=,--package=}'[package to run tests for]:packages:_get_package_names' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'--release[build artifacts in release mode, with optimizations]' \
'--target=[target triple]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'--color=:colorization option:(auto always never)' \
'1: :_test_names' \
;;
uninstall)
_arguments \
'--bin=[only uninstall the binary NAME]' \
'--color=:colorization option:(auto always never)' \
'(-h, --help)'{-h,--help}'[show help message]' \
'(-q, --quiet)'{-q,--quiet}'[less output printed to stdout]' \
'--root=[directory to uninstall packages from]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
;;
update)
_arguments \
'--aggressive=[force dependency update]' \
'(-h, --help)'{-h,--help}'[show help message]' \
'--manifest-path=[path to manifest]: :_files -/' \
'(-p,--package)'{-p=,--package=}'[package to update]:packages:__get_package_names' \
'--precise=[update single dependency to PRECISE]: :' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'--color=:colorization option:(auto always never)' \
;;
verify-project)
_arguments \
'(-h, --help)'{-h,--help}'[show help message]' \
'--manifest-path=[path to manifest]: :_files -/' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'--color=:colorization option:(auto always never)' \
;;
version)
_arguments \
'(-h, --help)'{-h,--help}'[show help message]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'--color=:colorization option:(auto always never)' \
;;
yank)
_arguments \
'(-h, --help)'{-h,--help}'[show help message]' \
'--index[registry index]' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'--token[API token to use when authenticating]' \
'--undo[undo a yank, putting a version back into the index]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'--color=:colorization option:(auto always never)' \
'--vers[yank version]' \
;;
esac
;;
esac
}
_cargo_cmds(){
local -a commands;commands=(
'bench:execute all benchmarks of a local package'
'build:compile the current project'
'clean:remove generated artifacts'
'doc:build package documentation'
'fetch:fetch package dependencies'
'generate-lockfile:create lockfile'
'git-checkout:git checkout'
'help:get help for commands'
'init:create new project in current directory'
'install:install a Rust binary'
'locate-project:print "Cargo.toml" location'
'login:login to remote server'
'metadata:the metadata for a project in json'
'new:create a new project'
'owner:manage the owners of a crate on the registry'
'package:assemble local package into a distributable tarball'
'pkgid:print a fully qualified package specification'
'publish:upload package to the registry'
'read-manifest:print manifest in JSON format'
'run:run the main binary of the local package'
'rustc:compile a package and all of its dependencies'
'rustdoc:build documentation for a package'
'search:search packages on crates.io'
'test:execute all unit and tests of a local package'
'uninstall:remove a Rust binary'
'update:update dependencies'
'verify-project:check Cargo.toml'
'version:show version information'
'yank:remove pushed file from index'
)
_describe 'command' commands
}
#FIXME: Disabled until fixed
#gets package names from the manifest file
_get_package_names()
{
}
#TODO:see if it makes sense to have 'locate-project' to have non-json output.
#strips package name from json stuff
_locate_manifest(){
local manifest=`cargo locate-project 2>/dev/null`
regexp-replace manifest '\{"root":"|"\}' ''
echo $manifest
}
# Extracts the values of "name" from the array given in $1 and shows them as
# command line options for completion
_get_names_from_array()
{
local -a filelist;
local manifest=$(_locate_manifest)
if [[ -z $manifest ]]; then
return 0
fi
local last_line
local -a names;
local in_block=false
local block_name=$1
names=()
while read line
do
if [[ $last_line == "[[$block_name]]" ]]; then
in_block=true
else
if [[ $last_line =~ '.*\[\[.*' ]]; then
in_block=false
fi
fi
if [[ $in_block == true ]]; then
if [[ $line =~ '.*name.*=' ]]; then
regexp-replace line '^.*name *= *|"' ""
names+=$line
fi
fi
last_line=$line
done < $manifest
_describe $block_name names
}
#Gets the test names from the manifest file
_test_names()
{
_get_names_from_array "test"
}
#Gets the bench names from the manifest file
_benchmark_names()
{
_get_names_from_array "bench"
}
# These flags are mutally exclusive specifiers for the scope of a command; as
# they are used in multiple places without change, they are expanded into the
# appropriate command's `_arguments` where appropriate.
set command_scope_spec
command_scope_spec=(
'(--bin --example --test --lib)--bench=[benchmark name]: :_benchmark_names'
'(--bench --bin --test --lib)--example=[example name]'
'(--bench --example --test --lib)--bin=[binary name]'
'(--bench --bin --example --test)--lib=[library name]'
'(--bench --bin --example --lib)--test=[test name]'
)
_cargo

View File

@ -1,7 +1,7 @@
## Coffeescript Plugin ## Coffeescript Plugin
This plugin provides aliases for quickly compiling and previewing your This plugin provides aliases for quickly compiling and previewing your
cofeescript code. coffeescript code.
When writing Coffeescript it's very common to want to preview the output of a When writing Coffeescript it's very common to want to preview the output of a
certain snippet of code, either because you want to test the output or because certain snippet of code, either because you want to test the output or because

View File

@ -63,7 +63,7 @@ if is-at-least 4.2.0; then
_image_fts=(jpg jpeg png gif mng tiff tif xpm) _image_fts=(jpg jpeg png gif mng tiff tif xpm)
for ft in $_image_fts ; do alias -s $ft=$XIVIEWER; done for ft in $_image_fts ; do alias -s $ft=$XIVIEWER; done
_media_fts=(ape avi flv mkv mov mp3 mpeg mpg ogg ogm rm wav webm) _media_fts=(ape avi flv m4a mkv mov mp3 mpeg mpg ogg ogm rm wav webm)
for ft in $_media_fts ; do alias -s $ft=mplayer ; done for ft in $_media_fts ; do alias -s $ft=mplayer ; done
#read documents #read documents

View File

@ -0,0 +1,11 @@
# `copybuffer` plugin
This plugin binds the ctrl-o keyboard shortcut to a command that copies the text
that is currently typed in the command line ($BUFFER) to the system clipboard.
This is useful if you type a command - and before you hit enter to execute it - want
to copy it maybe so you can paste it into a script, gist or whatnot.
```zsh
plugins=(... copybuffer)
```

View File

@ -0,0 +1,14 @@
# copy the active line from the command line buffer
# onto the system clipboard (requires clipcopy plugin)
copybuffer () {
if which clipcopy &>/dev/null; then
echo $BUFFER | clipcopy
else
echo "clipcopy function not found. Please make sure you have Oh My Zsh installed correctly."
fi
}
zle -N copybuffer
bindkey "^O" copybuffer

32
plugins/cp/README.md Normal file
View File

@ -0,0 +1,32 @@
# cp plugin
This plugin defines a `cpv` function that uses `rsync` so that you
get the features and security of this command.
To enable, add `cp` to your `plugins` array in your zshrc file:
```zsh
plugins=(... cp)
```
## Description
The enabled options for rsync are:
- `-p`: preserves permissions.
- `-o`: preserves owner.
* `-g`: preserves group.
* `-b`: make a backup of the original file instead of overwriting it, if it exists.
* `-r`: recurse directories.
* `-hhh`: outputs numbers in human-readable format, in units of 1024 (K, M, G, T).
* `--backup-dir=/tmp/rsync`: move backup copies to "/tmp/rsync".
* `-e /dev/null`: only work on local files (disable remote shells).
* `--progress`: display progress.

View File

@ -1,14 +1,4 @@
#Show progress while file is copying cpv() {
rsync -pogbr -hhh --backup-dir=/tmp/rsync -e /dev/null --progress "$@"
# Rsync options are: }
# -p - preserve permissions compdef _files cpv
# -o - preserve owner
# -g - preserve group
# -h - output in human-readable format
# --progress - display progress
# -b - instead of just overwriting an existing file, save the original
# --backup-dir=/tmp/rsync - move backup copies to "/tmp/rsync"
# -e /dev/null - only work on local files
# -- - everything after this is an argument, even if it looks like an option
alias cpv="rsync -poghb --backup-dir=/tmp/rsync -e /dev/null --progress --"

View File

@ -0,0 +1,22 @@
# Authors:
# https://github.com/tristola
#
# Docker-compose related zsh aliases
# Aliases ###################################################################
# Use dco as alias for docker-compose, since dc on *nix is 'dc - an arbitrary precision calculator'
# https://www.gnu.org/software/bc/manual/dc-1.05/html_mono/dc.html
alias dco='docker-compose'
alias dcb='docker-compose build'
alias dce='docker-compose exec'
alias dcps='docker-compose ps'
alias dcrestart='docker-compose restart'
alias dcrm='docker-compose rm'
alias dcr='docker-compose run'
alias dcstop='docker-compose stop'
alias dcup='docker-compose up'
alias dcl='docker-compose logs'
alias dclf='docker-compose logs -f'

View File

@ -1,19 +1,5 @@
## Docker autocomplete plugin ## Docker autocomplete plugin
- Adds autocomplete options for all docker commands. A copy of the completion script from the
- Will also show containerIDs and Image names where applicable [docker](https://github.com/docker/docker/tree/master/contrib/completion/zsh)
git repo.
####Shows help for all commands
![General Help](http://i.imgur.com/tUBO9jh.png "Help for all commands")
####Shows your downloaded images where applicable
![Images](http://i.imgur.com/R8ZsWO1.png "Images")
####Shows your running containers where applicable
![Containers](http://i.imgur.com/WQtbheg.png "Containers")
Maintainer : Ahmed Azaan ([@aeonazaan](https://twitter.com/aeonazaan))

File diff suppressed because it is too large Load Diff

46
plugins/extract/README.md Normal file
View File

@ -0,0 +1,46 @@
# extract plugin
This plugin defines a function called `extract` that extracts the archive file
you pass it, and it supports a wide variety of archive filetypes.
This way you don't have to know what specific command extracts a file, you just
do `extract <filename>` and the function takes care of the rest.
To use it, add `extract` to the plugins array in your zshrc file:
```zsh
plugins=(... extract)
```
## Supported file extensions
| Extension | Description |
|:------------------|:-------------------------------------|
| `7z` | 7zip file |
| `Z` | Z archive (LZW) |
| `apk` | Android app file |
| `bz2` | Bzip2 file |
| `deb` | Debian package |
| `gz` | Gzip file |
| `ipsw` | iOS firmware file |
| `jar` | Java Archive |
| `lzma` | LZMA archive |
| `rar` | WinRAR archive |
| `sublime-package` | Sublime Text package |
| `tar` | Tarball |
| `tar.bz2` | Tarball with bzip2 compression |
| `tar.gz` | Tarball with gzip compression |
| `tar.xz` | Tarball with lzma2 compression |
| `tar.zma` | Tarball with lzma compression |
| `tbz` | Tarball with bzip compression |
| `tbz2` | Tarball with bzip2 compression |
| `tgz` | Tarball with gzip compression |
| `tlz` | Tarball with lzma compression |
| `txz` | Tarball with lzma2 compression |
| `war` | Web Application archive (Java-based) |
| `xpi` | Mozilla XPI module file |
| `xz` | LZMA2 archive |
| `zip` | Zip archive |
See [list of archive formats](https://en.wikipedia.org/wiki/List_of_archive_formats) for
more information regarding archive formats.

View File

@ -3,6 +3,5 @@
_arguments \ _arguments \
'(-r --remove)'{-r,--remove}'[Remove archive.]' \ '(-r --remove)'{-r,--remove}'[Remove archive.]' \
"*::archive file:_files -g '(#i)*.(tar|tgz|tbz|tbz2|txz|tlz|gz|bz2|xz|lzma|Z|zip|ipsw|rar|7z|deb)(-.)'" && return 0 "*::archive file:_files -g '(#i)*.(7z|Z|apk|bz2|deb|gz|ipsw|jar|lzma|rar|sublime-package|tar|tar.bz2|tar.gz|tar.xz|tar.zma|tbz|tbz2|tgz|tlz|txz|war|xpi|xz|zip)(-.)'" \
&& return 0

View File

@ -1,80 +1,71 @@
# ------------------------------------------------------------------------------
# FILE: extract.plugin.zsh
# DESCRIPTION: oh-my-zsh plugin file.
# AUTHOR: Sorin Ionescu (sorin.ionescu@gmail.com)
# VERSION: 1.0.1
# ------------------------------------------------------------------------------
function extract() {
local remove_archive
local success
local file_name
local extract_dir
if (( $# == 0 )); then
echo "Usage: extract [-option] [file ...]"
echo
echo Options:
echo " -r, --remove Remove archive."
echo
echo "Report bugs to <sorin.ionescu@gmail.com>."
fi
remove_archive=1
if [[ "$1" == "-r" ]] || [[ "$1" == "--remove" ]]; then
remove_archive=0
shift
fi
while (( $# > 0 )); do
if [[ ! -f "$1" ]]; then
echo "extract: '$1' is not a valid file" 1>&2
shift
continue
fi
success=0
file_name="$( basename "$1" )"
extract_dir="$( echo "$file_name" | sed "s/\.${1##*.}//g" )"
case "$1" in
(*.tar.gz|*.tgz) [ -z $commands[pigz] ] && tar zxvf "$1" || pigz -dc "$1" | tar xv ;;
(*.tar.bz2|*.tbz|*.tbz2) tar xvjf "$1" ;;
(*.tar.xz|*.txz) tar --xz --help &> /dev/null \
&& tar --xz -xvf "$1" \
|| xzcat "$1" | tar xvf - ;;
(*.tar.zma|*.tlz) tar --lzma --help &> /dev/null \
&& tar --lzma -xvf "$1" \
|| lzcat "$1" | tar xvf - ;;
(*.tar) tar xvf "$1" ;;
(*.gz) [ -z $commands[pigz] ] && gunzip "$1" || pigz -d "$1" ;;
(*.bz2) bunzip2 "$1" ;;
(*.xz) unxz "$1" ;;
(*.lzma) unlzma "$1" ;;
(*.Z) uncompress "$1" ;;
(*.zip|*.war|*.jar|*.sublime-package|*.ipsw|*.xpi|*.apk) unzip "$1" -d $extract_dir ;;
(*.rar) unrar x -ad "$1" ;;
(*.7z) 7za x "$1" ;;
(*.deb)
mkdir -p "$extract_dir/control"
mkdir -p "$extract_dir/data"
cd "$extract_dir"; ar vx "../${1}" > /dev/null
cd control; tar xzvf ../control.tar.gz
cd ../data; tar xzvf ../data.tar.gz
cd ..; rm *.tar.gz debian-binary
cd ..
;;
(*)
echo "extract: '$1' cannot be extracted" 1>&2
success=1
;;
esac
(( success = $success > 0 ? $success : $? ))
(( $success == 0 )) && (( $remove_archive == 0 )) && rm "$1"
shift
done
}
alias x=extract alias x=extract
extract() {
local remove_archive
local success
local extract_dir
if (( $# == 0 )); then
cat <<-'EOF' >&2
Usage: extract [-option] [file ...]
Options:
-r, --remove Remove archive.
EOF
fi
remove_archive=1
if [[ "$1" == "-r" ]] || [[ "$1" == "--remove" ]]; then
remove_archive=0
shift
fi
while (( $# > 0 )); do
if [[ ! -f "$1" ]]; then
echo "extract: '$1' is not a valid file" >&2
shift
continue
fi
success=0
extract_dir="${1:t:r}"
case "$1" in
(*.tar.gz|*.tgz) (( $+commands[pigz] )) && { pigz -dc "$1" | tar xv } || tar zxvf "$1" ;;
(*.tar.bz2|*.tbz|*.tbz2) tar xvjf "$1" ;;
(*.tar.xz|*.txz)
tar --xz --help &> /dev/null \
&& tar --xz -xvf "$1" \
|| xzcat "$1" | tar xvf - ;;
(*.tar.zma|*.tlz)
tar --lzma --help &> /dev/null \
&& tar --lzma -xvf "$1" \
|| lzcat "$1" | tar xvf - ;;
(*.tar) tar xvf "$1" ;;
(*.gz) (( $+commands[pigz] )) && pigz -d "$1" || gunzip "$1" ;;
(*.bz2) bunzip2 "$1" ;;
(*.xz) unxz "$1" ;;
(*.lzma) unlzma "$1" ;;
(*.Z) uncompress "$1" ;;
(*.zip|*.war|*.jar|*.sublime-package|*.ipsw|*.xpi|*.apk) unzip "$1" -d $extract_dir ;;
(*.rar) unrar x -ad "$1" ;;
(*.7z) 7za x "$1" ;;
(*.deb)
mkdir -p "$extract_dir/control"
mkdir -p "$extract_dir/data"
cd "$extract_dir"; ar vx "../${1}" > /dev/null
cd control; tar xzvf ../control.tar.gz
cd ../data; extract ../data.tar.*
cd ..; rm *.tar.* debian-binary
cd ..
;;
(*)
echo "extract: '$1' cannot be extracted" >&2
success=1
;;
esac
(( success = $success > 0 ? $success : $? ))
(( $success == 0 )) && (( $remove_archive == 0 )) && rm "$1"
shift
done
}

View File

@ -0,0 +1,17 @@
alias fw="sudo firewall-cmd"
alias fwp="sudo firewall-cmd --permanent"
alias fwr="sudo firewall-cmd --reload"
alias fwrp="sudo firewall-cmd --runtime-to-permanent"
function fwl () {
# converts output to zsh array ()
# @f flag split on new line
zones=("${(@f)$(sudo firewall-cmd --get-active-zones | grep -v interfaces)}")
for i in $zones; do
sudo firewall-cmd --zone $i --list-all
done
echo 'Direct Rules:'
sudo firewall-cmd --direct --get-all-rules
}

View File

@ -0,0 +1,22 @@
# FirewallD Plugin
This plugin adds some aliases and functions for FirewallD using the `firewalld-cmd` command. To use it, add firewalld to your plugins array.
```zsh
plugins=(... firewalld)
```
## Aliases
| Alias | Command | Description |
| :---- | :----------------------------------------- | :--------------------------- |
| fw | `sudo firewall-cmd` | Shorthand |
| fwr | `sudo firewall-cmd --reload` | Reload current configuration |
| fwp | `sudo firewall-cmd --permanent` | Create permanent rule |
| fwrp | `sudo firewall-cmd --runtime-to-permanent` | Save current configuration |
## Functions
| Function | Description |
| :------- | :--------------------------------------------------------- |
| fwl | Lists configuration from all active zones and direct rules |

View File

@ -46,6 +46,7 @@ alias gapa='git add --patch'
alias gb='git branch' alias gb='git branch'
alias gba='git branch -a' alias gba='git branch -a'
alias gbd='git branch -d'
alias gbda='git branch --no-color --merged | command grep -vE "^(\*|\s*(master|develop|dev)\s*$)" | command xargs -n 1 git branch -d' alias gbda='git branch --no-color --merged | command grep -vE "^(\*|\s*(master|develop|dev)\s*$)" | command xargs -n 1 git branch -d'
alias gbl='git blame -b -w' alias gbl='git blame -b -w'
alias gbnm='git branch --no-merged' alias gbnm='git branch --no-merged'
@ -64,6 +65,7 @@ alias gca!='git commit -v -a --amend'
alias gcan!='git commit -v -a --no-edit --amend' alias gcan!='git commit -v -a --no-edit --amend'
alias gcans!='git commit -v -a -s --no-edit --amend' alias gcans!='git commit -v -a -s --no-edit --amend'
alias gcam='git commit -a -m' alias gcam='git commit -a -m'
alias gcsm='git commit -s -m'
alias gcb='git checkout -b' alias gcb='git checkout -b'
alias gcf='git config --list' alias gcf='git config --list'
alias gcl='git clone --recursive' alias gcl='git clone --recursive'
@ -74,7 +76,7 @@ alias gcd='git checkout develop'
alias gcmsg='git commit -m' alias gcmsg='git commit -m'
alias gco='git checkout' alias gco='git checkout'
alias gcount='git shortlog -sn' alias gcount='git shortlog -sn'
compdef gcount=git compdef _git gcount
alias gcp='git cherry-pick' alias gcp='git cherry-pick'
alias gcpa='git cherry-pick --abort' alias gcpa='git cherry-pick --abort'
alias gcpc='git cherry-pick --continue' alias gcpc='git cherry-pick --continue'
@ -157,11 +159,11 @@ alias ghh='git help'
alias gignore='git update-index --assume-unchanged' alias gignore='git update-index --assume-unchanged'
alias gignored='git ls-files -v | grep "^[[:lower:]]"' alias gignored='git ls-files -v | grep "^[[:lower:]]"'
alias git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk' alias git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk'
compdef git-svn-dcommit-push=git compdef _git git-svn-dcommit-push=git
alias gk='\gitk --all --branches' alias gk='\gitk --all --branches'
compdef _git gk='gitk' compdef _git gk='gitk'
alias gke='\gitk --all $(git log -g --pretty=format:%h)' alias gke='\gitk --all $(git log -g --pretty=%h)'
compdef _git gke='gitk' compdef _git gke='gitk'
alias gl='git pull' alias gl='git pull'
@ -171,8 +173,8 @@ alias glgg='git log --graph'
alias glgga='git log --graph --decorate --all' alias glgga='git log --graph --decorate --all'
alias glgm='git log --graph --max-count=10' alias glgm='git log --graph --max-count=10'
alias glo='git log --oneline --decorate' alias glo='git log --oneline --decorate'
alias glol="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit" alias glol="git log --graph --pretty='%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
alias glola="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --all" alias glola="git log --graph --pretty='%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --all"
alias glog='git log --oneline --decorate --graph' alias glog='git log --oneline --decorate --graph'
alias gloga='git log --oneline --decorate --graph --all' alias gloga='git log --oneline --decorate --graph --all'
alias glp="_git_log_prettily" alias glp="_git_log_prettily"
@ -235,4 +237,4 @@ alias gupv='git pull --rebase -v'
alias glum='git pull upstream master' alias glum='git pull upstream master'
alias gwch='git whatchanged -p --abbrev-commit --pretty=medium' alias gwch='git whatchanged -p --abbrev-commit --pretty=medium'
alias gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit -m "--wip--"' alias gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify -m "--wip--"'

View File

@ -2771,6 +2771,6 @@ __git_complete gitk __gitk_main
# when the user has tab-completed the executable name and consequently # when the user has tab-completed the executable name and consequently
# included the '.exe' suffix. # included the '.exe' suffix.
# #
if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then if [[ "$OSTYPE" = cygwin* ]]; then
__git_complete git.exe __git_main __git_complete git.exe __git_main
fi fi

View File

@ -0,0 +1,62 @@
# Globalias plugin
Expands all glob expressions, subcommands and aliases (including global).
Idea from: http://blog.patshead.com/2012/11/automatically-expaning-zsh-global-aliases---simplified.html.
## Usage
Add `globalias` to the plugins array in your zshrc file:
```zsh
plugins=(... globalias)
```
Then just press `SPACE` to trigger the expansion of a command you've written.
If you only want to insert a space without expanding the command line, press
`CTRL`+`SPACE`.
## Examples
#### Glob expressions
```
$ touch {1..10}<space>
# expands to
$ touch 1 2 3 4 5 6 7 8 9 10
$ ls **/*.json<space>
# expands to
$ ls folder/file.json anotherfolder/another.json
```
#### Subcommands
```
$ mkdir "`date -R`"
# expands to
$ mkdir Tue,\ 04\ Oct\ 2016\ 13:54:03\ +0300
```
#### Aliases
```
# .zshrc:
alias -g G="| grep --color=auto -P"
alias l='ls --color=auto -lah'
$ l<space>G<space>
# expands to
$ ls --color=auto -lah | grep --color=auto -P
```
```
# .zsrc:
alias S="sudo systemctl"
$ S<space>
# expands to:
$ sudo systemctl
```

View File

@ -0,0 +1,17 @@
globalias() {
zle _expand_alias
zle expand-word
zle self-insert
}
zle -N globalias
# space expands all aliases, including global
bindkey -M emacs " " globalias
bindkey -M viins " " globalias
# control-space to make a normal space
bindkey -M emacs "^ " magic-space
bindkey -M viins "^ " magic-space
# normal space during searches
bindkey -M isearch " " magic-space

1
plugins/gradle/_gradle Symbolic link
View File

@ -0,0 +1 @@
gradle.plugin.zsh

1
plugins/gradle/_gradlew Symbolic link
View File

@ -0,0 +1 @@
gradle.plugin.zsh

View File

@ -60,6 +60,35 @@ _gradle_does_task_list_need_generating () {
[[ ! -f .gradletasknamecache ]] || [[ build.gradle -nt .gradletasknamecache ]] [[ ! -f .gradletasknamecache ]] || [[ build.gradle -nt .gradletasknamecache ]]
} }
##############
# Parse the tasks from `gradle(w) tasks --all` into .gradletasknamecache
# All lines in the output from gradle(w) that are between /^-+$/ and /^\s*$/
# are considered to be tasks. If and when gradle adds support for listing tasks
# for programmatic parsing, this method can be deprecated.
##############
_gradle_parse_tasks () {
lines_might_be_tasks=false
task_name_buffer=""
while read -r line; do
if [[ $line =~ ^-+$ ]]; then
lines_might_be_tasks=true
# Empty buffer, because it contains items that are not tasks
task_name_buffer=""
elif [[ $line =~ ^\s*$ ]]; then
if [[ "$lines_might_be_tasks" = true ]]; then
# If a newline is found, send the buffer to .gradletasknamecache
while read -r task; do
echo $task | awk '/[a-zA-Z0-9:-]+/ {print $1}'
done <<< "$task_name_buffer"
# Empty buffer, because we are done with the tasks
task_name_buffer=""
fi
lines_might_be_tasks=false
elif [[ "$lines_might_be_tasks" = true ]]; then
task_name_buffer="${task_name_buffer}\n${line}"
fi
done <<< "$1"
}
############################################################################## ##############################################################################
# Discover the gradle tasks by running "gradle tasks --all" # Discover the gradle tasks by running "gradle tasks --all"
@ -68,7 +97,7 @@ _gradle_tasks () {
if [[ -f build.gradle ]]; then if [[ -f build.gradle ]]; then
_gradle_arguments _gradle_arguments
if _gradle_does_task_list_need_generating; then if _gradle_does_task_list_need_generating; then
gradle tasks --all | awk '/[a-zA-Z0-9:-]* - / {print $1}' > .gradletasknamecache _gradle_parse_tasks "$(gradle tasks --all)" > .gradletasknamecache
fi fi
compadd -X "==== Gradle Tasks ====" $(cat .gradletasknamecache) compadd -X "==== Gradle Tasks ====" $(cat .gradletasknamecache)
fi fi
@ -78,7 +107,7 @@ _gradlew_tasks () {
if [[ -f build.gradle ]]; then if [[ -f build.gradle ]]; then
_gradle_arguments _gradle_arguments
if _gradle_does_task_list_need_generating; then if _gradle_does_task_list_need_generating; then
./gradlew tasks --all | awk '/[a-zA-Z0-9:-]* - / {print $1}' > .gradletasknamecache _gradle_parse_tasks "$(./gradlew tasks --all)" > .gradletasknamecache
fi fi
compadd -X "==== Gradlew Tasks ====" $(cat .gradletasknamecache) compadd -X "==== Gradlew Tasks ====" $(cat .gradletasknamecache)
fi fi

View File

@ -9,7 +9,7 @@
export MARKPATH=$HOME/.marks export MARKPATH=$HOME/.marks
jump() { jump() {
cd -P "$MARKPATH/$1" 2>/dev/null || echo "No such mark: $1" cd -P "$MARKPATH/$1" 2>/dev/null || {echo "No such mark: $1"; return 1}
} }
mark() { mark() {

View File

@ -0,0 +1,9 @@
# last-working-dir plugin
Keeps track of the last used working directory and automatically jumps into it
for new shells, unless:
- The plugin is already loaded.
- The current `$PWD` is not `$HOME`.
Adds `lwd` function to jump to the last working directory.

View File

@ -1,26 +1,23 @@
#!/usr/bin/env zsh # Flag indicating if we've previously jumped to last directory
# Keeps track of the last used working directory and automatically jumps
# into it for new shells.
# Flag indicating if we've previously jumped to last directory.
typeset -g ZSH_LAST_WORKING_DIRECTORY typeset -g ZSH_LAST_WORKING_DIRECTORY
mkdir -p $ZSH_CACHE_DIR
cache_file="$ZSH_CACHE_DIR/last-working-dir"
# Updates the last directory once directory is changed. # Updates the last directory once directory is changed
chpwd_functions+=(chpwd_last_working_dir) chpwd_functions+=(chpwd_last_working_dir)
function chpwd_last_working_dir() { chpwd_last_working_dir() {
# Use >| in case noclobber is set to avoid "file exists" error local cache_file="$ZSH_CACHE_DIR/last-working-dir"
pwd >| "$cache_file" pwd >| "$cache_file"
} }
# Changes directory to the last working directory. # Changes directory to the last working directory
function lwd() { lwd() {
[[ ! -r "$cache_file" ]] || cd "`cat "$cache_file"`" local cache_file="$ZSH_CACHE_DIR/last-working-dir"
[[ -r "$cache_file" ]] && cd "$(cat "$cache_file")"
} }
# Automatically jump to last working directory unless this isn't the first time # Jump to last directory automatically unless:
# this plugin has been loaded. # - this isn't the first time the plugin is loaded
if [[ -z "$ZSH_LAST_WORKING_DIRECTORY" ]]; then # - it's not in $HOME directory
lwd 2>/dev/null && ZSH_LAST_WORKING_DIRECTORY=1 || true [[ -n "$ZSH_LAST_WORKING_DIRECTORY" ]] && return
fi [[ "$PWD" != "$HOME" ]] && return
lwd 2>/dev/null && ZSH_LAST_WORKING_DIRECTORY=1 || true

View File

@ -33,6 +33,8 @@ function _lein_commands() {
"version:print leiningen's version" "version:print leiningen's version"
) )
_describe -t subcommands 'leiningen subcommands' subcommands && ret=0 _describe -t subcommands 'leiningen subcommands' subcommands && ret=0
;;
*) _files
esac esac
return ret return ret

View File

@ -110,6 +110,8 @@ function listMavenCompletions {
help:active-profiles help:all-profiles help:describe help:effective-pom help:effective-settings help:evaluate help:expressions help:system help:active-profiles help:all-profiles help:describe help:effective-pom help:effective-settings help:evaluate help:expressions help:system
# release # release
release:clean release:prepare release:rollback release:perform release:stage release:branch release:update-versions release:clean release:prepare release:rollback release:perform release:stage release:branch release:update-versions
# jgitflow
jgitflow:feature-start jgitflow:feature-finish jgitflow:release-start jgitflow:release-finish jgitflow:hotfix-start jgitflow:hotfix-finish jgitflow:build-number
# repository # repository
repository:bundle-create repository:bundle-pack repository:bundle-create repository:bundle-pack
# source # source
@ -172,7 +174,7 @@ function listMavenCompletions {
gwt:browser gwt:clean gwt:compile gwt:compile-report gwt:css gwt:debug gwt:eclipse gwt:eclipseTest gwt:generateAsync gwt:help gwt:i18n gwt:mergewebxml gwt:resources gwt:run gwt:sdkInstall gwt:source-jar gwt:soyc gwt:test gwt:browser gwt:clean gwt:compile gwt:compile-report gwt:css gwt:debug gwt:eclipse gwt:eclipseTest gwt:generateAsync gwt:help gwt:i18n gwt:mergewebxml gwt:resources gwt:run gwt:sdkInstall gwt:source-jar gwt:soyc gwt:test
# options # options
-Dmaven.test.skip=true -DskipTests -Dmaven.surefire.debug -DenableCiProfile -Dpmd.skip=true -Dcheckstyle.skip=true -Dtycho.mode=maven -Dmaven.test.failure.ignore=true -Dmaven.test.skip=true -DskipTests -DskipITs -Dmaven.surefire.debug -DenableCiProfile -Dpmd.skip=true -Dcheckstyle.skip=true -Dtycho.mode=maven -Dmaven.test.failure.ignore=true -DgroupId= -DartifactId= -Dversion= -Dpackaging=jar -Dfile=
# arguments # arguments
-am -amd -B -C -c -cpu -D -e -emp -ep -f -fae -ff -fn -gs -h -l -N -npr -npu -nsu -o -P -pl -q -rf -s -T -t -U -up -V -v -X -am -amd -B -C -c -cpu -D -e -emp -ep -f -fae -ff -fn -gs -h -l -N -npr -npu -nsu -o -P -pl -q -rf -s -T -t -U -up -V -v -X
@ -181,6 +183,7 @@ function listMavenCompletions {
archetype:generate generate-sources archetype:generate generate-sources
cobertura:cobertura cobertura:cobertura
-Dtest= `if [ -d ./src/test/java ] ; then find ./src/test/java -type f -name '*.java' | grep -v svn | sed 's?.*/\([^/]*\)\..*?-Dtest=\1?' ; fi` -Dtest= `if [ -d ./src/test/java ] ; then find ./src/test/java -type f -name '*.java' | grep -v svn | sed 's?.*/\([^/]*\)\..*?-Dtest=\1?' ; fi`
-Dit.test= `if [ -d ./src/test/java ] ; then find ./src/test/java -type f -name '*.java' | grep -v svn | sed 's?.*/\([^/]*\)\..*?-Dit.test=\1?' ; fi`
); );
} }

37
plugins/ng/README.md Normal file
View File

@ -0,0 +1,37 @@
## NG Plugin
This [ng plugin](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/ng)
adds completion support for Angular's CLI (named ng).
Ng is hosted on [ng home](https://github.com/catull/angular-cli)
It is used to generate Angular 2 app "stubs", build those apps, configure them,
test them, lint them etc.
Ahem, "stubs" is not what Angular engineers refer to the items ng can generate
for you.
"Stubs" can be any one of:
- class
- component
- directive
- enum
- module
- pipe
- route
- service
At the moment, `ng completion` creates a very rough completion for Zsh and
Bash.
It is missing most of the options and a few arguments.
In future, this plugin may be shortened to simply being
```zsh
eval `ng completion`
```
There is hope this materialises in the 21st century.
### CONTRIBUTOR
- Carlo Dapor ([catull](https://github.com/catull))

77
plugins/ng/ng.plugin.zsh Normal file
View File

@ -0,0 +1,77 @@
ng_opts='addon asset-sizes b build completion d destroy doc e2e g generate get github-pages:deploy gh-pages:deploy h help i init install lint make-this-awesome new s serve server set t test v version -h --help'
_ng_completion () {
local words cword opts
read -Ac words
read -cn cword
let cword-=1
case $words[cword] in
addon )
opts='-b --blueprint -d -dir --directory --dry-run -sb --skip-bower -sg --skip-git -sn --skip-npm -v --verbose'
;;
asset-sizes )
opts='-o --output-path'
;;
b | build )
opts='--environment --output-path --suppress-sizes --target --watch --watcher -dev -e -prod'
;;
d | destroy )
opts='--dry-run --verbose --pod --classic --dummy --in-repo --in-repo-addon -d -v -p -c -dum -id -ir'
;;
g | generate )
opts='class component directive enum module pipe route service --generate -d --dry-run --verbose -v --pod -p --classic -c --dummy -dum -id --in-repo --in-repo-addon -ir'
;;
gh-pages:deploy | github-pages:deploy )
opts='--environment --gh-token --gh-username --skip-build --user-page --message'
;;
h | help | -h | --help)
opts='--json --verbose -v'
;;
init )
opts='--blueprint --dry-run --link-cli --mobile --name --prefix --skip-bower --skip-npm --source-dir --style --verbose -b -d -lc -n -p -sb -sd -sn -v'
;;
new )
opts='--blueprint --directory --dry-run --link-cli --mobile --prefix --skip-bower --skip-git --skip-npm --source-dir --style --verbose -b -d -dir -lc -p -sb -sd -sg -sn -v'
;;
s | serve | server )
opts='--environment --host --insecure-proxy --inspr --live-reload --live-reload-base-url --live-reload-host --live-reload-live-css --live-reload-port --output-path --port --proxy --ssl --ssl-cert --ssl-key --target --watcher -H -dev -e -lr -lrbu -lrh -lrp -op -out -p -pr -prod -pxy -t -w'
;;
set )
opts='--global -g'
;;
t | test )
opts='--browsers --colors --config-file --environment --filter --host --launch --log-level --module --path --port --query --reporter --server --silent --test-page --test-port --watch -H -c -cf -e -f -m -r -s -tp -w'
;;
v | version )
opts='--verbose'
;;
ng )
opts=$ng_opts
;;
* )
opts=''
;;
esac
setopt shwordsplit
reply=($opts)
unset shwordsplit
}
compctl -K _ng_completion ng

15
plugins/nomad/README.md Normal file
View File

@ -0,0 +1,15 @@
# Nomad
The `nomad` plugin provides a simple autocompletion for [Nomad](https://nomadproject.io/), a tool from Hashicorp for easily deploy applications at any scale.
## Usage
1. Enable the `nomad` plugin:
```zsh
plugins=(... nomad)
```
2. Install [Nomad](https://nomadproject.io/)
3. Type `nomad` into your prompt and hit `TAB` to see available completion options.

153
plugins/nomad/_nomad Normal file
View File

@ -0,0 +1,153 @@
#compdef nomad
local -a _nomad_cmds
_nomad_cmds=(
'agent:Runs a Nomad agent'
'agent-info:Display status information about the local agent'
'alloc-status:Display allocation status information and metadata'
'client-config:View or modify client configuration details'
'eval-status:Display evaluation status and placement failure reasons'
'fs:Inspect the contents of an allocation directory'
'init:Create an example job file'
'inspect:Inspect a submitted job'
'logs:Streams the logs of a task.'
'node-drain:Toggle drain mode on a given node'
'node-status:Display status information about nodes'
'plan:Dry-run a job update to determine its effects'
'run:Run a new job or update an existing'
'server-force-leave:Force a server into the left state'
'server-join:Join server nodes together'
'server-members:Display a list of known servers and their'
'status:Display status information about jobs'
'stop:Stop a running job'
'validate:Checks if a given job specification is valid'
'version:Prints the Nomad version'
)
__allocstatus() {
_arguments \
'-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \
'-region=[(region) The region of the Nomad servers to forward commands to. Overrides the NOMAD_REGION environment variable if set. Defaults to the Agent s local region.]' \
'-no-color[Disables colored command output.]' \
'-short[Display short output. Shows only the most recent task event.]' \
'-stats[Display detailed resource usage statistics.]' \
'-verbose[Show full information.]' \
'-json[Output the allocation in its JSON format.]' \
'-t[Format and display allocation using a Go template.]'
}
__evalstatus() {
_arguments \
'-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \
'-region=[(region) The region of the Nomad servers to forward commands to. Overrides the NOMAD_REGION environment variable if set. Defaults to the Agent s local region.]' \
'-no-color[Disables colored command output.]' \
'-monitor[Monitor an outstanding evaluation.]' \
'-verbose[Show full information.]' \
'-json[Output the allocation in its JSON format.]' \
'-t[Format and display allocation using a Go template.]'
}
__inspect() {
_arguments \
'-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \
'-region=[(region) The region of the Nomad servers to forward commands to. Overrides the NOMAD_REGION environment variable if set. Defaults to the Agent s local region.]' \
'-no-color[Disables colored command output.]' \
'-json[Output the allocation in its JSON format.]' \
'-t[Format and display allocation using a Go template.]'
}
__logs() {
_arguments \
'-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \
'-region=[(region) The region of the Nomad servers to forward commands to. Overrides the NOMAD_REGION environment variable if set. Defaults to the Agent s local region.]' \
'-no-color[Disables colored command output.]' \
'-stderr[ Display stderr logs.]' \
'-job[<job-id> Use a random allocation from the specified job ID.]' \
'-verbose[Show full information.]' \
'-f[Causes the output to not stop when the end of the logs are reached, but rather to wait for additional output.]' \
'-tail[Show the logs contents with offsets relative to the end of the logs. If no offset is given, -n is defaulted to 10.]' \
'-n[Sets the tail location in best-efforted number of lines relative to the end of the logs.]' \
'-c[Sets the tail location in number of bytes relative to the end of the logs.]'
}
__nodestatus() {
_arguments \
'-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \
'-region=[(region) The region of the Nomad servers to forward commands to. Overrides the NOMAD_REGION environment variable if set. Defaults to the Agent s local region.]' \
'-no-color[Disables colored command output.]' \
'-self[Query the status of the local node.]' \
'-allocs[ Display a count of running allocations for each node.]' \
'-short[Display short output. Shows only the most recent task event.]' \
'-stats[Display detailed resource usage statistics.]' \
'-verbose[Show full information.]' \
'-json[Output the allocation in its JSON format.]' \
'-t[Format and display allocation using a Go template.]'
}
__plan() {
_arguments \
'-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \
'-region=[(region) The region of the Nomad servers to forward commands to. Overrides the NOMAD_REGION environment variable if set. Defaults to the Agent s local region.]' \
'-no-color[Disables colored command output.]' \
'-diff[Determines whether the diff between the remote job and planned job is shown. Defaults to true.]'
}
__run() {
_arguments \
'-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \
'-region=[(region) The region of the Nomad servers to forward commands to. Overrides the NOMAD_REGION environment variable if set. Defaults to the Agent s local region.]' \
'-no-color[Disables colored command output.]' \
'-check-index[If set, the job is only registered or updated if the the passed job modify index matches the server side version. If a check-index value of zero is passed, the job is only registered if it does not yet exist. If a non-zero value is passed, it ensures that the job is being updated from a known state. The use of this flag is most common in conjunction with plan command.]' \
'-detach[Return immediately instead of entering monitor mode. After job submission, the evaluation ID will be printed to the screen, which can be used to examine the evaluation using the eval-status command.]' \
'-output[Output the JSON that would be submitted to the HTTP API without submitting the job.]' \
'-verbose[Show full information.]'
}
__status() {
_arguments \
'-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \
'-region=[(region) The region of the Nomad servers to forward commands to. Overrides the NOMAD_REGION environment variable if set. Defaults to the Agent s local region.]' \
'-no-color[Disables colored command output.]' \
'-short[Display short output. Shows only the most recent task event.]' \
'-evals[Display the evaluations associated with the job.]' \
'-verbose[Show full information.]'
}
__stop() {
_arguments \
'-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \
'-region=[(region) The region of the Nomad servers to forward commands to. Overrides the NOMAD_REGION environment variable if set. Defaults to the Agent s local region.]' \
'-no-color[Disables colored command output.]' \
'-detach[Return immediately instead of entering monitor mode. After the deregister command is submitted, a new evaluation ID is printed to the screen, which can be used to examine the evaluation using the eval-status command.]' \
'-yes[Automatic yes to prompts.]' \
'-verbose[Show full information.]'
}
_arguments '*:: :->command'
if (( CURRENT == 1 )); then
_describe -t commands "nomad command" _nomad_cmds
return
fi
local -a _command_args
case "$words[1]" in
alloc-status)
__allocstatus ;;
eval-status)
__evalstatus ;;
inspect)
__inspect ;;
logs)
__logs ;;
node-status)
__nodestatus ;;
plan)
__plan ;;
run)
__run ;;
status)
__status ;;
stop)
__stop ;;
esac

View File

@ -2,10 +2,13 @@
__NPM_COMPLETION_FILE="${ZSH_CACHE_DIR}/npm_completion" __NPM_COMPLETION_FILE="${ZSH_CACHE_DIR}/npm_completion"
if [[ ! -f $__NPM_COMPLETION_FILE ]]; then if [[ ! -f $__NPM_COMPLETION_FILE ]]; then
npm completion >! $__NPM_COMPLETION_FILE || rm -f $__NPM_COMPLETION_FILE npm completion >! $__NPM_COMPLETION_FILE 2>/dev/null
[[ $? -ne 0 ]] && rm -f $__NPM_COMPLETION_FILE
fi fi
source $__NPM_COMPLETION_FILE [[ -f $__NPM_COMPLETION_FILE ]] && source $__NPM_COMPLETION_FILE
unset __NPM_COMPLETION_FILE
} }
# Install dependencies globally # Install dependencies globally
@ -29,6 +32,12 @@ alias npmE='PATH="$(npm bin)":"$PATH"'
# Check which npm modules are outdated # Check which npm modules are outdated
alias npmO="npm outdated" alias npmO="npm outdated"
# Check package versions
alias npmV="npm -v"
# List packages
alias npmL="npm list"
# Run npm start # Run npm start
alias npmst="npm start" alias npmst="npm start"

View File

@ -30,3 +30,4 @@ Original author: [Sorin Ionescu](https://github.com/sorin-ionescu)
| `showfiles` | Show hidden files | | `showfiles` | Show hidden files |
| `hidefiles` | Hide the hidden files | | `hidefiles` | Hide the hidden files |
| `itunes` | Control iTunes. User `itunes -h` for usage details | | `itunes` | Control iTunes. User `itunes -h` for usage details |
| `spotify` | Control Spotify and search by artist, album, track and etc.|

View File

@ -261,6 +261,270 @@ EOF
osascript -e "tell application \"iTunes\" to $opt" osascript -e "tell application \"iTunes\" to $opt"
} }
# Spotify control function
function spotify() {
showHelp () {
echo "Usage:";
echo;
echo " $(basename "$0") <command>";
echo;
echo "Commands:";
echo;
echo " play # Resumes playback where Spotify last left off.";
echo " play [song name] # Finds a song by name and plays it.";
echo " play album [album name] # Finds an album by name and plays it.";
echo " play artist [artist name] # Finds an artist by name and plays it.";
echo " play list [playlist name] # Finds a playlist by name and plays it.";
echo " pause # Pauses Spotify playback.";
echo " next # Skips to the next song in a playlist.";
echo " prev # Returns to the previous song in a playlist.";
echo " pos [time] # Jumps to a time (in secs) in the current song.";
echo " quit # Stops playback and quits Spotify.";
echo;
echo " vol up # Increases the volume by 10%.";
echo " vol down # Decreases the volume by 10%.";
echo " vol [amount] # Sets the volume to an amount between 0 and 100.";
echo " vol show # Shows the current Spotify volume.";
echo;
echo " status # Shows the current player status.";
echo " share # Copies the current song URL to the clipboard."
echo " info # Shows Full Information about song that is playing.";
echo;
echo " toggle shuffle # Toggles shuffle playback mode.";
echo " toggle repeat # Toggles repeat playback mode.";
}
cecho(){
bold=$(tput bold);
green=$(tput setaf 2);
reset=$(tput sgr0);
echo "$bold$green$1$reset";
}
showStatus () {
state=$(osascript -e 'tell application "Spotify" to player state as string');
cecho "Spotify is currently $state.";
if [ "$state" = "playing" ]; then
artist=$(osascript -e 'tell application "Spotify" to artist of current track as string');
album=$(osascript -e 'tell application "Spotify" to album of current track as string');
track=$(osascript -e 'tell application "Spotify" to name of current track as string');
duration=$(osascript -e 'tell application "Spotify" to duration of current track as string');
duration=$(echo "scale=2; $duration / 60 / 1000" | bc);
position=$(osascript -e 'tell application "Spotify" to player position as string' | tr ',' '.');
position=$(echo "scale=2; $position / 60" | bc | awk '{printf "%0.2f", $0}');
printf "$reset""Artist: %s\nAlbum: %s\nTrack: %s \nPosition: %s / %s\n" "$artist" "$album" "$track" "$position" "$duration";
fi
}
if [ $# = 0 ]; then
showHelp;
else
if [ "$(osascript -e 'application "Spotify" is running')" = "false" ]; then
osascript -e 'tell application "Spotify" to activate'
sleep 2
fi
fi
while [ $# -gt 0 ]; do
arg=$1;
case $arg in
"play" )
if [ $# != 1 ]; then
# There are additional arguments, so find out how many
array=( $@ );
len=${#array[@]};
SPOTIFY_SEARCH_API="https://api.spotify.com/v1/search"
SPOTIFY_PLAY_URI="";
searchAndPlay() {
type="$1"
Q="$2"
cecho "Searching ${type}s for: $Q";
SPOTIFY_PLAY_URI=$( \
curl -s -G $SPOTIFY_SEARCH_API --data-urlencode "q=$Q" -d "type=$type&limit=1&offset=0" -H "Accept: application/json" \
| grep -E -o "spotify:$type:[a-zA-Z0-9]+" -m 1
)
}
case $2 in
"list" )
_args=${array[*]:2:$len};
Q=$_args;
cecho "Searching playlists for: $Q";
results=$( \
curl -s -G $SPOTIFY_SEARCH_API --data-urlencode "q=$Q" -d "type=playlist&limit=10&offset=0" -H "Accept: application/json" \
| grep -E -o "spotify:user:[a-zA-Z0-9_]+:playlist:[a-zA-Z0-9]+" -m 10 \
)
count=$( \
echo "$results" | grep -c "spotify:user" \
)
if [ "$count" -gt 0 ]; then
random=$(( RANDOM % count));
SPOTIFY_PLAY_URI=$( \
echo "$results" | awk -v random="$random" '/spotify:user:[a-zA-Z0-9]+:playlist:[a-zA-Z0-9]+/{i++}i==random{print; exit}' \
)
fi;;
"album" | "artist" | "track" )
_args=${array[*]:2:$len};
searchAndPlay "$2" "$_args";;
* )
_args=${array[*]:1:$len};
searchAndPlay track "$_args";;
esac
if [ "$SPOTIFY_PLAY_URI" != "" ]; then
cecho "Playing ($Q Search) -> Spotify URL: $SPOTIFY_PLAY_URI";
osascript -e "tell application \"Spotify\" to play track \"$SPOTIFY_PLAY_URI\"";
else
cecho "No results when searching for $Q";
fi
else
# play is the only param
cecho "Playing Spotify.";
osascript -e 'tell application "Spotify" to play';
fi
break ;;
"pause" )
state=$(osascript -e 'tell application "Spotify" to player state as string');
if [ "$state" = "playing" ]; then
cecho "Pausing Spotify.";
else
cecho "Playing Spotify.";
fi
osascript -e 'tell application "Spotify" to playpause';
break ;;
"quit" )
cecho "Quitting Spotify.";
osascript -e 'tell application "Spotify" to quit';
exit 1 ;;
"next" )
cecho "Going to next track." ;
osascript -e 'tell application "Spotify" to next track';
break ;;
"prev" )
cecho "Going to previous track.";
osascript -e 'tell application "Spotify" to previous track';
break ;;
"vol" )
vol=$(osascript -e 'tell application "Spotify" to sound volume as integer');
if [[ "$2" = "show" || "$2" = "" ]]; then
cecho "Current Spotify volume level is $vol.";
break ;
elif [ "$2" = "up" ]; then
if [ "$vol" -le 90 ]; then
newvol=$(( vol+10 ));
cecho "Increasing Spotify volume to $newvol.";
else
newvol=100;
cecho "Spotify volume level is at max.";
fi
elif [ "$2" = "down" ]; then
if [ "$vol" -ge 10 ]; then
newvol=$(( vol-10 ));
cecho "Reducing Spotify volume to $newvol.";
else
newvol=0;
cecho "Spotify volume level is at min.";
fi
elif [ "$2" -ge 0 ]; then
newvol=$2;
fi
osascript -e "tell application \"Spotify\" to set sound volume to $newvol";
break ;;
"toggle" )
if [ "$2" = "shuffle" ]; then
osascript -e 'tell application "Spotify" to set shuffling to not shuffling';
curr=$(osascript -e 'tell application "Spotify" to shuffling');
cecho "Spotify shuffling set to $curr";
elif [ "$2" = "repeat" ]; then
osascript -e 'tell application "Spotify" to set repeating to not repeating';
curr=$(osascript -e 'tell application "Spotify" to repeating');
cecho "Spotify repeating set to $curr";
fi
break ;;
"pos" )
cecho "Adjusting Spotify play position."
osascript -e "tell application \"Spotify\" to set player position to $2";
break;;
"status" )
showStatus;
break ;;
"info" )
info=$(osascript -e 'tell application "Spotify"
set tM to round (duration of current track / 60) rounding down
set tS to duration of current track mod 60
set pos to player position as text
set myTime to tM as text & "min " & tS as text & "s"
set nM to round (player position / 60) rounding down
set nS to round (player position mod 60) rounding down
set nowAt to nM as text & "min " & nS as text & "s"
set info to "" & "\nArtist: " & artist of current track
set info to info & "\nTrack: " & name of current track
set info to info & "\nAlbum Artist: " & album artist of current track
set info to info & "\nAlbum: " & album of current track
set info to info & "\nSeconds: " & duration of current track
set info to info & "\nSeconds played: " & pos
set info to info & "\nDuration: " & mytime
set info to info & "\nNow at: " & nowAt
set info to info & "\nPlayed Count: " & played count of current track
set info to info & "\nTrack Number: " & track number of current track
set info to info & "\nPopularity: " & popularity of current track
set info to info & "\nId: " & id of current track
set info to info & "\nSpotify URL: " & spotify url of current track
set info to info & "\nArtwork: " & artwork of current track
set info to info & "\nPlayer: " & player state
set info to info & "\nVolume: " & sound volume
set info to info & "\nShuffle: " & shuffling
set info to info & "\nRepeating: " & repeating
end tell
return info')
echo "$info";
break ;;
"share" )
url=$(osascript -e 'tell application "Spotify" to spotify url of current track');
remove='spotify:track:'
url=${url#$remove}
url="http://open.spotify.com/track/$url"
cecho "Share URL: $url";
cecho -n "$url" | pbcopy
break;;
-h|--help| *)
showHelp;
break ;;
esac
done
}
# Show/hide hidden files in the Finder # Show/hide hidden files in the Finder
alias showfiles="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder" alias showfiles="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder"
alias hidefiles="defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder" alias hidefiles="defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder"

View File

@ -27,9 +27,8 @@ Usage
2. The default mode if per directory history, interact with your history as normal. 2. The default mode if per directory history, interact with your history as normal.
3. Press ^G (the Control and G keys simultaneously) to toggle between local 3. Press ^G (the Control and G keys simultaneously) to toggle between local
and global histories. and global histories. If you would prefer a different shortcut to toggle
set the PER_DIRECTORY_HISTORY_TOGGLE environment variable.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Configuration Configuration

View File

@ -30,7 +30,7 @@
# #
################################################################################ ################################################################################
# #
# Copyright (c) 2012 Jim Hester # Copyright (c) 2014 Jim Hester
# #
# This software is provided 'as-is', without any express or implied warranty. # This software is provided 'as-is', without any express or implied warranty.
# In no event will the authors be held liable for any damages arising from the # In no event will the authors be held liable for any damages arising from the
@ -57,6 +57,7 @@
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
[[ -z $HISTORY_BASE ]] && HISTORY_BASE="$HOME/.directory_history" [[ -z $HISTORY_BASE ]] && HISTORY_BASE="$HOME/.directory_history"
[[ -z $PER_DIRECTORY_HISTORY_TOGGLE ]] && PER_DIRECTORY_HISTORY_TOGGLE='^G'
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# toggle global/directory history used for searching - ctrl-G by default # toggle global/directory history used for searching - ctrl-G by default
@ -76,7 +77,7 @@ function per-directory-history-toggle-history() {
autoload per-directory-history-toggle-history autoload per-directory-history-toggle-history
zle -N per-directory-history-toggle-history zle -N per-directory-history-toggle-history
bindkey '^G' per-directory-history-toggle-history bindkey $PER_DIRECTORY_HISTORY_TOGGLE per-directory-history-toggle-history
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# implementation details # implementation details
@ -108,7 +109,7 @@ function _per-directory-history-change-directory() {
} }
function _per-directory-history-addhistory() { function _per-directory-history-addhistory() {
print -Sr -- ${1%%$'\n'} print -Sr -- "${1%%$'\n'}"
fc -p $_per_directory_history_directory fc -p $_per_directory_history_directory
} }
@ -140,8 +141,9 @@ function _per-directory-history-set-global-history() {
#add functions to the exec list for chpwd and zshaddhistory #add functions to the exec list for chpwd and zshaddhistory
chpwd_functions=(${chpwd_functions[@]} "_per-directory-history-change-directory") autoload -U add-zsh-hook
zshaddhistory_functions=(${zshaddhistory_functions[@]} "_per-directory-history-addhistory") add-zsh-hook chpwd _per-directory-history-change-directory
add-zsh-hook zshaddhistory _per-directory-history-addhistory
#start in directory mode #start in directory mode
mkdir -p ${_per_directory_history_directory:h} mkdir -p ${_per_directory_history_directory:h}

View File

@ -6,10 +6,10 @@
### Aliases ### Aliases
# Set all files' permissions to 644 recursively in a directory # Set all files' permissions to 644 recursively in a directory
alias set644='find . -type f -print0 | xargs -0 chmod 644' alias set644='find . -type f ! -perm 644 -print0 | xargs -0 chmod 644'
# Set all directories' permissions to 755 recursively in a directory # Set all directories' permissions to 755 recursively in a directory
alias set755='find . -type d -print0 | xargs -0 chmod 755' alias set755='find . -type d ! -perm 755 -print0 | xargs -0 chmod 755'
### Functions ### Functions
@ -63,14 +63,14 @@ EOF
exit_status=0; exit_status=0;
if [[ $use_slow == true ]]; then if [[ $use_slow == true ]]; then
# Process directories first so non-traversable ones are fixed as we go # Process directories first so non-traversable ones are fixed as we go
find "$target" -type d -exec chmod $chmod_opts 755 {} \; find "$target" -type d ! -perm 755 -exec chmod $chmod_opts 755 {} \;
if [[ $? != 0 ]]; then exit_status=$?; fi if [[ $? != 0 ]]; then exit_status=$?; fi
find "$target" -type f -exec chmod $chmod_opts 644 {} \; find "$target" -type f ! -perm 644 -exec chmod $chmod_opts 644 {} \;
if [[ $? != 0 ]]; then exit_status=$?; fi if [[ $? != 0 ]]; then exit_status=$?; fi
else else
find "$target" -type d -print0 | xargs -0 chmod $chmod_opts 755 find "$target" -type d ! -perm 755 -print0 | xargs -0 chmod $chmod_opts 755
if [[ $? != 0 ]]; then exit_status=$?; fi if [[ $? != 0 ]]; then exit_status=$?; fi
find "$target" -type f -print0 | xargs -0 chmod $chmod_opts 644 find "$target" -type f ! -perm 644 -print0 | xargs -0 chmod $chmod_opts 644
if [[ $? != 0 ]]; then exit_status=$?; fi if [[ $? != 0 ]]; then exit_status=$?; fi
fi fi
echo "Complete" echo "Complete"

View File

@ -1,7 +1,8 @@
#compdef pip pip2 pip-2.7 pip3 pip-3.2 pip-3.3 pip-3.4 #compdef pip pip2 pip-2.7 pip3 pip-3.2 pip-3.3 pip-3.4
#autoload #autoload
# pip zsh completion, based on homebrew completion # pip zsh completion, based on last stable release (pip8)
# homebrew completion and backwards compatibility
_pip_all() { _pip_all() {
# we cache the list of packages (originally from the macports plugin) # we cache the list of packages (originally from the macports plugin)
@ -17,30 +18,43 @@ _pip_installed() {
local -a _1st_arguments local -a _1st_arguments
_1st_arguments=( _1st_arguments=(
'bundle:create pybundles (archives containing multiple packages)'
'freeze:output all currently installed packages (exact versions) to stdout'
'help:show available commands'
'show:show information about installed packages'
'install:install packages' 'install:install packages'
'search:search PyPI' 'download:download packages'
'uninstall:uninstall packages' 'uninstall:uninstall packages'
'unzip:unzip individual packages' 'freeze:output all currently installed packages (exact versions) to stdout'
'zip:zip individual packages' 'list:list installed packages'
'show:show information about installed packages'
'search:search PyPI'
'wheel:build individual wheel archives for your requirements and dependencies'
'hash:compute a hash of a local package archive'
'help:show available commands'
'bundle:create pybundles (archives containing multiple packages)(deprecated)'
'unzip:unzip individual packages(deprecated)'
'zip:zip individual packages(deprecated)'
) )
local expl local expl
local -a all_pkgs installed_pkgs local -a all_pkgs installed_pkgs
_arguments \ _arguments \
'(--version)--version[show version number of program and exit]' \
'(-h --help)'{-h,--help}'[show help]' \ '(-h --help)'{-h,--help}'[show help]' \
'(-E --environment)'{-E,--environment}'[virtualenv environment to run pip in]' \ '(--isolated)--isolated[run pip in isolated mode, ignores environment variables and user configuration]' \
'(-s --enable-site-packages)'{-s,--enable-site-packages}'[include site-packages in virtualenv]' \
'(-v --verbose)'{-v,--verbose}'[give more output]' \ '(-v --verbose)'{-v,--verbose}'[give more output]' \
'(-V --version)'{-V,--version}'[show version number of program and exit]' \
'(-q --quiet)'{-q,--quiet}'[give less output]' \ '(-q --quiet)'{-q,--quiet}'[give less output]' \
'(--log)--log[log file location]' \ '(--log)--log[log file location]' \
'(--proxy)--proxy[proxy in form user:passwd@proxy.server:port]' \ '(--proxy)--proxy[proxy in form user:passwd@proxy.server:port]' \
'(--retries)--retries[max number of retries per connection (default 5 times)]' \
'(--timeout)--timeout[socket timeout (default 15s)]' \ '(--timeout)--timeout[socket timeout (default 15s)]' \
'(--exists-action)--exists-action[default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup]' \
'(--trusted-host)--trusted-host[mark this host as trusted]' \
'(--cert)--cert[path to alternate CA bundle]' \
'(--client-cert)--client-cert[path to SSL client certificate]' \
'(--cache-dir)--cache-dir[store the cache data in specified directory]' \
'(--no-cache-dir)--no-cache-dir[disable de cache]' \
'(--disable-pip-version-check)--disable-pip-version-check[do not check periodically for new pip version downloads]' \
'(-E --environment)'{-E,--environment}'[virtualenv environment to run pip in (deprecated)]' \
'(-s --enable-site-packages)'{-s,--enable-site-packages}'[include site-packages in virtualenv (deprecated)]' \
'*:: :->subcmds' && return 0 '*:: :->subcmds' && return 0
if (( CURRENT == 1 )); then if (( CURRENT == 1 )); then
@ -56,7 +70,7 @@ case "$words[1]" in
_arguments \ _arguments \
'(-l --local)'{-l,--local}'[report only virtualenv packages]' ;; '(-l --local)'{-l,--local}'[report only virtualenv packages]' ;;
install) install)
_arguments \ _arguments \
'(-U --upgrade)'{-U,--upgrade}'[upgrade all packages to the newest available version]' \ '(-U --upgrade)'{-U,--upgrade}'[upgrade all packages to the newest available version]' \
'(-f --find-links)'{-f,--find-links}'[URL for finding packages]' \ '(-f --find-links)'{-f,--find-links}'[URL for finding packages]' \
'(-r --requirement)'{-r,--requirement}'[Requirements file for packages to install]:File:_files' \ '(-r --requirement)'{-r,--requirement}'[Requirements file for packages to install]:File:_files' \

View File

@ -36,6 +36,7 @@ alias -g RET='RAILS_ENV=test'
# Rails aliases # Rails aliases
alias rc='rails console' alias rc='rails console'
alias rcs='rails console --sandbox'
alias rd='rails destroy' alias rd='rails destroy'
alias rdb='rails dbconsole' alias rdb='rails dbconsole'
alias rg='rails generate' alias rg='rails generate'

View File

@ -3,4 +3,5 @@ alias rnios4s='react-native run-ios --simulator "iPhone 4s"'
alias rnios5='react-native run-ios --simulator "iPhone 5"' alias rnios5='react-native run-ios --simulator "iPhone 5"'
alias rnios5s='react-native run-ios --simulator "iPhone 5s"' alias rnios5s='react-native run-ios --simulator "iPhone 5s"'
alias rnios='react-native run-ios' alias rnios='react-native run-ios'
alias rnlink='react-native link'

View File

@ -0,0 +1,38 @@
# ssh-agent plugin
This plugin starts automatically `ssh-agent` to set up and load whichever
credentials you want for ssh connections.
To enable it, add `ssh-agent` to your plugins:
```zsh
plugins=(... ssh-agent)
```
## Instructions
To enable **agent forwarding support** add the following to your zshrc file:
```zsh
zstyle :omz:plugins:ssh-agent agent-forwarding on
```
To **load multiple identities** use the `identities` style, For example:
```zsh
zstyle :omz:plugins:ssh-agent identities id_rsa id_rsa2 id_github
```
To **set the maximum lifetime of the identities**, use the `lifetime` style.
The lifetime may be specified in seconds or as described in sshd_config(5)
(see _TIME FORMATS_). If left unspecified, the default lifetime is forever.
```zsh
zstyle :omz:plugins:ssh-agent lifetime 4h
```
## Credits
Based on code from Joseph M. Reagle: http://www.cygwin.com/ml/cygwin/2001-06/msg00537.html
Agent-forwarding support based on ideas from Florent Thoumie and Jonas Pfenniger

View File

@ -1,79 +1,42 @@
# typeset _agent_forwarding _ssh_env_cache
# INSTRUCTIONS
#
# To enable agent forwarding support add the following to
# your .zshrc file:
#
# zstyle :omz:plugins:ssh-agent agent-forwarding on
#
# To load multiple identities use the identities style, For
# example:
#
# zstyle :omz:plugins:ssh-agent identities id_rsa id_rsa2 id_github
#
# To set the maximum lifetime of the identities, use the
# lifetime style. The lifetime may be specified in seconds
# or as described in sshd_config(5) (see TIME FORMATS)
# If left unspecified, the default lifetime is forever.
#
# zstyle :omz:plugins:ssh-agent lifetime 4h
#
# CREDITS
#
# Based on code from Joseph M. Reagle
# http://www.cygwin.com/ml/cygwin/2001-06/msg00537.html
#
# Agent forwarding support based on ideas from
# Florent Thoumie and Jonas Pfenniger
#
local _plugin__ssh_env function _start_agent() {
local _plugin__forwarding local lifetime
local -a identities
function _plugin__start_agent() # start ssh-agent and setup environment
{ zstyle -s :omz:plugins:ssh-agent lifetime lifetime
local -a identities
local lifetime
zstyle -s :omz:plugins:ssh-agent lifetime lifetime
# start ssh-agent and setup environment ssh-agent -s ${lifetime:+-t} ${lifetime} | sed 's/^echo/#echo/' >! $_ssh_env_cache
/usr/bin/env ssh-agent ${lifetime:+-t} ${lifetime} | sed 's/^echo/#echo/' >! ${_plugin__ssh_env} chmod 600 $_ssh_env_cache
chmod 600 ${_plugin__ssh_env} . $_ssh_env_cache > /dev/null
. ${_plugin__ssh_env} > /dev/null
# load identies # load identies
zstyle -a :omz:plugins:ssh-agent identities identities zstyle -a :omz:plugins:ssh-agent identities identities
echo starting ssh-agent...
/usr/bin/ssh-add $HOME/.ssh/${^identities} echo starting ssh-agent...
ssh-add $HOME/.ssh/${^identities}
} }
# Get the filename to store/lookup the environment from # Get the filename to store/lookup the environment from
if (( $+commands[scutil] )); then _ssh_env_cache="$HOME/.ssh/environment-$SHORT_HOST"
# It's OS X!
_plugin__ssh_env="$HOME/.ssh/environment-$(scutil --get ComputerName)"
else
_plugin__ssh_env="$HOME/.ssh/environment-$HOST"
fi
# test if agent-forwarding is enabled # test if agent-forwarding is enabled
zstyle -b :omz:plugins:ssh-agent agent-forwarding _plugin__forwarding zstyle -b :omz:plugins:ssh-agent agent-forwarding _agent_forwarding
if [[ ${_plugin__forwarding} == "yes" && -n "$SSH_AUTH_SOCK" ]]; then
# Add a nifty symlink for screen/tmux if agent forwarding
[[ -L $SSH_AUTH_SOCK ]] || ln -sf "$SSH_AUTH_SOCK" /tmp/ssh-agent-$USER-screen
elif [ -f "${_plugin__ssh_env}" ]; then if [[ $_agent_forwarding == "yes" && -n "$SSH_AUTH_SOCK" ]]; then
# Source SSH settings, if applicable # Add a nifty symlink for screen/tmux if agent forwarding
. ${_plugin__ssh_env} > /dev/null [[ -L $SSH_AUTH_SOCK ]] || ln -sf "$SSH_AUTH_SOCK" /tmp/ssh-agent-$USER-screen
ps x | grep ${SSH_AGENT_PID} | grep ssh-agent > /dev/null || { elif [[ -f "$_ssh_env_cache" ]]; then
_plugin__start_agent; # Source SSH settings, if applicable
} . $_ssh_env_cache > /dev/null
ps x | grep ssh-agent | grep -q $SSH_AGENT_PID || {
_start_agent
}
else else
_plugin__start_agent; _start_agent
fi fi
# tidy up after ourselves # tidy up after ourselves
unfunction _plugin__start_agent unset _agent_forwarding _ssh_env_cache
unset _plugin__forwarding unfunction _start_agent
unset _plugin__ssh_env

View File

@ -1,4 +1,4 @@
if [[ $('uname') == 'Linux' ]]; then if [[ "$OSTYPE" == linux* ]]; then
local _sublime_linux_paths > /dev/null 2>&1 local _sublime_linux_paths > /dev/null 2>&1
_sublime_linux_paths=( _sublime_linux_paths=(
"$HOME/bin/sublime_text" "$HOME/bin/sublime_text"

67
plugins/svn/README.md Normal file
View File

@ -0,0 +1,67 @@
# `svn` plugin
This plugin adds some utility functions to display additional information regarding your current
svn repository. See http://subversion.apache.org/ for the full svn documentation.
To use it, add `svn` to your plugins array:
```zsh
plugins=(... svn)
```
## Functions
| Command | Description |
|:----------------------|:--------------------------------------------|
| `svn_prompt_info` | Shows svn prompt in themes |
| `in_svn` | Checks if we're in an svn repository |
| `svn_get_repo_name` | Get repository name |
| `svn_get_branch_name` | Get branch name (see [caveats](#caveats)) |
| `svn_get_rev_nr` | Get revision number |
| `svn_dirty` | Checks if there are changes in the svn repo |
## Caveats
The plugin expects the first directory to be the current branch / tag / trunk. So it returns
the first path element if you don't use branches.
## Usage on themes
To use this in the `agnoster` theme follow these instructions:
1. Enable the svn plugin
2. Add the following lines to your `zshrc` file:
```shell
prompt_svn() {
local rev branch
if in_svn; then
rev=$(svn_get_rev_nr)
branch=$(svn_get_branch_name)
if [[ $(svn_dirty_choose_pwd 1 0) -eq 1 ]]; then
prompt_segment yellow black
echo -n "$rev@$branch"
echo -n "±"
else
prompt_segment green black
echo -n "$rev@$branch"
fi
fi
}
```
3. Override the agnoster `build_prompt()` function:
```zsh
build_prompt() {
RETVAL=$?
prompt_status
prompt_context
prompt_dir
prompt_git
prompt_svn
prompt_end
}
```

View File

@ -1,9 +1,7 @@
# vim:ft=zsh ts=2 sw=2 sts=2 svn_prompt_info() {
#
function svn_prompt_info() {
local _DISPLAY local _DISPLAY
if in_svn; then if in_svn; then
if [ "x$SVN_SHOW_BRANCH" = "xtrue" ]; then if [[ "$SVN_SHOW_BRANCH" = true ]]; then
unset SVN_SHOW_BRANCH unset SVN_SHOW_BRANCH
_DISPLAY=$(svn_get_branch_name) _DISPLAY=$(svn_get_branch_name)
else else
@ -16,23 +14,20 @@ $ZSH_THEME_REPO_NAME_COLOR$_DISPLAY$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_S
} }
function in_svn() { in_svn() {
if $(svn info >/dev/null 2>&1); then svn info >/dev/null 2>&1
return 0
fi
return 1
} }
function svn_get_repo_name() { svn_get_repo_name() {
if in_svn; then if in_svn; then
svn info | sed -n 's/Repository\ Root:\ .*\///p' | read SVN_ROOT LANG=C svn info | sed -n 's/^Repository\ Root:\ .*\///p' | read SVN_ROOT
svn info | sed -n "s/URL:\ .*$SVN_ROOT\///p" LANG=C svn info | sed -n "s/^URL:\ .*$SVN_ROOT\///p"
fi fi
} }
function svn_get_branch_name() { svn_get_branch_name() {
local _DISPLAY=$( local _DISPLAY=$(
svn info 2> /dev/null | \ LANG=C svn info 2> /dev/null | \
awk -F/ \ awk -F/ \
'/^URL:/ { \ '/^URL:/ { \
for (i=0; i<=NF; i++) { \ for (i=0; i<=NF; i++) { \
@ -45,40 +40,27 @@ function svn_get_branch_name() {
}' }'
) )
if [ "x$_DISPLAY" = "x" ]; then if [[ -z "$_DISPLAY" ]]; then
svn_get_repo_name svn_get_repo_name
else else
echo $_DISPLAY echo $_DISPLAY
fi fi
} }
function svn_get_rev_nr() { svn_get_rev_nr() {
if in_svn; then if in_svn; then
svn info 2> /dev/null | sed -n 's/Revision:\ //p' LANG=C svn info 2> /dev/null | sed -n 's/Revision:\ //p'
fi fi
} }
function svn_dirty_choose() { svn_dirty() {
if in_svn; then
local root=`svn info 2> /dev/null | sed -n 's/^Working Copy Root Path: //p'`
if $(svn status $root 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'); then
# Grep exits with 0 when "One or more lines were selected", return "dirty".
echo $1
else
# Otherwise, no lines were found, or an error occurred. Return clean.
echo $2
fi
fi
}
function svn_dirty() {
svn_dirty_choose $ZSH_THEME_SVN_PROMPT_DIRTY $ZSH_THEME_SVN_PROMPT_CLEAN svn_dirty_choose $ZSH_THEME_SVN_PROMPT_DIRTY $ZSH_THEME_SVN_PROMPT_CLEAN
} }
function svn_dirty_choose_pwd () { svn_dirty_choose() {
if in_svn; then if in_svn; then
local root=$PWD local root=$(LANG=C svn info 2> /dev/null | sed -n 's/^Working Copy Root Path: //p')
if $(svn status $root 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'); then if svn status $root 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'; then
# Grep exits with 0 when "One or more lines were selected", return "dirty". # Grep exits with 0 when "One or more lines were selected", return "dirty".
echo $1 echo $1
else else
@ -88,8 +70,18 @@ function svn_dirty_choose_pwd () {
fi fi
} }
function svn_dirty_pwd () { svn_dirty_pwd () {
svn_dirty_choose_pwd $ZSH_THEME_SVN_PROMPT_DIRTY_PWD $ZSH_THEME_SVN_PROMPT_CLEAN_PWD svn_dirty_choose_pwd $ZSH_THEME_SVN_PROMPT_DIRTY_PWD $ZSH_THEME_SVN_PROMPT_CLEAN_PWD
} }
svn_dirty_choose_pwd () {
if in_svn; then
if svn status "$PWD" 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'; then
# Grep exits with 0 when "One or more lines were selected", return "dirty".
echo $1
else
# Otherwise, no lines were found, or an error occurred. Return clean.
echo $2
fi
fi
}

View File

@ -29,7 +29,6 @@ compdef _ppap ppap='sudo ppa-purge'
alias ag='sudo apt-get' # age - but without sudo alias ag='sudo apt-get' # age - but without sudo
alias aga='sudo apt-get autoclean' # aac alias aga='sudo apt-get autoclean' # aac
alias agar='sudo apt-get autoremove'
alias agb='sudo apt-get build-dep' # abd alias agb='sudo apt-get build-dep' # abd
alias agc='sudo apt-get clean' # adc alias agc='sudo apt-get clean' # adc
alias agd='sudo apt-get dselect-upgrade' # ads alias agd='sudo apt-get dselect-upgrade' # ads
@ -44,7 +43,6 @@ alias agar='sudo apt-get autoremove'
compdef _ag ag='sudo apt-get' compdef _ag ag='sudo apt-get'
compdef _aga aga='sudo apt-get autoclean' compdef _aga aga='sudo apt-get autoclean'
compdef _agar agar='sudo apt-get autoremove'
compdef _agb agb='sudo apt-get build-dep' compdef _agb agb='sudo apt-get build-dep'
compdef _agc agc='sudo apt-get clean' compdef _agc agc='sudo apt-get clean'
compdef _agd agd='sudo apt-get dselect-upgrade' compdef _agd agd='sudo apt-get dselect-upgrade'

View File

@ -6,7 +6,7 @@ function zle-keymap-select() {
# Ensure that the prompt is redrawn when the terminal size changes. # Ensure that the prompt is redrawn when the terminal size changes.
TRAPWINCH() { TRAPWINCH() {
zle && { zle reset-prompt; zle -R } zle && zle -R
} }
zle -N zle-keymap-select zle -N zle-keymap-select
@ -28,6 +28,13 @@ bindkey '^?' backward-delete-char
bindkey '^h' backward-delete-char bindkey '^h' backward-delete-char
bindkey '^w' backward-kill-word bindkey '^w' backward-kill-word
# allow ctrl-r to perform backward search in history
bindkey '^r' history-incremental-search-backward
# allow ctrl-a and ctrl-e to move to beginning/end of line
bindkey '^a' beginning-of-line
bindkey '^e' end-of-line
# if mode indicator wasn't setup by theme, define default # if mode indicator wasn't setup by theme, define default
if [[ "$MODE_INDICATOR" == "" ]]; then if [[ "$MODE_INDICATOR" == "" ]]; then
MODE_INDICATOR="%{$fg_bold[red]%}<%{$fg[red]%}<<%{$reset_color%}" MODE_INDICATOR="%{$fg_bold[red]%}<%{$fg[red]%}<<%{$reset_color%}"

View File

@ -26,7 +26,7 @@ plugins=(... xcode)
### `xc` ### `xc`
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. 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.
### `simulator` ### `simulator`

View File

@ -7,10 +7,19 @@ alias xcsel='sudo xcode-select --switch'
# source: http://gist.github.com/subdigital/5420709 # source: http://gist.github.com/subdigital/5420709
function xc { function xc {
local xcode_proj local xcode_proj
xcode_proj=(*.{xcworkspace,xcodeproj}(N)) if [[ $# == 0 ]]; then
xcode_proj=(*.{xcworkspace,xcodeproj}(N))
else
xcode_proj=($1/*.{xcworkspace,xcodeproj}(N))
fi
if [[ ${#xcode_proj} -eq 0 ]]; then if [[ ${#xcode_proj} -eq 0 ]]; then
echo "No xcworkspace/xcodeproj file found in the current directory." if [[ $# == 0 ]]; then
echo "No xcworkspace/xcodeproj file found in the current directory."
else
echo "No xcworkspace/xcodeproj file found in $1."
fi
return 1 return 1
else else
echo "Found ${xcode_proj[1]}" echo "Found ${xcode_proj[1]}"

View File

@ -10,8 +10,8 @@ integer cygwin=0
local IFS=" local IFS="
" "
case "$(uname)" in case "$OSTYPE" in
CYGWIN*) list=( `command ps -Wa` ); cygwin=1 ;; cygwin*) list=( `command ps -Wa` ); cygwin=1 ;;
*) list=( `command ps -o pid,uid,command -A` ) ;; *) list=( `command ps -o pid,uid,command -A` ) ;;
esac esac

View File

@ -42,8 +42,8 @@ NLIST_NONSELECTABLE_ELEMENTS=( 1 )
type ps 2>/dev/null 1>&2 || { echo >&2 "Error: \`ps' not found"; return 1 } type ps 2>/dev/null 1>&2 || { echo >&2 "Error: \`ps' not found"; return 1 }
case "$(uname)" in case "$OSTYPE" in
CYGWIN*) list=( `command ps -Wa` ) ;; cygwin*) list=( `command ps -Wa` ) ;;
*) list=( `command ps -o pid,uid,command -A` ) ;; *) list=( `command ps -o pid,uid,command -A` ) ;;
esac esac

View File

@ -86,7 +86,7 @@ prompt_context() {
# Git: branch/detached head, dirty status # Git: branch/detached head, dirty status
prompt_git() { prompt_git() {
(( $+commands[git] )) || return
local PL_BRANCH_CHAR local PL_BRANCH_CHAR
() { () {
local LC_ALL="" LC_CTYPE="en_US.UTF-8" local LC_ALL="" LC_CTYPE="en_US.UTF-8"
@ -127,6 +127,28 @@ prompt_git() {
fi fi
} }
prompt_bzr() {
(( $+commands[bzr] )) || return
if (bzr status >/dev/null 2>&1); then
status_mod=`bzr status | head -n1 | grep "modified" | wc -m`
status_all=`bzr status | head -n1 | wc -m`
revision=`bzr log | head -n2 | tail -n1 | sed 's/^revno: //'`
if [[ $status_mod -gt 0 ]] ; then
prompt_segment yellow black
echo -n "bzr@"$revision "✚ "
else
if [[ $status_all -gt 0 ]] ; then
prompt_segment yellow black
echo -n "bzr@"$revision
else
prompt_segment green black
echo -n "bzr@"$revision
fi
fi
fi
}
prompt_hg() { prompt_hg() {
(( $+commands[hg] )) || return (( $+commands[hg] )) || return
local rev status local rev status
@ -198,6 +220,7 @@ build_prompt() {
prompt_context prompt_context
prompt_dir prompt_dir
prompt_git prompt_git
prompt_bzr
prompt_hg prompt_hg
prompt_end prompt_end
} }

View File

@ -41,10 +41,4 @@ PROMPT='
%~ %~
${smiley} %{$reset_color%}' ${smiley} %{$reset_color%}'
if [[ -d ~/.rvm ]] && [[ -e ~/.rvm/bin/rvm-prompt ]]; then RPROMPT='%{$fg[white]%} $(ruby_prompt_info)$(git_prompt)%{$reset_color%}'
rvm_prompt='$(~/.rvm/bin/rvm-prompt)'
else
rvm_prompt=''
fi
RPROMPT='%{$fg[white]%} $rvm_prompt$(git_prompt)%{$reset_color%}'

View File

@ -1,6 +1,6 @@
# user, host, full path, and time/date # user, host, full path, and time/date
# on two lines for easier vgrepping # on two lines for easier vgrepping
# entry in a nice long thread on the Arch Linux forums: http://bbs.archlinux.org/viewtopic.php?pid=521888#p521888 # entry in a nice long thread on the Arch Linux forums: http://bbs.archlinux.org/viewtopic.php?pid=521888#p521888
PROMPT=$'%{\e[0;34m%}%B┌─[%b%{\e[0m%}%{\e[1;32m%}%n%{\e[1;30m%}@%{\e[0m%}%{\e[0;36m%}%m%{\e[0;34m%}%B]%b%{\e[0m%} - %b%{\e[0;34m%}%B[%b%{\e[1;37m%}%~%{\e[0;34m%}%B]%b%{\e[0m%} - %{\e[0;34m%}%B[%b%{\e[0;33m%}'%D{"%a %b %d, %I:%M"}%b$'%{\e[0;34m%}%B]%b%{\e[0m%} PROMPT=$'%{\e[0;34m%}%B┌─[%b%{\e[0m%}%{\e[1;32m%}%n%{\e[1;30m%}@%{\e[0m%}%{\e[0;36m%}%m%{\e[0;34m%}%B]%b%{\e[0m%} - %b%{\e[0;34m%}%B[%b%{\e[1;37m%}%~%{\e[0;34m%}%B]%b%{\e[0m%} - %{\e[0;34m%}%B[%b%{\e[0;33m%}'%D{"%a %b %d, %H:%M"}%b$'%{\e[0;34m%}%B]%b%{\e[0m%}
%{\e[0;34m%}%B└─%B[%{\e[1;35m%}$%{\e[0;34m%}%B] <$(git_prompt_info)>%{\e[0m%}%b ' %{\e[0;34m%}%B└─%B[%{\e[1;35m%}$%{\e[0;34m%}%B] <$(git_prompt_info)>%{\e[0m%}%b '
PS2=$' \e[0;34m%}%B>%{\e[0m%}%b ' PS2=$' \e[0;34m%}%B>%{\e[0m%}%b '

View File

@ -1,6 +1,6 @@
# user, host, full path, and time/date # user, host, full path, and time/date
# on two lines for easier vgrepping # on two lines for easier vgrepping
# entry in a nice long thread on the Arch Linux forums: http://bbs.archlinux.org/viewtopic.php?pid=521888#p521888 # entry in a nice long thread on the Arch Linux forums: http://bbs.archlinux.org/viewtopic.php?pid=521888#p521888
PROMPT=$'%{\e[0;34m%}%B┌─[%b%{\e[0m%}%{\e[1;32m%}%n%{\e[1;30m%}@%{\e[0m%}%{\e[0;36m%}%m%{\e[0;34m%}%B]%b%{\e[0m%} - %b%{\e[0;34m%}%B[%b%{\e[1;37m%}%~%{\e[0;34m%}%B]%b%{\e[0m%} - %{\e[0;34m%}%B[%b%{\e[0;33m%}'%D{"%a %b %d, %I:%M"}%b$'%{\e[0;34m%}%B]%b%{\e[0m%} PROMPT=$'%{\e[0;34m%}%B┌─[%b%{\e[0m%}%{\e[1;32m%}%n%{\e[1;30m%}@%{\e[0m%}%{\e[0;36m%}%m%{\e[0;34m%}%B]%b%{\e[0m%} - %b%{\e[0;34m%}%B[%b%{\e[1;37m%}%~%{\e[0;34m%}%B]%b%{\e[0m%} - %{\e[0;34m%}%B[%b%{\e[0;33m%}'%D{"%a %b %d, %H:%M"}%b$'%{\e[0;34m%}%B]%b%{\e[0m%}
%{\e[0;34m%}%B└─%B[%{\e[1;35m%}$%{\e[0;34m%}%B]>%{\e[0m%}%b ' %{\e[0;34m%}%B└─%B[%{\e[1;35m%}$%{\e[0;34m%}%B]>%{\e[0m%}%b '
PS2=$' \e[0;34m%}%B>%{\e[0m%}%b ' PS2=$' \e[0;34m%}%B>%{\e[0m%}%b '

View File

@ -33,31 +33,32 @@ fi
# Cancel upgrade if git is unavailable on the system # Cancel upgrade if git is unavailable on the system
whence git >/dev/null || return 0 whence git >/dev/null || return 0
if [ -f $ZSH_UPDATE ] if mkdir "$ZSH/log/update.lock" 2>/dev/null; then
then if [ -f $ZSH_UPDATE ]; then
. $ZSH_UPDATE . $ZSH_UPDATE
if [[ -z "$LAST_EPOCH" ]]; then if [[ -z "$LAST_EPOCH" ]]; then
_update_zsh_update && return 0; _update_zsh_update && return 0;
fi fi
epoch_diff=$(($(_current_epoch) - $LAST_EPOCH)) epoch_diff=$(($(_current_epoch) - $LAST_EPOCH))
if [ $epoch_diff -gt $epoch_target ] if [ $epoch_diff -gt $epoch_target ]; then
then if [ "$DISABLE_UPDATE_PROMPT" = "true" ]; then
if [ "$DISABLE_UPDATE_PROMPT" = "true" ]
then
_upgrade_zsh
else
echo "[Oh My Zsh] Would you like to check for updates? [Y/n]: \c"
read line
if [[ "$line" == Y* ]] || [[ "$line" == y* ]] || [ -z "$line" ]; then
_upgrade_zsh _upgrade_zsh
else else
_update_zsh_update echo "[Oh My Zsh] Would you like to check for updates? [Y/n]: \c"
read line
if [[ "$line" == Y* ]] || [[ "$line" == y* ]] || [ -z "$line" ]; then
_upgrade_zsh
else
_update_zsh_update
fi
fi fi
fi fi
else
# create the zsh file
_update_zsh_update
fi fi
else
# create the zsh file rmdir $ZSH/log/update.lock
_update_zsh_update
fi fi