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

Merge branch 'master' into clipboard

parents d81cd753 368198b7
# hitokoto plugin
Displays a random quote taken from [hitokoto.cn](https://v1.hitokoto.cn/)
Created by [Sinrimin](https://github.com/sinrimin)
## Usage
Add the plugin to the plugins array in your zshrc file and restart zsh:
```zsh
plugins=(... hitokoto)
```
Then, run `hitokoto` to get a new random quote.
if ! (( $+commands[curl] )); then
echo "hitokoto plugin needs curl to work" >&2
return
fi
function hitokoto {
emulate -L zsh
Q=$(curl -s --connect-timeout 2 "https://v1.hitokoto.cn" | jq -j '.hitokoto+"\t"+.from')
TXT=$(echo "$Q" | awk -F '\t' '{print $1}')
WHO=$(echo "$Q" | awk -F '\t' '{print $2}')
[[ -n "$WHO" && -n "$TXT" ]] && print -P "%F{3}${WHO}%f: “%F{5}${TXT}%f”"
}
# Homestead basic command completion
_homestead_get_command_list () {
homestead --no-ansi | sed "1,/Available commands/d" | awk '/^ +[a-z]+/ { print $1 }'
homestead --no-ansi | sed -E "1,/(Available|Common) commands/d" | awk '/^ +[a-z]+/ { print $1 }'
}
_homestead () {
......
# Ionic plugin
This plugin adds completion for the [Ionic CLI](https://ionicframework.com/docs/cli),
as well as some aliases for common Ionic commands.
To use it, add `ionic` to the plugins array in your zshrc file:
```zsh
plugins=(... ionic)
```
## Aliases
| Alias | Command | Description |
|-------|--------------------------------------|------------------------------------------------------------------|
| iv | `ionic --version` | Check Ionic version |
| ih | `ionic --help` | Ionic help command |
| ist | `ionic start` | Create a new project |
| ii | `ionic info` | Print system/environment info |
| is | `ionic serve` | Start a local dev server for app dev/testing |
| icba | `ionic cordova build android` | Build web assets and prepare app for android platform targets |
| icbi | `ionic cordova build ios` | Build web assets and prepare app for ios platform targets |
| icra | `ionic cordova run android` | Run an Ionic project on a connected android device |
| icri | `ionic cordova run ios` | Run an Ionic project on a connected ios device |
| icrsa | `ionic cordova resources android` | Automatically create icon and splash screen resources for android|
| icrsi | `ionic cordova resources ios` | Automatically create icon and splash screen resources for ios |
| icpaa | `ionic cordova platform add android` | Add Cordova android platform targets |
| icpai | `ionic cordova platform add ios` | Add Cordova ios platform targets |
| icpra | `ionic cordova platform rm android` | Remove Cordova platform targets |
| icpri | `ionic cordova platform rm ios` | Remove Cordova platform targets |
alias iv="ionic --version"
alias ih="ionic --help"
alias ist="ionic start"
alias ii="ionic info"
alias is="ionic serve"
alias icba="ionic cordova build android"
alias icbi="ionic cordova build ios"
alias icra="ionic cordova run android"
alias icri="ionic cordova run ios"
alias icrsa="ionic cordova resources android"
alias icrsi="ionic cordova resources ios"
alias icpaa="ionic cordova platform add android"
alias icpai="ionic cordova platform add ios"
alias icpra="ionic cordova platform rm android"
alias icpri="ionic cordova platform rm ios"
......@@ -15,7 +15,7 @@ if [[ $FOUND_JENV -eq 0 ]]; then
fi
if [[ $FOUND_JENV -eq 1 ]]; then
export PATH="${jenvdir}/bin:$PATH"
(( $+commands[jenv] )) || export PATH="${jenvdir}/bin:$PATH"
eval "$(jenv init - zsh)"
function jenv_prompt_info() { jenv version-name 2>/dev/null }
......
# JFrog CLI
This plugin provides completion for [JFrog CLI](https://github.com/jfrog/jfrog-cli).
JFrog CLI provides a simple interface that automates access to [Artifactory](https://jfrog.com/artifactory), [Xray](https://jfrog.com/xray), [Bintray](https://jfrog.com/bintray) and [Mission Control](https://jfrog.com/mission-control) through their respective REST APIs.
To use it, add `jfrog` to the plugins array in your zshrc file:
```zsh
plugins=(... jfrog)
```
_jfrog() {
local -a opts
opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} --generate-bash-completion)}")
_describe 'values' opts
if [[ $compstate[nmatches] -eq 0 && $words[$CURRENT] != -* ]]; then
_files
fi
}
compdef _jfrog jfrog
\ No newline at end of file
## JHBuild
# JHBuild
This plugin adds some [JHBuild](https://developer.gnome.org/jhbuild/) aliases.
To use it, add `jhbuild` to the plugins array of your zshrc file:
```zsh
plugins=(... jhbuild)
```
**Maintainer:** [Miguel Vaello](https://github.com/miguxbe)
This plugin adds some jhbuild aliases and increase the completion function provided by zsh.
## Aliases
| Alias | Command |
|---------|---------------------------|
| `jh` | `jhbuild` |
| `jhb` | `jhbuild build` |
| `jhbo` | `jhbuild buildone` |
| `jhckb` | `jhbuild checkbranches` |
| `jhckm` | `jhbuild checkmodulesets` |
| `jhi` | `jhbuild info` |
| `jhl` | `jhbuild list` |
| `jhc` | `jhbuild clean` |
| `jhco` | `jhbuild cleanone` |
| `jhm` | `jhbuild make` |
| `jhr` | `jhbuild run` |
| `jhrd` | `jhbuild rdepends` |
| `jhsd` | `jhbuild sysdeps` |
| `jhu` | `jhbuild update` |
| `jhuo` | `jhbuild updateone` |
| `jhun` | `jhbuild uninstall` |
| `jhsh` | `jhbuild shell` |
| `jht` | `jhbuild tinderbox` |
# Aliases
#
# JHBuild Aliases
# Base
alias jh='jhbuild'
# Build
alias jhb='jhbuild build'
......@@ -7,12 +8,14 @@ alias jhbo='jhbuild buildone'
# Checks
alias jhckb='jhbuild checkbranches'
alias jhckm='jhbuild checkmodulesets'
# Info & list
# Info & List
alias jhi='jhbuild info'
alias jhl='jhbuild list'
# Clean
alias jhc='jhbuild clean'
alias jhco='jhbuild cleanone'
# Make
alias jhm='jhbuild make'
# Run
alias jhr='jhbuild run'
# Depends
......@@ -23,6 +26,7 @@ alias jhu='jhbuild update'
alias jhuo='jhbuild updateone'
# Uninstall
alias jhun='jhbuild uninstall'
# Shell
alias jhsh='jhbuild shell'
# Tinderbox
alias jht='jhbuild tinderbox'
# JRuby plugin
This plugin adds aliases for [JRuby](https://www.jruby.org/).
To use it, add `jruby` to the plugins array in your zshrc file:
```zsh
plugins=(... jruby)
```
## Requirements
This plugin assumes you already have jruby installed and available in your [path](https://www.jruby.org/getting-started).
## Aliases
| Alias | Command |
| ------------ | ---------------------------------------------------------------- |
| `jrspec` | `jruby --debug -S rspec --debug` |
| `jprofile` | `jruby --profile.api -S rspec` |
| `jexec` | `jruby -S` |
......@@ -11,9 +11,10 @@ if [[ $(whence node) != "" && ( "x$JSONTOOLS_METHOD" = "x" || "x$JSONTOOLS_METH
alias urlencode_json='xargs -0 node -e "console.log(encodeURIComponent(process.argv[1]))"'
alias urldecode_json='xargs -0 node -e "console.log(decodeURIComponent(process.argv[1]))"'
elif [[ $(whence python) != "" && ( "x$JSONTOOLS_METHOD" = "x" || "x$JSONTOOLS_METHOD" = "xpython" ) ]]; then
alias pp_json='python -mjson.tool'
alias pp_json='python -c "import sys; del sys.path[0]; import runpy; runpy._run_module_as_main(\"json.tool\")"'
alias is_json='python -c "
import json, sys;
import sys; del sys.path[0];
import json;
try:
json.loads(sys.stdin.read())
except ValueError, e:
......@@ -22,11 +23,13 @@ else:
print True
sys.exit(0)"'
alias urlencode_json='python -c "
import urllib, json, sys;
import sys; del sys.path[0];
import urllib, json;
print urllib.quote_plus(sys.stdin.read())
sys.exit(0)"'
alias urldecode_json='python -c "
import urllib, json, sys;
import sys; del sys.path[0];
import urllib, json;
print urllib.unquote_plus(sys.stdin.read())
sys.exit(0)"'
elif [[ $(whence ruby) != "" && ( "x$JSONTOOLS_METHOD" = "x" || "x$JSONTOOLS_METHOD" = "xruby" ) ]]; then
......
......@@ -17,3 +17,15 @@ plugins=(... jump)
| `mark [mark-name]` | Create a mark with the given name or with the name of the current directory if none is provided |
| `unmark <mark-name>` | Remove the given mark |
| `marks` | List the existing marks and the directories they point to |
## Key bindings
Pressing `CTRL`+`G` substitutes the written mark name for the full path of the mark.
For example, with a mark named `mymark` pointing to `/path/to/my/mark`:
```zsh
$ cp /tmp/file mymark<C-g>
```
will become:
```zsh
$ cp /tmp/file /path/to/my/mark
```
......@@ -9,33 +9,34 @@
export MARKPATH=$HOME/.marks
jump() {
cd -P "$MARKPATH/$1" 2>/dev/null || {echo "No such mark: $1"; return 1}
builtin cd -P "$MARKPATH/$1" 2>/dev/null || {echo "No such mark: $1"; return 1}
}
mark() {
if [[ ( $# == 0 ) || ( "$1" == "." ) ]]; then
MARK=$(basename "$PWD")
if [[ $# -eq 0 || "$1" = "." ]]; then
MARK=${PWD:t}
else
MARK="$1"
fi
if read -q \?"Mark $PWD as ${MARK}? (y/n) "; then
mkdir -p "$MARKPATH"; ln -sfn "$PWD" "$MARKPATH/$MARK"
if read -q "?Mark $PWD as ${MARK}? (y/n) "; then
command mkdir -p "$MARKPATH"
command ln -sfn "$PWD" "$MARKPATH/$MARK"
fi
}
unmark() {
rm -i "$MARKPATH/$1"
LANG= command rm -i "$MARKPATH/$1"
}
marks() {
local max=0
for link in $MARKPATH/*(@); do
local link max=0
for link in $MARKPATH/{,.}*(@N); do
if [[ ${#link:t} -gt $max ]]; then
max=${#link:t}
fi
done
local printf_markname_template="$(printf -- "%%%us " "$max")"
for link in $MARKPATH/*(@); do
for link in $MARKPATH/{,.}*(@N); do
local markname="$fg[cyan]${link:t}$reset_color"
local markpath="$fg[blue]$(readlink $link)$reset_color"
printf -- "$printf_markname_template" "$markname"
......@@ -44,21 +45,15 @@ marks() {
}
_completemarks() {
if [[ $(ls "${MARKPATH}" | wc -l) -gt 1 ]]; then
reply=($(ls $MARKPATH/**/*(-) | grep : | sed -E 's/(.*)\/([_a-zA-Z0-9\.\-]*):$/\2/g'))
else
if readlink -e "${MARKPATH}"/* &>/dev/null; then
reply=($(ls "${MARKPATH}"))
fi
fi
reply=("${MARKPATH}"/{,.}*(@N:t))
}
compctl -K _completemarks jump
compctl -K _completemarks unmark
_mark_expansion() {
setopt extendedglob
setopt localoptions extendedglob
autoload -U modify-current-argument
modify-current-argument '$(readlink "$MARKPATH/$ARG")'
modify-current-argument '$(readlink "$MARKPATH/$ARG" || echo "$ARG")'
}
zle -N _mark_expansion
bindkey "^g" _mark_expansion
......@@ -15,7 +15,7 @@ function _start_agent() {
zstyle -a :omz:plugins:keychain options options
# start keychain...
keychain ${^options:-} --agents ${agents:-gpg} ${^identities}
keychain ${^options:-} --agents ${agents:-gpg} ${^identities} --host $SHORT_HOST
# Get the filenames to store/lookup the environment from
_keychain_env_sh="$HOME/.keychain/$SHORT_HOST-sh"
......
# knife plugin
This plugin adds completion for [knife](https://docs.chef.io/knife.html), a command-line tool
to interact with [Chef](https://chef.io), a platform to automate and manage infrastructure via
code.
To use it, add `knife` to the plugins array in your zshrc file:
```zsh
plugins=(... knife)
```
## Options
- `KNIFE_RELATIVE_PATH`: if set to `true`, the completion script will look for local cookbooks
under the `cookbooks` folder in the chef root directory. It has preference over the other two
options below. **Default:** empty.
- `KNIFE_COOKBOOK_PATH`: if set, it points to the folder that contains local cookbooks, for
example: `/path/to/my/chef/cookbooks`. **Default:** `cookbook_path` field in `knife.rb`
(see below).
- `KNIFE_CONF_PATH`: variable pointing to the `knife.rb` configuration file, for example
`/path/to/my/.chef/knife.rb`. Only used if `$KNIFE_COOKBOOK_PATH` isn't set. If it exists,
`$PWD/.chef/knife.rb` is used instead. Otherwise, if it's set, its value is used.
**Default**: `$HOME/.chef/knife.rb`.
......@@ -9,7 +9,7 @@
# Read around where these are used for more detail.
# These flags should be available everywhere according to man knife
knife_general_flags=( --help --server-url --key --config --editor --format --log_level --logfile --no-editor --user --print-after --version --yes )
knife_general_flags=(--help --server-url --key --config --editor --format --log_level --logfile --no-editor --user --print-after --version --yes)
# knife has a very special syntax, some example calls are:
# knife status
......@@ -25,8 +25,8 @@ _knife() {
typeset -A opt_args
cloudproviders=(bluebox ec2 rackspace slicehost terremark)
_arguments \
'1: :->knifecmd'\
'2: :->knifesubcmd'\
'1: :->knifecmd' \
'2: :->knifesubcmd' \
'3: :->knifesubcmd2' \
'4: :->knifesubcmd3' \
'5: :->knifesubcmd4' \
......@@ -38,7 +38,7 @@ _knife() {
;;
knifesubcmd)
case $words[2] in
(bluebox|ec2|rackspace|slicehost|terremark)
bluebox|ec2|rackspace|slicehost|terremark)
compadd "$@" server images
;;
client)
......@@ -76,6 +76,7 @@ _knife() {
;;
*)
_arguments '2:Subsubcommands:($(_knife_options1))'
;;
esac
;;
knifesubcmd2)
......@@ -89,10 +90,10 @@ _knife() {
site)
compadd "$@" vendor show share search download list unshare
;;
(show|delete|edit)
show|delete|edit)
_arguments '3:Subsubcommands:($(_chef_$words[2]s_remote))'
;;
(upload|test)
upload|test)
_arguments '3:Subsubcommands:($(_chef_$words[2]s_local) --all)'
;;
list)
......@@ -103,6 +104,7 @@ _knife() {
;;
*)
_arguments '3:Subsubcommands:($(_knife_options2))'
;;
esac
;;
knifesubcmd3)
......@@ -113,12 +115,14 @@ _knife() {
versioncomp=1
_arguments '4:Cookbookversions:($(_cookbook_versions) latest)'
;;
(node|client|role)
node|client|role)
compadd "$@" --attribute
;;
esac
;;
esac
case $words[4] in
(show|edit)
show|edit)
_arguments '4:Subsubsubcommands:($(_chef_$words[2]_$words[3]s_remote))'
;;
file)
......@@ -134,6 +138,7 @@ _knife() {
;;
*)
_arguments '*:Subsubcommands:($(_knife_options3))'
;;
esac
;;
list)
......@@ -141,17 +146,18 @@ _knife() {
;;
*)
_arguments '*:Subsubcommands:($(_knife_options3))'
;;
esac
;;
knifesubcmd4)
if (( versioncomp > 0 )); then
if ((versioncomp > 0)); then
compadd "$@" attributes definitions files libraries providers recipes resources templates
else
case $words[5] in
file)
_arguments '*:directory:_path_files -/ -W "$(_chef_root)/data_bags" -qS \ '
;;
*) _arguments '*:Subsubcommands:($(_knife_options2))'
*) _arguments '*:Subsubcommands:($(_knife_options2))' ;;
esac
fi
;;
......@@ -162,21 +168,23 @@ _knife() {
;;
*)
_arguments '*:Subsubcommands:($(_knife_options3))'
;;
esac
;;
esac
}
# Helper functions to provide the argument completion for several depths of commands
_knife_options1() {
( for line in $( knife $words[2] --help | grep -v "^knife" ); do echo $line | grep "\-\-"; done )
(for line in $(knife $words[2] --help | grep -v "^knife"); do echo $line | grep "\-\-"; done)
}
_knife_options2() {
( for line in $( knife $words[2] $words[3] --help | grep -v "^knife" ); do echo $line | grep "\-\-"; done )
(for line in $(knife $words[2] $words[3] --help | grep -v "^knife"); do echo $line | grep "\-\-"; done)
}
_knife_options3() {
( for line in $( knife $words[2] $words[3] $words[4] --help | grep -v "^knife" ); do echo $line | grep "\-\-"; done )
(for line in $(knife $words[2] $words[3] $words[4] --help | grep -v "^knife"); do echo $line | grep "\-\-"; done)
}
# The chef_x_remote functions use knife to get a list of objects of type x on the server
......@@ -217,7 +225,7 @@ _chef_cookbooks_local() {
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/' )}
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)
}
......@@ -229,10 +237,9 @@ _cookbook_versions() {
# 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 () {
_chef_root() {
directory="$PWD"
while [ $directory != '/' ]
do
while [ $directory != '/' ]; do
test -e "$directory/.chef" && echo "$directory" && return
directory="${directory:h}"
done
......
# knife_ssh plugin
This plugin adds a `knife_ssh` function as well as completion for it, to allow
connecting via ssh to servers managed with [Chef](https://www.chef.io/).
To use it, add `knife_ssh` to the plugins array in your zshrc file:
```zsh
plugins=(... knife_ssh)
```
The plugin creates a cache of the Chef node list via `knife`, and stores it
in `$HOME/.knife_comp~`, when first triggering knife_ssh completion.
**Requirements:** `knife` has to be installed.
function knife_ssh() {
grep -q $1 ~/.knife_comp~ 2> /dev/null || rm -f ~/.knife_comp~;
grep -q $1 ~/.knife_comp~ 2> /dev/null || rm -f ~/.knife_comp~
ssh $(knife node show $1 | awk '/IP:/{print $2}')
}
_knife_ssh() {
if hash knife 2>/dev/null; then
if [[ ! -f ~/.knife_comp~ ]]; then
echo "\nGenerating ~/.knife_comp~..." >/dev/stderr
echo "\nGenerating ~/.knife_comp~..." >&2
knife node list > ~/.knife_comp~
fi
compadd $(<~/.knife_comp~)
compadd $(< ~/.knife_comp~)
else
echo "Could not find knife" > /dev/stderr;
echo "Could not find knife" >&2
fi
}
......
......@@ -53,10 +53,13 @@ plugins=(
kube-ps1
)
# After the "source Oh My Zsh" line
PROMPT=$PROMPT'$(kube_ps1) '
# Or in double quotes, don't forget to escape
PROMPT=$PROMPT"\$(kube_ps1) "
```
Note: the `PROMPT` example above was tested with the theme `robbyrussell`
Note: The `PROMPT` example above was tested with the theme `robbyrussell`.
## Enabling / Disabling on the current shell
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment