Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Guillermo Caracuel 2016-06-20 08:41:47 +02:00
commit 0a1e2957f4
17 changed files with 242 additions and 79 deletions

View File

@ -1,12 +1,27 @@
#!/bin/sh
# get list of available X windows.
x=`emacsclient --alternate-editor '' --eval '(x-display-list)' 2>/dev/null`
function _emacsfun
{
# get list of available X windows.
x=`emacsclient --alternate-editor '' --eval '(x-display-list)' 2>/dev/null`
if [ -z "$x" ] || [ "$x" = "nil" ] ;then
if [ -z "$x" ] || [ "$x" = "nil" ] ;then
# Create one if there is no X window yet.
emacsclient --alternate-editor "" --create-frame "$@"
else
else
# prevent creating another X frame if there is at least one present.
emacsclient --alternate-editor "" "$@"
fi
}
# adopted from https://github.com/davidshepherd7/emacs-read-stdin/blob/master/emacs-read-stdin.sh
# If the second argument is - then write stdin to a tempfile and open the
# tempfile. (first argument will be `--no-wait` passed in by the plugin.zsh)
if [[ $# -ge 2 ]] && [[ "$2" == - ]]; then
tempfile="$(mktemp emacs-stdin-$USER.XXXXXXX --tmpdir)"
cat - > "$tempfile"
_emacsfun --no-wait $tempfile
else
_emacsfun "$@"
fi

View File

@ -1,6 +1,43 @@
# author: Peter Eisentraut
# source: https://gist.github.com/petere/10307599
# compdef kitchen
#compdef kitchen
# ------------------------------------------------------------------------------
# Copyright (c) 2014 Github zsh-users - http://github.com/zsh-users
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the zsh-users nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# ------------------------------------------------------------------------------
# Description
# -----------
#
# Completion script for Test Kitchen (http://kitchen.ci/).
#
# ------------------------------------------------------------------------------
# Authors
# -------
#
# * Peter Eisentraut (https://github.com/petere)
#
# ------------------------------------------------------------------------------
_kitchen() {
local curcontext="$curcontext" state line
@ -11,12 +48,12 @@ _kitchen() {
case $state in
cmds)
_arguments "1:Commands:(console converge create destroy diagnose driver help init list login setup test verify version)"
_kitchen_commands
;;
args)
case $line[1] in
converge|create|destroy|diagnose|list|setup|test|verify)
compadd "$@" all
compadd 'all'
_kitchen_instances
;;
login)
@ -27,15 +64,22 @@ _kitchen() {
esac
}
_kitchen_commands() {
local commands
commands=("${(@f)$(_call_program commands $service help | sed -n 's/^ kitchen \([[:alpha:]]*\) [ [].*# \(.*\)$/\1:\2/p')}")
_describe -t commands 'kitchen commands' commands
}
_kitchen_instances() {
if [[ $_kitchen_instances_cache_dir != $PWD ]]; then
unset _kitchen_instances_cache
fi
if [[ ${+_kitchen_instances_cache} -eq 0 ]]; then
_kitchen_instances_cache=(${(f)"$(bundle exec kitchen list -b 2>/dev/null || kitchen list -b 2>/dev/null)"})
_kitchen_instances_cache=(${(f)"$(_call_program instances $service list -b 2>/dev/null)"})
_kitchen_instances_cache_dir=$PWD
fi
compadd -a _kitchen_instances_cache
_wanted instances expl 'instance' compadd -a _kitchen_instances_cache
}
_kitchen "$@"

View File

@ -3,6 +3,9 @@
# You can override the path to knife.rb and your cookbooks by setting
# KNIFE_CONF_PATH=/path/to/my/.chef/knife.rb
# KNIFE_COOKBOOK_PATH=/path/to/my/chef/cookbooks
# If you want your local cookbooks path to be calculated relative to where you are then
# set the below option
# KNIFE_RELATIVE_PATH=true
# Read around where these are used for more detail.
# These flags should be available everywhere according to man knife
@ -119,7 +122,19 @@ _knife() {
_arguments '4:Subsubsubcommands:($(_chef_$words[2]_$words[3]s_remote))'
;;
file)
_arguments '*:file or directory:_files -g "*.(rb|json)"'
case $words[2] in
environment)
_arguments '*:files:_path_files -g "*.(rb|json)" -W "$(_chef_root)/environments"'
;;
node)
_arguments '*:files:_path_files -g "*.(rb|json)" -W "$(_chef_root)/nodes"'
;;
role)
_arguments '*:files:_path_files -g "*.(rb|json)" -W "$(_chef_root)/roles"'
;;
*)
_arguments '*:Subsubcommands:($(_knife_options3))'
esac
;;
list)
compadd -a "$@" knife_general_flags
@ -132,12 +147,23 @@ _knife() {
if (( versioncomp > 0 )); then
compadd "$@" attributes definitions files libraries providers recipes resources templates
else
_arguments '*:Subsubcommands:($(_knife_options2))'
case $words[5] in
file)
_arguments '*:directory:_path_files -/ -W "$(_chef_root)/data_bags" -qS \ '
;;
*) _arguments '*:Subsubcommands:($(_knife_options2))'
esac
fi
;;
knifesubcmd5)
case $words[5] in
file)
_arguments '*:files:_path_files -g "*.json" -W "$(_chef_root)/data_bags/$words[6]"'
;;
*)
_arguments '*:Subsubcommands:($(_knife_options3))'
esac
esac
}
# Helper functions to provide the argument completion for several depths of commands
@ -184,12 +210,15 @@ _chef_environments_remote() {
# The chef_x_local functions use the knife config to find the paths of relevant objects x to be uploaded to the server
_chef_cookbooks_local() {
if [ $KNIFE_RELATIVE_PATH ]; then
local cookbook_path="$(_chef_root)/cookbooks"
else
local knife_rb=${KNIFE_CONF_PATH:-${HOME}/.chef/knife.rb}
if [ -f ./.chef/knife.rb ]; then
knife_rb="./.chef/knife.rb"
fi
local cookbook_path=${KNIFE_COOKBOOK_PATH:-$(grep cookbook_path $knife_rb | awk 'BEGIN {FS = "[" }; {print $2}' | sed 's/\,//g' | sed "s/'//g" | sed 's/\(.*\)]/\1/' )}
fi
(for i in $cookbook_path; do ls $i; done)
}
@ -198,4 +227,15 @@ _cookbook_versions() {
(knife cookbook show $words[4] | grep -v $words[4] | grep -v -E '\]|\[|\{|\}' | sed 's/ //g' | sed 's/"//g')
}
# Searches up from current directory to find the closest folder that has a .chef folder
# Useful for the knife upload/from file commands
_chef_root () {
directory="$PWD"
while [ $directory != '/' ]
do
test -e "$directory/.chef" && echo "$directory" && return
directory="${directory:h}"
done
}
_knife "$@"

View File

@ -15,6 +15,7 @@ plugins=(... mvn)
| `mvncie` | `mvn clean install eclipse:eclipse` |
| `mvnci` | `mvn clean install` |
| `mvncist` | `mvn clean install -DskipTests` |
| `mvncisto` | `mvn clean install -DskipTests --offline` |
| `mvne` | `mvn eclipse:eclipse` |
| `mvnd` | `mvn deploy` |
| `mvnp` | `mvn package` |

View File

@ -45,6 +45,7 @@ mvn-color()
alias mvncie='mvn clean install eclipse:eclipse'
alias mvnci='mvn clean install'
alias mvncist='mvn clean install -DskipTests'
alias mvncisto='mvn clean install -DskipTests --offline'
alias mvne='mvn eclipse:eclipse'
alias mvnce='mvn clean eclipse:clean eclipse:eclipse'
alias mvnd='mvn deploy'

27
plugins/osx/README.md Normal file
View File

@ -0,0 +1,27 @@
# OSX plugin
## Description
This plugin provides a few utilities to make it more enjoyable on OSX.
To start using it, add the `osx` plugin to your plugins array in `~/.zshrc`:
```zsh
plugins=(... osx)
```
Original author: [Sorin Ionescu](https://github.com/sorin-ionescu)
## Commands
| Command | Description |
|:--------------|:-----------------------------------------------|
| `tab` | Open the current directory in a new tab |
| `ofd` | Open the current directory in a Finder window |
| `pfd` | Return the path of the frontmost Finder window |
| `pfs` | Return the current Finder selection |
| `cdf` | `cd` to the current Finder directory |
| `pushdf` | `pushd` to the current Finder directory |
| `quick-look` | Quick-Look a specified file |
| `man-preview` | Open a specified man page in Preview app |

View File

@ -1,5 +0,0 @@
#compdef man-preview
#autoload
_man

View File

@ -1,9 +1,5 @@
# ------------------------------------------------------------------------------
# FILE: osx.plugin.zsh
# DESCRIPTION: oh-my-zsh plugin file.
# AUTHOR: Sorin Ionescu (sorin.ionescu@gmail.com)
# VERSION: 1.1.0
# ------------------------------------------------------------------------------
# Open the current directory in a Finder window
alias ofd='open_command $PWD'
function _omz_osx_get_frontmost_app() {
local the_app=$(
@ -179,6 +175,7 @@ function quick-look() {
function man-preview() {
man -t "$@" | open -f -a Preview
}
compdef man-preview=man
function vncviewer() {
open vnc://$@

View File

@ -1,6 +1,6 @@
#compdef task
#
# Copyright 2010 - 2015 Johannes Schlatow
# Copyright 2010 - 2016 Johannes Schlatow
# Copyright 2009 P.C. Shyamshankar
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
@ -26,7 +26,6 @@
typeset -g _task_cmds _task_projects _task_tags _task_config _task_modifiers
_task_projects=($(task _projects))
_task_tags=($(task _tags))
_task_ids=($(task _ids))
_task_zshids=( ${(f)"$(task _zshids)"} )
_task_config=($(task _config))
_task_columns=($(task _columns))
@ -139,8 +138,10 @@ task_dates=(
)
local -a task_zshids
_regex_words values 'task IDs' $_task_zshids
task_zshids=("$reply[@]")
if (( $#_task_zshids )); then
_regex_words values 'task IDs' $_task_zshids
task_zshids=("$reply[@]")
fi
_regex_words values 'task frequencies' \
'daily:Every day' \

View File

@ -8,7 +8,7 @@ local active_text=reverse
# This doesn't cover scripts named "[0-9]## *", which should be very rare
# (#s) is ^, (#e) is $, # is *, ## is + (comparing to regex)
# | is alternative, but only in ()
local NLIST_COLORING_PATTERN="((#s) #[0-9]## |[[][^]]#](#e)|[^ 0-9/?\\\\][^/\\\\]#(#e)|[^ /\\\\]##[^0-9/\\\\ ]##[^/\\\\]#(#e))"
local NLIST_COLORING_PATTERN="((#s) #[0-9]## |[[][^]]#](#e)|[^ 0-9/?\\\\][^/\\\\]#(#e))"
local NLIST_COLORING_COLOR=$'\x1b[00;33m'
local NLIST_COLORING_MATCH_MULTIPLE=1

View File

@ -6,7 +6,7 @@ local bold=0
local colorpair="white/black"
# Should draw the border?
local border=1
local border=0
# Combinations of colors to try out with Ctrl-T and Ctrl-G
# The last number is the bold option, 0 or 1

View File

@ -1,11 +1,11 @@
autoload colors
colors
local h1="$fg_bold[cyan]"
local h1="$fg_bold[magenta]"
local h2="$fg_bold[green]"
local h3="$fg_bold[blue]"
local h4="$fg_bold[yellow]"
local h5="$fg_bold[magenta]"
local h5="$fg_bold[cyan]"
local rst="$reset_color"
LESS="-iRc" less <<<"
@ -93,4 +93,43 @@ start. This is a way to have handy set of bookmarks prepared in private
history's file.
Private history is instantly shared among sessions.
${h1}Zshrc integration${rst}
There are 5 standard configuration variables that can be set in zshrc:
${h4}znt_history_active_text${rst}
\"underline\" or \"reverse\" - how should be active element highlighted
${h4}znt_history_nlist_coloring_pattern${rst}
Pattern that can be used to colorize elements
${h4}znt_history_nlist_coloring_color${rst}
Color with which to colorize via the pattern
${h4}znt_history_nlist_coloring_match_multiple${rst}
Should multiple matches be colorized (${h2}\"0\"${rst} or ${h2}\"1\"${rst})
${h4}znt_history_keywords ${h2}(array)${rst}
Search keywords activated with Ctrl-X, F2, Ctrl-/, e.g. ( ${h2}\"git\"${rst} ${h2}\"vim\"${rst} )
Above variables will work for n-history tool. For other tools, change
\"_history_\" to e.g. \"_cd_\", for the n-cd tool. The same works for
all 8 tools.
Common configuration of the tools uses variables with \"_list_\" in them:
${h4}znt_list_bold${rst}
Should draw text in bold (${h2}\"0\"${rst} or ${h2}\"1\"${rst})
${h4}znt_list_colorpair${rst}
Main pair of colors to be used, e.g ${h2}\"green/black\"${rst}
${h4}znt_list_border${rst}
Should draw borders around windows (${h2}\"0\"${rst} or ${h2}\"1\"${rst})
${h4}znt_list_themes ${h2}(array)${rst}
List of themes to try out with Ctrl-T, e.g. ( ${h2}\"white/black/1\"${rst}
${h2}\"green/black/0\"${rst} )
${h4}znt_list_instant_select${rst}
Should pressing enter in search mode leave tool (${h2}\"0\"${rst} or ${h2}\"1\"${rst})
If you used ZNT before v2.1.12 then remove old configuration files
${h3}~/.config/znt/*.conf${rst} so that ZNT can update them to the latest versions
that support integration with Zshrc. If you used installer then run it
again (after the remove of configuration files), that is not needed when
using as plugin.
"

View File

@ -157,7 +157,7 @@ _nhistory_generate_most_frequent() {
vk+="$v"$'\t'"$k"
done
print -rl "$title" "${(On)vk[@]}" > "$most_frequent_db"
print -rl -- "$title" "${(On)vk[@]}" > "$most_frequent_db"
}
# Load configuration
@ -337,16 +337,16 @@ if [ "$REPLY" -gt 0 ]; then
selected="$reply[REPLY]"
# ZLE?
if [ "${(t)CURSOR}" = "integer-local-special" ]; then
zle redisplay
zle kill-buffer
zle .redisplay
zle .kill-buffer
LBUFFER+="$selected"
# Append to private history
local newline=$'\n'
selected="${selected//$newline/\\$newline}"
[ "$active_view" = "0" ] && print -r "$selected" >> "$private_history_db"
[ "$active_view" = "0" ] && print -r -- "$selected" >> "$private_history_db"
else
print -zr "$selected"
print -zr -- "$selected"
fi
else
[ "${(t)CURSOR}" = "integer-local-special" ] && zle redisplay

View File

@ -445,7 +445,10 @@ while (( 1 )); do
[ "$border" = "1" ] && zcurses border main
local top_msg=" F1-change view, ${(C)ZSH_NAME} $ZSH_VERSION, shell level $SHLVL "
local top_msg=" ${(C)ZSH_NAME} $ZSH_VERSION, shell level $SHLVL "
if [[ "${NLIST_ENABLED_EVENTS[(r)F1]}" = "F1" ]]; then
top_msg=" F1-change view,$top_msg"
fi
zcurses move main 0 $(( term_width / 2 - $#top_msg / 2 ))
zcurses string main $top_msg

View File

@ -53,7 +53,7 @@ plugins=(git)
# User configuration
export PATH=$HOME/bin:/usr/local/bin:$PATH
# export PATH="/usr/bin:/bin:/usr/sbin:/sbin:$PATH"
# export MANPATH="/usr/local/man:$MANPATH"
source $ZSH/oh-my-zsh.sh

View File

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

View File

@ -80,12 +80,6 @@ main() {
" ~/.zshrc > ~/.zshrc-omztemp
mv -f ~/.zshrc-omztemp ~/.zshrc
printf "${BLUE}Copying your current PATH and adding it to the end of ~/.zshrc for you.${NORMAL}\n"
sed "/export PATH=/ c\\
export PATH=\"$PATH\"
" ~/.zshrc > ~/.zshrc-omztemp
mv -f ~/.zshrc-omztemp ~/.zshrc
# If this user's login shell is not already "zsh", attempt to switch.
TEST_CURRENT_SHELL=$(expr "$SHELL" : '.*/\(.*\)')
if [ "$TEST_CURRENT_SHELL" != "zsh" ]; then