More completion functions, and helpers
This commit is contained in:
parent
c2dde89fb3
commit
cc8f5b32ab
|
@ -0,0 +1,39 @@
|
||||||
|
#compdef apt-key=gpg
|
||||||
|
|
||||||
|
local -a args reply matchany keycomp keyfile advopts
|
||||||
|
|
||||||
|
# matches any word
|
||||||
|
matchany=(/$'[^\0]##\0'/)
|
||||||
|
# key file completion
|
||||||
|
keyfile=($matchany ':file:file:_files')
|
||||||
|
# key completion
|
||||||
|
function _apt_keys()
|
||||||
|
{
|
||||||
|
local expl keys
|
||||||
|
local -a disp
|
||||||
|
keys=$(apt-key list | grep 'pub' | colrm 1 12 | colrm 9)
|
||||||
|
_wanted keys expl 'apt keys' compadd "$@" "$disp[@]" - "${(f)keys}"
|
||||||
|
}
|
||||||
|
keycomp=(/$'[A-F0-9]##\0'/ ":key:key:_apt_keys")
|
||||||
|
advopts=( \( $matchany ':option:option:{compset -n 2;_dispatch -command- gpg}' \) \# )
|
||||||
|
#_dispatch $cmd:t $cmd $cmd:t -default- && ret=0
|
||||||
|
args=$matchany
|
||||||
|
_regex_words command "command" \
|
||||||
|
'add:add the key contained in file (use \"-\" for stdin):$keyfile' \
|
||||||
|
'del:remove a key:$keycomp' \
|
||||||
|
'export:output a key:$keycomp' \
|
||||||
|
'exportall:output all trusted keys.' \
|
||||||
|
'update:update keys using the keyring package.' \
|
||||||
|
'net-update:update keys using the network.' \
|
||||||
|
'list:list keys.' \
|
||||||
|
'finger:list fingerprints.' \
|
||||||
|
'adv:pass advanced options to gpg (download key).:$advopts'
|
||||||
|
args+=("$reply[@]")
|
||||||
|
|
||||||
|
_regex_arguments _apt-key "${args[@]}"
|
||||||
|
|
||||||
|
_apt-key "$@"
|
||||||
|
|
||||||
|
# Local Variables:
|
||||||
|
# mode:shell-script
|
||||||
|
# End:
|
|
@ -0,0 +1,20 @@
|
||||||
|
#compdef autorandr
|
||||||
|
|
||||||
|
local -a profiles
|
||||||
|
|
||||||
|
profiles=$(ls ~/.autorandr)
|
||||||
|
|
||||||
|
# Example of call to _arguments function with one option and one argument
|
||||||
|
_arguments : {-h,--help}'[show help]' \
|
||||||
|
{-c,--change}'[reload current setup]' \
|
||||||
|
'--fingerprint[fingerprint your current hardware setup]' \
|
||||||
|
'--force[force (re)loading of a profile]' \
|
||||||
|
'--config[dump your current xrandr setup]' \
|
||||||
|
{-s,--save}'[save your current setup to profile]:profile:{compadd -X "Profile" ${(f)profiles}}' \
|
||||||
|
{-l,--load}'[load profile]:profile:{compadd -X "Profile" ${(f)profiles}}' \
|
||||||
|
{-d,--default}'[set the default profile]:profile:{compadd -X "Profile" ${(f)profiles}}'
|
||||||
|
|
||||||
|
|
||||||
|
# Local Variables:
|
||||||
|
# mode:shell-script
|
||||||
|
# End:
|
|
@ -0,0 +1,164 @@
|
||||||
|
#compdef bitcoind bitcoin
|
||||||
|
|
||||||
|
|
||||||
|
local -a matchbcaddr matchtxid matchany matchnum matchalpha matchhex matchipaddr matchtruefalse node filedir comment
|
||||||
|
local -a amount passphrase blockhash
|
||||||
|
# matches a bitcoin address
|
||||||
|
matchbcaddr=(/$'[13][[:alnum:]]##\0'/ ':bcaddress:bitcoin address:')
|
||||||
|
# matches a transaction ID
|
||||||
|
matchtxid=(/$'[[:xdigit:]]##\0'/ ':txid:transaction ID:')
|
||||||
|
# matches any word
|
||||||
|
matchany=(/$'[^\0]##\0'/)
|
||||||
|
# matches any number
|
||||||
|
matchnum=(/$'[[:digit:]]##\0'/)
|
||||||
|
# matches any word with lowercase letters
|
||||||
|
matchalpha=(/$'[[:alpha:]]##\0'/)
|
||||||
|
# matches any hexadecimal number
|
||||||
|
matchhex=(/$'[[:xdigit:]]##\0'/)
|
||||||
|
# matches an IPv4 address
|
||||||
|
matchipaddr=(/$'[[:digit:]][[:digit:]]\.[[:digit:]][[:digit:]]\.[[:digit:]][[:digit:]]\.[[:digit:]][[:digit:]]\0'/
|
||||||
|
':ipaddress:IPv4 address:( )')
|
||||||
|
# match true/false
|
||||||
|
matchtruefalse=(/$'(true|false)\0'/)
|
||||||
|
# function for completing account names
|
||||||
|
function _bitcoin_accounts()
|
||||||
|
{
|
||||||
|
local expl bcaccounts
|
||||||
|
local -a disp
|
||||||
|
if [[ `hostname` == samsung ]]; then
|
||||||
|
bcaccounts=$(bitcoind listaccounts | cut -f 2 -d \" | sed '/./!d;$d;1d')
|
||||||
|
else
|
||||||
|
bcaccounts=$(ssh samsung bitcoind listaccounts | cut -f 2 -d \" | sed '/./!d;$d;1d')
|
||||||
|
fi
|
||||||
|
_wanted accounts expl 'bitcoin accounts' compadd "$@" "$disp[@]" - "${(f)bcaccounts}"
|
||||||
|
}
|
||||||
|
node=($matchany ':node:bitcoin node:')
|
||||||
|
filedir=($matchany ':file:file or directory:_files')
|
||||||
|
comment=($matchany ':comment:comment:')
|
||||||
|
amount=($matchnum ':amount:amount of bitcoins to move:')
|
||||||
|
passphrase=($matchany ':passphrase:wallet passphrase:')
|
||||||
|
blockhash=($matchhex ':hash:block hash:')
|
||||||
|
|
||||||
|
local -a createmultisig addmultisigaddress addnode bccmds bcaccount minconf dns getaddednodeinfo getbalance
|
||||||
|
local -a getblocktemplate getrawtransaction getreceivedbyaddress getreceivedbyaccount gettxout getwork importprivkey
|
||||||
|
local -a listaccounts listreceivedbyaddress listreceivedbyaccount listsinceblock listtransactions listunspent
|
||||||
|
local -a move sendfrom sendmany sendrawtransaction sendtoaddress setgenerate settxfee signmessage signrawtransaction
|
||||||
|
local -a submitblock verifymessage walletpassphrase walletpassphrasechange decoderawtransaction setaccount
|
||||||
|
|
||||||
|
createmultisig=($matchnum ':nrequired:No of keys required to spend funds:' $matchany ':addresses:comma separated list of bitcoin addresses:')
|
||||||
|
bcaccount=($matchany ':account:bitcoin account:_bitcoin_accounts')
|
||||||
|
addmultisigaddress=($createmultisig $bcaccount)
|
||||||
|
addnode=($node /$'(add|remove|onetry)\0'/ ':action:action:(add remove onetry)')
|
||||||
|
bccmds=($matchalpha ':command:bitcoind command:(addmultisigaddress addnode backupwallet createmultisig createrawtransaction decoderawtransaction dumpprivkey getaccount getaccountaddress getaddednodeinfo getaddressesbyaccount getbalance getblock getblockcount getblockhash getblocktemplate getconnectioncount getdifficulty getgenerate gethashespersec getinfo getmemorypool getmininginfo getnewaddress getpeerinfo getrawchangeaddress getrawmempool getrawtransaction getreceivedbyaccount getreceivedbyaddress gettransaction gettxout gettxoutsetinfo getwork importprivkey keypoolrefill listaccounts listaddressgroupings listreceivedbyaccount listreceivedbyaddress listsinceblock listtransactions listunspent listlockunspent lockunspent move sendfrom sendmany sendrawtransaction sendtoaddress setaccount setgenerate settxfee signmessage signrawtransaction stop submitblock validateaddress verifymessage walletlock walletpassphrase walletpassphrasechange)' )
|
||||||
|
minconf=($matchnum ':number:Min number of confirmations required (default 1):')
|
||||||
|
getaddednodeinfo=($matchtruefalse ':dns:include dns info?:(true false)' $node)
|
||||||
|
getbalance=($bcaccount $minconf)
|
||||||
|
getblockhash=($matchnum ':index:index of block:')
|
||||||
|
getblocktemplate=($matchany ':params:(optional) parameters:')
|
||||||
|
getrawtransaction=($matchtxid $matchnum ':verbose:(optional) verbose:')
|
||||||
|
getreceivedbyaccount=($bcaccount $minconf)
|
||||||
|
getreceivedbyaddress=($matchbcaddr $minconf)
|
||||||
|
gettxout=($matchtxid $matchnum ':num:num:' $matchtruefalse ':includemempool:include memory pool:(true false)')
|
||||||
|
getwork=($matchany ':data:data:')
|
||||||
|
importprivkey=($matchany ':privkey:private key:' $matchany ':label:label:' $matchtruefalse ':rescan:rescan:(true false)')
|
||||||
|
decoderawtransaction=($matchhex ":hexnum:hexadecimal No.:")
|
||||||
|
listaccounts=($minconf)
|
||||||
|
listreceivedbyaddress=($minconf $matchtruefalse ':includeempty:include empty accounts:(true false)')
|
||||||
|
listreceivedbyaccount=($listreceivedbyaddress)
|
||||||
|
listsinceblock=($blockhash $matchnum ':number:Number of target confirmations:')
|
||||||
|
listtransactions=($bcaccount $matchnum ':number:max number of transactions to list:' $matchnum ':number:number of initial transactions to skip:')
|
||||||
|
listunspent=($minconf $matchnum ':number:Max number of confirmations required:' $matchbcaddr)
|
||||||
|
move=($bcaccount $bcaccount $amount $minconf $comment)
|
||||||
|
sendfrom=($bcaccount $matchbcaddr $amount $minconf $comment $comment)
|
||||||
|
sendmany=($bcaccount $matchany ':amounts:addresses & amounts:' $minconf $comment)
|
||||||
|
sendrawtransaction=($matchhex ':transaction:raw transaction hex string:')
|
||||||
|
sendtoaddress=($matchbcaddr $amount $comment $comment)
|
||||||
|
setaccount=($matchbcaddr $bcaccount)
|
||||||
|
setgenerate=($matchtruefalse ':generate:generation on:' $matchnum ':limit:processors limit (-1 = unlimited):')
|
||||||
|
settxfee=($amount)
|
||||||
|
signmessage=($matchbcaddr $comment)
|
||||||
|
signrawtransaction=($matchhex ':transaction:hex-encoded transaction:')
|
||||||
|
submitblock=($matchhex ':hexdata:hex block data:')
|
||||||
|
verifymessage=($matchbcaddr $matchany ':signature:signature:' $comment)
|
||||||
|
walletpassphrase=($passphrase $matchnum ':number:timeout in seconds:')
|
||||||
|
walletpassphrasechange=($passphrase $passphrase)
|
||||||
|
|
||||||
|
local -a args reply
|
||||||
|
# Command word. Don't care what that is.
|
||||||
|
args=( $matchany )
|
||||||
|
|
||||||
|
_regex_words command "bitcoin command" \
|
||||||
|
'addmultisigaddress:Add a nrequired-to-sign multisignature address to the wallet:$addmultisigaddress' \
|
||||||
|
'addnode:Attempts to add or remove a node from the addnode list or try a connection to node once:$addnode' \
|
||||||
|
'backupwallet:Safely copy wallet.dat to a destination (a directory or filepath.):$filedir' \
|
||||||
|
'createmultisig:Creates a multi-signature address and returns a json object:$createmultisig' \
|
||||||
|
'createrawtransaction:Create a raw transaction spending given inputs.' \
|
||||||
|
'decoderawtransaction:Produce human-readable JSON object for a raw transaction.:$decoderawtransaction' \
|
||||||
|
'dumpprivkey:Reveal private key corresponding to bitcoin address.:$matchbcaddr' \
|
||||||
|
'getaccount:Return account associated with the given address.:$matchbcaddr' \
|
||||||
|
'getaccountaddress:Return current bitcoin address for receiving payments to this account.:$bcaccount' \
|
||||||
|
'getaddednodeinfo:Return information about the given added node, or all added nodes:$getaddednodeinfo' \
|
||||||
|
'getaddressesbyaccount:Return list of addresses for the given account.:$bcaccount' \
|
||||||
|
'getbalance:If account is not specified, returns the servers total available balance.:$getbalance' \
|
||||||
|
'getblock:Return information about the block with the given hash.:$blockhash' \
|
||||||
|
'getblockcount:Return number of blocks in the longest block chain.' \
|
||||||
|
'getblockhash:Return hash of block in best-block-chain at index (index 0 is the genesis block):$getblockhash' \
|
||||||
|
'getblocktemplate:Return data needed to construct a block to work on.:$getblocktemplate' \
|
||||||
|
'getconnectioncount:Return number of connections to other nodes.' \
|
||||||
|
'getdifficulty:Return proof-of-work difficulty as a multiple of the minimum difficulty.' \
|
||||||
|
'getgenerate:Return true or false whether bitcoind is currently generating hashes' \
|
||||||
|
'gethashespersec:Return a recent hashes per second performance measurement while generating.' \
|
||||||
|
'getinfo:Return an object containing various state info.' \
|
||||||
|
'getmemorypool:Replaced with getblocktemplate, submitblock, getrawmempool:$submitblock' \
|
||||||
|
'getmininginfo:Return an object containing mining-related information:' \
|
||||||
|
'getnewaddress:Return a new bitcoin address for receiving payments.:$bcaccount' \
|
||||||
|
'getpeerinfo:Return data about each connected node.' \
|
||||||
|
'getrawchangeaddress:Return a new Bitcoin address, for receiving change.' \
|
||||||
|
'getrawmempool:Return all transaction ids in memory pool.' \
|
||||||
|
'getrawtransaction:Return raw transaction representation for given transaction id.:$getrawtransaction' \
|
||||||
|
'getreceivedbyaccount:Return total amount received by addresses in account.:$getreceivedbyaccount' \
|
||||||
|
'getreceivedbyaddress:Return amount received by bitcoin address.:$getreceivedbyaddress' \
|
||||||
|
'gettransaction:Return an object about the given transaction:$matchtxid' \
|
||||||
|
'gettxout:Return details about an unspent transaction output:$gettxout' \
|
||||||
|
'gettxoutsetinfo:Return statistics about the unspent transaction output set' \
|
||||||
|
'getwork:Return formatted hash data (data not specified) to work on or try to solve block (data specified).:$getwork' \
|
||||||
|
'help:List commands, or get help for a command.:$bccmds' \
|
||||||
|
'importprivkey:Adds a private key (as returned by dumpprivkey) to your wallet.:$importprivkey' \
|
||||||
|
'keypoolrefill:Fills the keypool, requires wallet passphrase to be set.' \
|
||||||
|
'listaccounts:Return Object that has account names as keys, account balances as values.:$listaccounts' \
|
||||||
|
'listaddressgroupings:Return all addresses in the wallet and info used for coincontrol.' \
|
||||||
|
'listreceivedbyaccount:Return an array of objects containing account, amount, and confirmations:$listreceivedbyaccount' \
|
||||||
|
'listreceivedbyaddress:Return an array of objects containing address, account, amount, and confirmations:$listreceivedbyaddress' \
|
||||||
|
'listsinceblock:Get all transactions in blocks since block blockhash, or all transactions if omitted.:$listsinceblock' \
|
||||||
|
'listtransactions:Return most recent transactions.:$listtransactions' \
|
||||||
|
'listunspent:Return array of unspent transaction inputs in the wallet.:$listunspent' \
|
||||||
|
'listlockunspent:Return list of temporarily unspendable outputs:' \
|
||||||
|
'lockunspent:Updates list of temporarily unspendable outputs' \
|
||||||
|
'move:Move from one account in your wallet to another' \
|
||||||
|
'sendfrom:Send given amount to given address.:$sendfrom' \
|
||||||
|
'sendmany:Send given amounts to given addresses.:$sendmany' \
|
||||||
|
'sendrawtransaction:Submit raw transaction (serialized, hex-encoded) to local node and network.:$sendrawtransaction' \
|
||||||
|
'sendtoaddress:Send amount from wallet to bitcoin address.:$sendtoaddress' \
|
||||||
|
'setaccount:Set the account associated with the given address, or create a new address for account.:$setaccount' \
|
||||||
|
'setgenerate:Turn generation on or off.:$setgenerate' \
|
||||||
|
'settxfee:Set transaction fee.:$settxfee' \
|
||||||
|
'signmessage:Sign a message with the private key of an address.:$signmessage' \
|
||||||
|
'signrawtransaction:Add signatures to a raw transaction and return the resulting raw transaction.:$signrawtransaction' \
|
||||||
|
'stop:Stop bitcoin server.' \
|
||||||
|
'submitblock:Attempt to submit new block to network.:$submitblock' \
|
||||||
|
'validateaddress:Return information about bitcoin address.:$matchbcaddr' \
|
||||||
|
'verifymessage:Verify a signed message.:$verifymessage' \
|
||||||
|
'walletlock:Remove the wallet encryption key from memory, locking the wallet.' \
|
||||||
|
'walletpassphrase:Store the wallet decryption key in memory.:$walletpassphrase' \
|
||||||
|
'walletpassphrasechange:Change the wallet passphrase.:$walletpassphrasechange'
|
||||||
|
|
||||||
|
args+=("$reply[@]")
|
||||||
|
|
||||||
|
_regex_arguments _bitcoin "${args[@]}"
|
||||||
|
|
||||||
|
_bitcoin "$@"
|
||||||
|
|
||||||
|
|
||||||
|
# Local Variables:
|
||||||
|
# mode:shell-script
|
||||||
|
# End:
|
|
@ -0,0 +1,239 @@
|
||||||
|
#autoload
|
||||||
|
|
||||||
|
# Filename: _completion_helpers
|
||||||
|
# Description: Extra utility functions to help create zsh completion functions
|
||||||
|
# Author: Joe Bloggs <vapniks@yahoo.com>
|
||||||
|
# Copyleft (Ↄ) 2015, Joe Bloggs, all rites reversed.
|
||||||
|
# Created: 2015-12-19 19:00:00
|
||||||
|
# By: Joe Bloggs
|
||||||
|
# URL: https://github.com/vapniks/zsh-completions
|
||||||
|
|
||||||
|
## License:
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 3, or (at your option)
|
||||||
|
# any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; see the file COPYING.
|
||||||
|
# If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
# To use the following functions add a call to "_completion_helpers" in your completion script,
|
||||||
|
# in order to load this file first.
|
||||||
|
|
||||||
|
# This function joins together groups of consecutive lines. The first line in each group is identified by having
|
||||||
|
# less initial whitespace that subsequent lines in the group (i.e. it is indented less).
|
||||||
|
# This is useful for preprocessing the output from a command called with its --help argument.
|
||||||
|
# The function reads input from a pipe and takes the following three arguments:
|
||||||
|
# 1) A separator to place between joined lines.
|
||||||
|
# 2) A regular expression matching the initial line of each group. All lines subsequent to the initial line will
|
||||||
|
# be appended to it (after removing leading & trailing whitespace) until the next initial line of a group.
|
||||||
|
# Alternatively this argument can be the maximum number of leading whitespace chars for the initial line.
|
||||||
|
# Any lines with more than this many leading whitespace chars will be appended to previous lines.
|
||||||
|
# 3) An optional regular expression matching the line before the beginning of the section of output to be processed.
|
||||||
|
# If this is set to the empty string then processing will start from the beginning of the output.
|
||||||
|
# 4) An optional regular expression matching the line after the end of the section of output to be processed
|
||||||
|
# (if this arg is omitted then all output upto the last line will be processed).
|
||||||
|
function _join_lines() {
|
||||||
|
awk -v SEP="$1" -v ARG2="$2" -v START="$3" -v END2="$4" 'BEGIN {if(START==""){f=1}{f=0};
|
||||||
|
if(ARG2 ~ "^[0-9]+"){LINE1 = "^[[:space:]]{,"ARG2"}[^[:space:]]"}else{LINE1 = ARG2}}
|
||||||
|
($0 ~ END2 && f>0 && END2!="") {exit}
|
||||||
|
($0 ~ START && f<1) {f=1; if(length(START)!=0){next}}
|
||||||
|
($0 ~ LINE1 && f>0) {if(f<2){f=2; printf("%s",$0)}else{printf("\n%s",$0)}; next}
|
||||||
|
(f>1) {gsub(/^[[:space:]]+|[[:space:]]+$/,"",$0); printf("%s%s",SEP, $0); next}
|
||||||
|
END {print ""}'
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function can be used to extract parts of lines into arrays. This is useful for extracting
|
||||||
|
# completion information about commands by using the --help option.
|
||||||
|
# It takes a variable number of arguments: a regexp (first arg), and the names of any number
|
||||||
|
# array variables (other args).
|
||||||
|
# For each line of input piped into the function it will try and match the regexp on the line
|
||||||
|
# and save each parenthesised subexpression into one of the arrays (first subexpression into
|
||||||
|
# the first array, second subexpression into the second array, etc.)
|
||||||
|
# For each line that doesn't match the regexp empty elements will be added to the arrays.
|
||||||
|
# If a line matches but a subexpressions doesn't then whatever is stored in the corresponding
|
||||||
|
# element of $match (see zsh documentation) will be used instead.
|
||||||
|
function _extract_parts() {
|
||||||
|
OLDIFS=$IFS;IFS=;
|
||||||
|
while read -r inputtxt; do
|
||||||
|
local i=2 rx="${*[1]}" matched="no"
|
||||||
|
if [[ "$inputtxt" =~ "$rx" ]]; then
|
||||||
|
matched="yes"
|
||||||
|
fi
|
||||||
|
while [[ "$i" -le "$#" ]]; do
|
||||||
|
local arr="${*[$i]}"
|
||||||
|
if [[ -n "$arr" ]]; then
|
||||||
|
if [[ "$matched" =~ "yes" ]]; then
|
||||||
|
eval "$arr+=\$match[$i-1]"
|
||||||
|
else
|
||||||
|
eval "$arr+=''"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
let i=i+1
|
||||||
|
done
|
||||||
|
done
|
||||||
|
IFS=$OLDIFS
|
||||||
|
}
|
||||||
|
|
||||||
|
# Given three arrays of strings, apply _regex_words to triples formed by taking corresponding elements
|
||||||
|
# from the arrays. The result will be stored in the $reply array, and can be viewed with: echo "${reply[@]}"
|
||||||
|
# See documentation of _regex_words for more info.
|
||||||
|
# This command takes 5 arguments:
|
||||||
|
# 1) A tag name for the resulting call to _regex_words
|
||||||
|
# 2) A description for the call to _regex_words
|
||||||
|
# 3) The name of an array var containing completion words (each used in first part of a _regex_words spec)
|
||||||
|
# 4) The name of an array var containing descriptions (each used in second part of a _regex_words spec)
|
||||||
|
# 5) Optionally: the name of an array var containing further completions (each used in third part of a _regex_words spec)
|
||||||
|
# 6) Optionally: the name of an array var in which to store the results from _regex_words
|
||||||
|
# (otherwise they can be found in ${reply[@]})
|
||||||
|
function _arrays_to_regex_words() {
|
||||||
|
local opts="${*[3]}" descs="${*[4]}" args="${*[5]}"
|
||||||
|
local -a regexwords
|
||||||
|
local i=1 desc
|
||||||
|
while [[ "$i" -le "${(@P)#opts}" ]]; do
|
||||||
|
desc="${${${${${(@P)descs}[$i]//:/-}//\[/(}//]/)}//\'/}"
|
||||||
|
regexwords+="${${(@P)opts}[$i]}:$desc:${${(@P)args}[$i]}"
|
||||||
|
let i=i+1
|
||||||
|
done
|
||||||
|
_regex_words "$1" "$2" "${regexwords[@]}"
|
||||||
|
if [[ -n "${*[6]}" ]]; then
|
||||||
|
set -A "${*[6]}" "${reply[@]}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function can be used for substituting values in an indexed array (1st arg) according to rules defined in another
|
||||||
|
# associative array (2nd arg)
|
||||||
|
# Any elements of the indexed array that match a key of the associative array will be replaced with the corresponding value
|
||||||
|
# of the associative array.
|
||||||
|
# This can be used for replacing option argument names (extracted from command help info) with corresponding definitions
|
||||||
|
# for _regex_words (also using _arrays_to_regex_words).
|
||||||
|
function _replace_vals_in_array() {
|
||||||
|
local vals="$1" arg2="$2"
|
||||||
|
typeset -A repls
|
||||||
|
set -A repls "${(kvP@)arg2}"
|
||||||
|
local i=1 newval val repl
|
||||||
|
while [[ "$i" -le "${(P)#vals}" ]]; do
|
||||||
|
val="${${(@P)vals}[i]}"
|
||||||
|
repl="${repls[$val]}"
|
||||||
|
if [[ -n "$repl" ]]; then
|
||||||
|
typeset -g "$vals""[$i]"="$repl"
|
||||||
|
fi
|
||||||
|
let i=i+1
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function makes multiple substitutions in the input string and outputs the result.
|
||||||
|
# It takes a single argument: the name of an associative array whose keys are the strings
|
||||||
|
# to be replaced and whose values are the replacements.
|
||||||
|
_multi_substitute () {
|
||||||
|
local instring="$(cat)"
|
||||||
|
local key val
|
||||||
|
typeset -A repls
|
||||||
|
set -A repls "${(kvP@)1}"
|
||||||
|
for key in "${(k@)repls}"
|
||||||
|
do
|
||||||
|
val="${repls[$key]}"
|
||||||
|
instring="${instring//$key/$val}"
|
||||||
|
done
|
||||||
|
print "$instring"
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function creates an associative array from a pair of indexed arrays of keys and values.
|
||||||
|
# It takes the following arguments:
|
||||||
|
# 1) a name for the resulting associative array
|
||||||
|
# 2) the name of an indexed array of keys
|
||||||
|
# 3) the name of an indexed array of values (with order corresponding to the keys array)
|
||||||
|
# If there are fewer keys than values then any excess values will be omitted from the results.
|
||||||
|
# If there are more keys than values then the extra keys will not be assigned values
|
||||||
|
function _create_assoc_array() {
|
||||||
|
typeset -g -A "$1"
|
||||||
|
local i=1 key val
|
||||||
|
local keys="$2" vals="$3"
|
||||||
|
while [[ "$i" -le "${(P@)#keys}" ]]; do
|
||||||
|
key="${${(P@)keys}[$i]}"
|
||||||
|
val="${${(P@)vals}[$i]}"
|
||||||
|
typeset -g "$1""[$key]"="$val"
|
||||||
|
let i=i+1
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function tests whether its only argument is a shell option or not.
|
||||||
|
function _is_option() {
|
||||||
|
[[ -n "$1" ]] \
|
||||||
|
&& ( (setopt | grep "^$1\$" >/dev/null) \
|
||||||
|
|| (unsetopt | grep "^$1\$" >/dev/null) )
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function saves current shell option values to an associative array.
|
||||||
|
# The first argument can be the name of a variable to save the option to,
|
||||||
|
# or an option name.
|
||||||
|
# All other arguments are names of options to save. If the first argument
|
||||||
|
# is an option name then it save with the other option name arguments into
|
||||||
|
# the SAVED_SHELL_OPTIONS variable instead.
|
||||||
|
# The options can be restored using the _restore_options function.
|
||||||
|
function _save_options() {
|
||||||
|
local savename
|
||||||
|
if _is_option "$1"; then
|
||||||
|
savename=SAVED_SHELL_OPTIONS
|
||||||
|
else
|
||||||
|
savename="$1"
|
||||||
|
shift
|
||||||
|
fi
|
||||||
|
local -a opts states
|
||||||
|
opts=("$@")
|
||||||
|
local i=1
|
||||||
|
while [[ "$i" -le "${#opts}" ]]; do
|
||||||
|
if ( setopt | grep "^$opts[i]\$" > /dev/null ); then
|
||||||
|
states[i]=on
|
||||||
|
elif ( unsetopt | grep "^$opts[i]\$" > /dev/null ); then
|
||||||
|
states[i]=off
|
||||||
|
else
|
||||||
|
echo "Invalid option $opts[i] !"
|
||||||
|
fi
|
||||||
|
let i=i+1
|
||||||
|
done
|
||||||
|
_create_assoc_array "$savename" opts states
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function is used for restoring options previously saved with _save_options
|
||||||
|
# The first argument can be the name of a variable containing the saved options,
|
||||||
|
# or an option name. All other arguments are the names of options to restore.
|
||||||
|
# If no option names are supplied then all saved options will be restored.
|
||||||
|
# If the first argument is an option name, then it will be restored with the other
|
||||||
|
# option name arguments from the SAVED_SHELL_OPTIONS variable instead.
|
||||||
|
# If there are no arguments then all options in SAVED_SHELL_OPTIONS will be restored.
|
||||||
|
function _restore_options () {
|
||||||
|
local savename
|
||||||
|
if _is_option "$1"; then
|
||||||
|
savename=SAVED_SHELL_OPTIONS
|
||||||
|
else
|
||||||
|
savename="$1"
|
||||||
|
shift
|
||||||
|
fi
|
||||||
|
typeset -A savedoptions
|
||||||
|
set -A savedoptions "${(kvP@)savename}"
|
||||||
|
local -a opts
|
||||||
|
opts=("$@")
|
||||||
|
local opt state
|
||||||
|
for opt in "${(k@)savedoptions}"; do
|
||||||
|
if [[ "${#opts}" -eq 0 || "${opts[(r)$opt]}" == "$opt" ]]; then
|
||||||
|
state="${savedoptions[$opt]}"
|
||||||
|
if [[ "$state" =~ "on" ]]; then
|
||||||
|
setopt "$opt"
|
||||||
|
elif [[ "$state" =~ "off" ]]; then
|
||||||
|
unsetopt "$opt"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Local Variables:"
|
||||||
|
# mode:sh"
|
||||||
|
# End:"
|
|
@ -0,0 +1,15 @@
|
||||||
|
#compdef csvtool
|
||||||
|
|
||||||
|
# zsh completion for csvtool
|
||||||
|
|
||||||
|
_arguments -s -w \
|
||||||
|
'-t[Input separator char (use -t TAB for tab separated input)]:char:{_guard "*" "separator char or \"TAB\""}' \
|
||||||
|
'-u[Output separator char (use -u TAB for tab separated output)]:char:{_guard "*" "separator char or \"TAB\""}' \
|
||||||
|
'-o[Write output to file (instead of stdout)]:filenames:_files' \
|
||||||
|
'-z[Number columns from 0 instead of 1]' \
|
||||||
|
'(--help)-help[Display help]' \
|
||||||
|
"1:Commands:((col\:'Return one or more columns from the CSV file' namedcol\:'Return one or more named columns (assuming first row contains column headings)' width\:'Print maximum width of CSV file (number of columns in widest row)' height\:'Print number of rows in the CSV file' setcolumns\:'Set the number of columns' setrows\:'Take the first N rows (add padding if necessary)' head\:'Take the first N rows (no padding is added)' drop\:'Drop the first N rows' cat\:'Concatenate input files vertically (rowwise)' paste\:'Concatenate input files horizontally (columnwise)' pastecol\:'replace columns of 1st file with those of 2nd file' join\:'merge multiple CSV files together' square\:'make all rows have the same length' trim\:'trim the empty cells at the top/left/right/bottom of the CSV file'sub\:'take a square subset of the CSV file' replace\:'replace rows in 1st file with matching rows in 2nd file' transpose\:'transpose lines and columns of the CSV file' call\:'call external command/function on each row of CSV file'))"
|
||||||
|
|
||||||
|
# Local Variables:
|
||||||
|
# mode:shell-script
|
||||||
|
# End:
|
|
@ -0,0 +1,9 @@
|
||||||
|
#autoload
|
||||||
|
|
||||||
|
# Function for completing currency codes
|
||||||
|
|
||||||
|
_alternative 'currency:currency:((AED\:"United Arab Emirates Dirham" AFN\:"Afghan Afghani" ALL\:"Albanian Lek" AMD\:"Armenian Dram" ANG\:"Netherlands Antillean Guilder" AOA\:"Angolan Kwanza" ARS\:"Argentine Peso" AUD\:"Australian Dollar" AWG\:"Aruban Florin" AZN\:"Azerbaijani Manat" BAM\:"Bosnia-Herzegovina Convertible Mark" BBD\:"Barbadian Dollar" BDT\:"Bangladeshi Taka" BGN\:"Bulgarian Lev" BHD\:"Bahraini Dinar" BIF\:"Burundian Franc" BMD\:"Bermudan Dollar" BND\:"Brunei Dollar" BOB\:"Bolivian Boliviano" BRL\:"Brazilian Real" BSD\:"Bahamian Dollar" BTC\:"Bitcoin" BTN\:"Bhutanese Ngultrum" BWP\:"Botswanan Pula" BYR\:"Belarusian Ruble" BZD\:"Belize Dollar" CAD\:"Canadian Dollar" CDF\:"Congolese Franc" CHF\:"Swiss Franc" CLF\:"Chilean Unit of Account (UF)" CLP\:"Chilean Peso" CNH\:"CNH" CNY\:"Chinese Yuan" COP\:"Colombian Peso" CRC\:"Costa Rican Colón" CUP\:"Cuban Peso" CVE\:"Cape Verdean Escudo" CZK\:"Czech Republic Koruna" DEM\:"German Mark" DJF\:"Djiboutian Franc" DKK\:"Danish Krone" DOP\:"Dominican Peso" DZD\:"Algerian Dinar" EGP\:"Egyptian Pound" ERN\:"Eritrean Nakfa" ETB\:"Ethiopian Birr" EUR\:"Euro" FIM\:"Finnish Markka" FJD\:"Fijian Dollar" FKP\:"Falkland Islands Pound" FRF\:"French Franc" GBP\:"British Pound Sterling" GEL\:"Georgian Lari" GHS\:"Ghanaian Cedi" GIP\:"Gibraltar Pound" GMD\:"Gambian Dalasi" GNF\:"Guinean Franc" GTQ\:"Guatemalan Quetzal" GYD\:"Guyanaese Dollar" HKD\:"Hong Kong Dollar" HNL\:"Honduran Lempira" HRK\:"Croatian Kuna" HTG\:"Haitian Gourde" HUF\:"Hungarian Forint" IDR\:"Indonesian Rupiah" IEP\:"Irish Pound" ILS\:"Israeli New Sheqel" INR\:"Indian Rupee" IQD\:"Iraqi Dinar" IRR\:"Iranian Rial" ISK\:"Icelandic Króna" ITL\:"Italian Lira" JMD\:"Jamaican Dollar" JOD\:"Jordanian Dinar" JPY\:"Japanese Yen" KES\:"Kenyan Shilling" KGS\:"Kyrgystani Som" KHR\:"Cambodian Riel" KMF\:"Comorian Franc" KPW\:"North Korean Won" KRW\:"South Korean Won" KWD\:"Kuwaiti Dinar" KYD\:"Cayman Islands Dollar" KZT\:"Kazakhstani Tenge" LAK\:"Laotian Kip" LBP\:"Lebanese Pound" LKR\:"Sri Lankan Rupee" LRD\:"Liberian Dollar" LSL\:"Lesotho Loti" LTL\:"Lithuanian Litas" LVL\:"Latvian Lats" LYD\:"Libyan Dinar" MAD\:"Moroccan Dirham" MDL\:"Moldovan Leu" MGA\:"Malagasy Ariary" MKD\:"Macedonian Denar" MMK\:"Myanmar Kyat" MNT\:"Mongolian Tugrik" MOP\:"Macanese Pataca" MRO\:"Mauritanian Ouguiya" MUR\:"Mauritian Rupee" MVR\:"Maldivian Rufiyaa" MWK\:"Malawian Kwacha" MXN\:"Mexican Peso" MYR\:"Malaysian Ringgit" MZN\:"Mozambican Metical" NAD\:"Namibian Dollar" NGN\:"Nigerian Naira" NIO\:"Nicaraguan Córdoba" NOK\:"Norwegian Krone" NPR\:"Nepalese Rupee" NZD\:"New Zealand Dollar" OMR\:"Omani Rial" PAB\:"Panamanian Balboa" PEN\:"Peruvian Nuevo Sol" PGK\:"Papua New Guinean Kina" PHP\:"Philippine Peso" PKG\:"PKG" PKR\:"Pakistani Rupee" PLN\:"Polish Zloty" PYG\:"Paraguayan Guarani" QAR\:"Qatari Rial" RON\:"Romanian Leu" RSD\:"Serbian Dinar" RUB\:"Russian Ruble" RWF\:"Rwandan Franc" SAR\:"Saudi Riyal" SBD\:"Solomon Islands Dollar" SCR\:"Seychellois Rupee" SDG\:"Sudanese Pound" SEK\:"Swedish Krona" SGD\:"Singapore Dollar" SHP\:"Saint Helena Pound" SLL\:"Sierra Leonean Leone" SOS\:"Somali Shilling" SRD\:"Surinamese Dollar" STD\:"São Tomé and Príncipe Dobra" SVC\:"Salvadoran Colón" SYP\:"Syrian Pound" SZL\:"Swazi Lilangeni" THB\:"Thai Baht" TJS\:"Tajikistani Somoni" TMT\:"Turkmenistani Manat" TND\:"Tunisian Dinar" TOP\:"Tongan Paanga" TRY\:"Turkish Lira" TTD\:"Trinidad and Tobago Dollar" TWD\:"New Taiwan Dollar" TZS\:"Tanzanian Shilling" UAH\:"Ukrainian Hryvnia" UGX\:"Ugandan Shilling" USD\:"US Dollar" UYU\:"Uruguayan Peso" UZS\:"Uzbekistan Som" VEF\:"Venezuelan Bolívar" VND\:"Vietnamese Dong" VUV\:"Vanuatu Vatu" WST\:"Samoan Tala" XAF\:"CFA Franc BEAC" XCD\:"East Caribbean Dollar" XDR\:"Special Drawing Rights" XOF\:"CFA Franc BCEAO" XPF\:"CFP Franc" YER\:"Yemeni Rial" ZAR\:"South African Rand" ZMK\:"Zambian Kwacha (1968–2012)" ZMW\:"Zambian Kwacha" ZWL\:"Zimbabwean Dollar (2009)"))'
|
||||||
|
|
||||||
|
# Local Variables:"
|
||||||
|
# mode:shell-script"
|
||||||
|
# End:"
|
|
@ -0,0 +1,15 @@
|
||||||
|
#compdef dglob
|
||||||
|
|
||||||
|
_arguments : '-a[Search through all available packages, not just installed ones.]' \
|
||||||
|
'-f[List all files in the matched packages.]' \
|
||||||
|
'-0[When listing files (with -f) use "\0" as a separator instead of a newline.]' \
|
||||||
|
'-r[The pattern of the current simple filter is a standard POSIX regular expression.]' \
|
||||||
|
'-e[Regard the pattern of the current simple filter as an extended POSIX regular expression.]' \
|
||||||
|
'-i[Ignore case when looking for a match in the current simple filter.]' \
|
||||||
|
'-X[Do an exact match (as opposed to a substring match) in the current simple filter.]' \
|
||||||
|
'-v[Instead of showing all the paragraphs that match, show those paragraphs that do not match.]' \
|
||||||
|
"1:pattern:{_guard \"[^ ]#\" 'pattern'}"
|
||||||
|
|
||||||
|
# Local Variables:
|
||||||
|
# mode:shell-script
|
||||||
|
# End:
|
|
@ -0,0 +1,157 @@
|
||||||
|
#compdef dig
|
||||||
|
#
|
||||||
|
# Based on dig(1) version "DiG 9.9.1-P1". Incomplete, see XXX.
|
||||||
|
|
||||||
|
local curcontext="$curcontext" state line
|
||||||
|
typeset -A opt_args
|
||||||
|
|
||||||
|
local -aU dnsclasses
|
||||||
|
# taken from http://www.bind9.net/dns-parameters
|
||||||
|
dnsclasses=(IN CH HS)
|
||||||
|
|
||||||
|
# Though probably a better idea to do something like this elsewhere:
|
||||||
|
# typeset -aU dns_servers
|
||||||
|
# dns_servers=('\:\:1' 8.8.4.4 8.8.8.8 othernsnameorip..)
|
||||||
|
if [[ ${#dns_servers} -eq 0 ]]; then
|
||||||
|
dns_servers=${(z)${(Mz)${(f)"$(</etc/resolv.conf)"}:#nameserver *}:#nameserver}
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Did not include +[no]defname as is deprecated
|
||||||
|
#
|
||||||
|
# XXX this option problematic due to - in option name, even with \hypen:
|
||||||
|
# '*+trusted\-key=[trusted key when chasing DNSSEC]:keyfile:_files' \
|
||||||
|
_arguments -C -s \
|
||||||
|
'(- *)-h[display help]' \
|
||||||
|
'(- *)-v[display version]' \
|
||||||
|
'(-4 -6)-4[IPv4 lookups]' \
|
||||||
|
'(-4 -6)-6[IPv6 lookups]' \
|
||||||
|
'(-c)-c[query class]:class:->dnsclass' \
|
||||||
|
'(-f)-f[batch mode file]:file:_files' \
|
||||||
|
'(-i)-i[older IP6.INT IPv6 reverse lookup method]' \
|
||||||
|
'(-k)-k[TSIG key file]:file:_files' \
|
||||||
|
'(-m)-m[enable memory usage debugging]' \
|
||||||
|
'(-b)-b[bind to address]:addr:->bindaddr' \
|
||||||
|
'(-p)-p[bind to port]:port:_ports' \
|
||||||
|
'(-q)-q[query name]:name:' \
|
||||||
|
'(-t)-t[query type]:type:->dnstype' \
|
||||||
|
'(-x)-x[IP address]:_ip' \
|
||||||
|
'(-y)-y[hmac name and key data (unsafe)]:authinfo' \
|
||||||
|
'*+novc' \
|
||||||
|
'*+vc[TCP Mode]' \
|
||||||
|
'*+notcp' \
|
||||||
|
'*+tcp[TCP mode, alternate syntax]' \
|
||||||
|
'*+time=[set query timeout]:timeout:' \
|
||||||
|
'*+tries=[set number of UDP attempts]:count:' \
|
||||||
|
'*+retry=[set number of UDP retries]:count' \
|
||||||
|
'*+domain=[set default domainname]:domain:_hosts' \
|
||||||
|
'*+bufsize=[set EDNS0 max UDP packet size]:number:' \
|
||||||
|
'*+ndots=[set NDOTS value]:value:' \
|
||||||
|
'*+edns=[set EDNS version]:version:' \
|
||||||
|
'*+nosearch' \
|
||||||
|
'*+search[set whether to use searchlist]' \
|
||||||
|
'*+noshowsearch' \
|
||||||
|
'*+showsearch[search with intermediate results]' \
|
||||||
|
'*+norecurse' \
|
||||||
|
'*+recurse[recursive mode]' \
|
||||||
|
'*+noignore' \
|
||||||
|
'*+ignore[do not revert to TCP for TC responses]' \
|
||||||
|
'*+nofail' \
|
||||||
|
'*+fail[do not try next server on SERVFAIL]' \
|
||||||
|
'*+nobesteffort' \
|
||||||
|
'*+besteffort[try to parse even illegal messages]' \
|
||||||
|
'*'{+noaaonly,+noaaflag} \
|
||||||
|
'*'{+aaonly,+aaflag}'[set AA flag in query]' \
|
||||||
|
'*+noadflag' \
|
||||||
|
'*+adflag[set AD flag in query]' \
|
||||||
|
'*+nocdflag' \
|
||||||
|
'*+cdflag[set CD flag in query]' \
|
||||||
|
'*+nocl' \
|
||||||
|
'*+cl[control display of class in records]' \
|
||||||
|
'*+nocmd' \
|
||||||
|
'*+cmd[control display of command line]' \
|
||||||
|
'*+nocomments' \
|
||||||
|
'*+comments[control display of comment lines]' \
|
||||||
|
'*+norrcomments' \
|
||||||
|
'*+rrcomments[control display of per-record comments]' \
|
||||||
|
'*+noquestion' \
|
||||||
|
'*+question[control display of question]' \
|
||||||
|
'*+noanswer' \
|
||||||
|
'*+answer[control display of answer]' \
|
||||||
|
'*+noauthority' \
|
||||||
|
'*+authority[control display of authority]' \
|
||||||
|
'*+noadditional' \
|
||||||
|
'*+additional[control display of additional]' \
|
||||||
|
'*+nostats' \
|
||||||
|
'*+stats[control display of statistics]' \
|
||||||
|
'*+noshort' \
|
||||||
|
'*+short[disable all except short form of answer]' \
|
||||||
|
'*+nottlid' \
|
||||||
|
'*+ttlid[control display of ttls]' \
|
||||||
|
'*+noall' \
|
||||||
|
'*+all[set all display flags]' \
|
||||||
|
'*+noqr' \
|
||||||
|
'*+qr[print question before sending]' \
|
||||||
|
'*+nonssearch' \
|
||||||
|
'*+nssearch[search all authoritative NS]' \
|
||||||
|
'*+noidentify' \
|
||||||
|
'*+identify[ID responders in short answers]' \
|
||||||
|
'*+notrace' \
|
||||||
|
'*+trace[trace delegation down from root]' \
|
||||||
|
'*+nodnssec' \
|
||||||
|
'*+dnssec[request DNSSEC records]' \
|
||||||
|
'*+nonsid' \
|
||||||
|
'*+nsid[request name server ID]' \
|
||||||
|
'*+sigchase)+nosigchase' \
|
||||||
|
'*+sigchase[chase DNSSEC signatures]' \
|
||||||
|
'*+notopdown' \
|
||||||
|
'*+topdown[do DNSSEC validation top down mode]' \
|
||||||
|
'*+nosplit' \
|
||||||
|
'*+split=[split hex/base64 fields into chunks]:value:' \
|
||||||
|
'*+nomultiline' \
|
||||||
|
'*+multiline[print records in a expanded format]' \
|
||||||
|
'*+noonesoa' \
|
||||||
|
'*+onesoa[AXFR prints only one SOA record]' \
|
||||||
|
'*: :->dnsquery' \
|
||||||
|
&& return 0
|
||||||
|
|
||||||
|
case "$state" in
|
||||||
|
bindaddr)
|
||||||
|
if compset -P '*[#]'; then
|
||||||
|
_ports
|
||||||
|
else
|
||||||
|
_bind_addresses
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
dnsclass)
|
||||||
|
_describe -t dnsclass 'DNS class' dnsclasses
|
||||||
|
;;
|
||||||
|
dnsquery)
|
||||||
|
# XXX need to support grammer, probably by keeping track of where
|
||||||
|
# the command line is in the following:
|
||||||
|
#
|
||||||
|
# Usage: dig [@global-server] [domain] [q-type] [q-class] {q-opt}
|
||||||
|
# {global-d-opt} host [@local-server] {local-d-opt}
|
||||||
|
# [ host [@local-server] {local-d-opt} [...]]
|
||||||
|
#
|
||||||
|
# but that is beyond my ability at present. So just complete hosts.
|
||||||
|
if compset -P '@'; then
|
||||||
|
_describe -t dnsserver 'DNS server' dns_servers
|
||||||
|
else
|
||||||
|
_wanted hosts expl server _hosts
|
||||||
|
|
||||||
|
# XXX this should instead be the count of non-@, -+, -- elements
|
||||||
|
# prior to the current position...
|
||||||
|
if [[ $#line -gt 1 ]]; then
|
||||||
|
local -a dnstypesshort
|
||||||
|
dnstypesshort=(ANY A NS CNAME SOA PTR HINFO MX TXT AAAA SRV IXFR AXFR)
|
||||||
|
_describe -t dnsquery 'DNS query' dnstypesshort
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
dnstype)
|
||||||
|
local -a dnstypes
|
||||||
|
# taken from http://www.bind9.net/dns-parameters and * swapped for 'ANY'
|
||||||
|
dnstypes=(ANY A NS MD MF CNAME SOA MB MG MR NULL WKS PTR HINFO MINFO MX TXT RP AFSDB X25 ISDN RT NSAP NSAP-PTR SIG KEY PX GPOS AAAA LOC NXT EID NIMLOC SRV ATMA NAPTR KX CERT A6 DNAME SINK OPT APL DS SSHFP IPSECKEY RRSIG NSEC DNSKEY DHCID NSEC3 NSEC3PARAM TLSA HIP NINFO RKEY TALINK CDS SPF UINFO UID GID UNSPEC TKEY TSIG IXFR AXFR MAILB MAILA URI CAA TA DLV)
|
||||||
|
_describe -t dnstype 'DNS type' dnstypes
|
||||||
|
;;
|
||||||
|
esac
|
|
@ -0,0 +1,151 @@
|
||||||
|
#compdef gsettings
|
||||||
|
|
||||||
|
_gsettings() {
|
||||||
|
_arguments : \
|
||||||
|
'--schemadir[A directory to search for additional schemas]:additional schema:_path_files -/' \
|
||||||
|
':gsettings command:_gsettings_commands' \
|
||||||
|
'*: :_gsettings_rest_args'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( $+functions[_gsettings_commands] )) || _gsettings_commands() {
|
||||||
|
local -a command_list
|
||||||
|
command_list=(
|
||||||
|
'help:show the help'
|
||||||
|
'list-schemas:list installed schemas'
|
||||||
|
'list-relocatable-schemas:list relocatable schemas'
|
||||||
|
'list-keys:list keys in a schema'
|
||||||
|
'list-children:list children of a schema'
|
||||||
|
'list-recursively:list keys and values, recursively'
|
||||||
|
'range:queries the range of a key'
|
||||||
|
'get:get the value of a key'
|
||||||
|
'set:set the value of a key'
|
||||||
|
'reset:reset the value of a key'
|
||||||
|
'reset-recursively:reset all values in a given schema'
|
||||||
|
'writable:check if a key is writable'
|
||||||
|
'monitor:watch for changes'
|
||||||
|
)
|
||||||
|
_describe -t commands 'gsettings commands' command_list
|
||||||
|
}
|
||||||
|
|
||||||
|
(( $+functions[_gsettings_rest_args] )) || _gsettings_rest_args() {
|
||||||
|
local CMD_IDX=2
|
||||||
|
local SCHEMA_IDX=3
|
||||||
|
local KEY_IDX=4
|
||||||
|
local VALUE_IDX=5
|
||||||
|
local offset=0
|
||||||
|
local opt_schemadir schemadir cmd schema key
|
||||||
|
|
||||||
|
if [[ $#words -ge 4 && "${(Q)words[2]}" == --schemadir ]]; then
|
||||||
|
opt_schemadir=--schemadir
|
||||||
|
schemadir="${(Q)words[3]}"
|
||||||
|
offset=2
|
||||||
|
fi
|
||||||
|
|
||||||
|
cmd="${(Q)words[CMD_IDX+offset]}"
|
||||||
|
|
||||||
|
case $((CURRENT-offset)) in
|
||||||
|
$SCHEMA_IDX)
|
||||||
|
case "$cmd" in
|
||||||
|
help)
|
||||||
|
_gsettings_help_targets
|
||||||
|
;;
|
||||||
|
list-keys|list-children|list-recursively|range|get|set|reset| \
|
||||||
|
reset-recursively|writable|monitor)
|
||||||
|
_gsettings_schemas "$opt_schemadir" "$schemadir"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
$KEY_IDX)
|
||||||
|
case "$cmd" in
|
||||||
|
get|set|range|reset|writable|monitor)
|
||||||
|
schema="${(Q)words[SCHEMA_IDX+offset]}"
|
||||||
|
_gsettings_keys "$opt_schemadir" "$schemadir" "$schema"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
$VALUE_IDX)
|
||||||
|
case "$cmd" in
|
||||||
|
set)
|
||||||
|
schema="${(Q)words[SCHEMA_IDX+offset]}"
|
||||||
|
key="${(Q)words[KEY_IDX+offset]}"
|
||||||
|
_gsettings_values "$opt_schemadir" "$schemadir" "$schema" "$key"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
(( $+functions[_gsettings_help_targets] )) || _gsettings_help_targets() {
|
||||||
|
local -a target_list
|
||||||
|
target_list=(
|
||||||
|
'help:show the help'
|
||||||
|
'list-schemas:list installed schemas'
|
||||||
|
'list-relocatable-schemas:list relocatable schemas'
|
||||||
|
'list-keys:list keys in a schema'
|
||||||
|
'list-children:list children of a schema'
|
||||||
|
'list-recursively:list keys and values, recursively'
|
||||||
|
'range:queries the range of a key'
|
||||||
|
'get:get the value of a key'
|
||||||
|
'set:set the value of a key'
|
||||||
|
'reset:reset the value of a key'
|
||||||
|
'reset-recursively:reset all values in a given schema'
|
||||||
|
'writable:check if a key is writable'
|
||||||
|
'monitor:watch for changes'
|
||||||
|
)
|
||||||
|
_describe -t help-target 'help targets' target_list
|
||||||
|
}
|
||||||
|
|
||||||
|
(( $+functions[_gsettings_schemas] )) || _gsettings_schemas() {
|
||||||
|
local -a schema_list
|
||||||
|
schema_list=(
|
||||||
|
${(@f)"$(gsettings $1 $2 list-schemas 2>/dev/null)"}
|
||||||
|
${(@f)"$(gsettings $1 $2 list-relocatable-schemas 2>/dev/null)"}
|
||||||
|
)
|
||||||
|
if [[ $#schema_list == 0 ]]; then
|
||||||
|
schema_list=(
|
||||||
|
${(@f)"$(gsettings list-schemas 2>/dev/null)"}
|
||||||
|
${(@f)"$(gsettings list-relocatable-schemas 2>/dev/null)"}
|
||||||
|
)
|
||||||
|
fi
|
||||||
|
_describe -t schemas 'schemas' schema_list -V
|
||||||
|
}
|
||||||
|
|
||||||
|
(( $+functions[_gsettings_keys] )) || _gsettings_keys() {
|
||||||
|
local -a key_list
|
||||||
|
key_list=(${(@f)"$(gsettings $1 $2 list-keys $3 2>/dev/null)"})
|
||||||
|
if [[ $#key_list == 0 ]]; then
|
||||||
|
key_list=(${(@f)"$(gsettings list-keys $3 2>/dev/null)"})
|
||||||
|
fi
|
||||||
|
_describe -t keys 'keys' key_list -V
|
||||||
|
}
|
||||||
|
|
||||||
|
# Complete possible values including bool and enum
|
||||||
|
(( $+functions[_gsettings_values] )) || _gsettings_values() {
|
||||||
|
local -a range
|
||||||
|
range=(${(@f)"$(gsettings $1 $2 range $3 $4 2>/dev/null)"})
|
||||||
|
if [[ $#range == 0 ]]; then
|
||||||
|
range=(${(@f)"$(gsettings range $3 $4 2>/dev/null)"})
|
||||||
|
fi
|
||||||
|
case "$range[1]" in
|
||||||
|
'type b')
|
||||||
|
_gsettings_complete_bool
|
||||||
|
;;
|
||||||
|
'enum')
|
||||||
|
_gsettings_complete_enum $range[2,-1]
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
(( $+functions[_gsettings_complete_bool] )) || _gsettings_complete_bool() {
|
||||||
|
local -a bool_list
|
||||||
|
bool_list=('true' 'false')
|
||||||
|
_describe -t val-bool 'possible values (bool)' bool_list -V
|
||||||
|
}
|
||||||
|
|
||||||
|
(( $+functions[_gsettings_complete_enum] )) || _gsettings_complete_enum() {
|
||||||
|
local -a enum_list
|
||||||
|
enum_list=(${(@Q)"${@}"})
|
||||||
|
_describe -t val-enum 'possible values' enum_list -V
|
||||||
|
}
|
||||||
|
|
||||||
|
_gsettings
|
|
@ -0,0 +1,89 @@
|
||||||
|
#compdef gsettings-info
|
||||||
|
|
||||||
|
_gsettings_info() {
|
||||||
|
_arguments : \
|
||||||
|
'--schemadir[A directory to search for additional schemas]:additional schema:_path_files -/' \
|
||||||
|
':gsettings_info command:_gsettings_info_commands' \
|
||||||
|
'*: :_gsettings_info_rest_args'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( $+functions[_gsettings_info_commands] )) || _gsettings_info_commands() {
|
||||||
|
local -a command_list
|
||||||
|
command_list=(
|
||||||
|
'help:show the help'
|
||||||
|
'summary:get the summary of keys'
|
||||||
|
'desc:get the description of keys'
|
||||||
|
'default:get the default value of keys'
|
||||||
|
'show:show the information of keys'
|
||||||
|
)
|
||||||
|
_describe -t commands 'gsettings commands' command_list
|
||||||
|
}
|
||||||
|
|
||||||
|
(( $+functions[_gsettings_info_rest_args] )) || _gsettings_info_rest_args() {
|
||||||
|
local CMD_IDX=2
|
||||||
|
local SCHEMA_IDX=3
|
||||||
|
local KEY_IDX=4
|
||||||
|
local offset=0
|
||||||
|
local opt_schemadir schemadir schema
|
||||||
|
|
||||||
|
if [[ $#words -ge 4 && "${(Q)words[2]}" == --schemadir ]]; then
|
||||||
|
opt_schemadir=--schemadir
|
||||||
|
schemadir="${(Q)words[3]}"
|
||||||
|
offset=2
|
||||||
|
fi
|
||||||
|
case "${(Q)words[CMD_IDX+offset]}" in
|
||||||
|
help)
|
||||||
|
_gsettings_info_help_targets
|
||||||
|
;;
|
||||||
|
summary|desc|default|show)
|
||||||
|
case $((CURRENT-offset)) in
|
||||||
|
$SCHEMA_IDX)
|
||||||
|
_gsettings_info_schemas "$opt_schemadir" "$schemadir"
|
||||||
|
;;
|
||||||
|
$KEY_IDX)
|
||||||
|
schema="${(Q)words[SCHEMA_IDX+offset]}"
|
||||||
|
_gsettings_info_keys "$opt_schemadir" "$schemadir" "$schema"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
(( $+functions[_gsettings_info_help_targets] )) ||
|
||||||
|
_gsettings_info_help_targets() {
|
||||||
|
local -a target_list
|
||||||
|
target_list=(
|
||||||
|
'help:show the help'
|
||||||
|
'summary:get the summary of keys'
|
||||||
|
'desc:get the description of keys'
|
||||||
|
'default:get the default value of keys'
|
||||||
|
'show:show the information of keys'
|
||||||
|
)
|
||||||
|
_describe -t help-target 'help targets' target_list
|
||||||
|
}
|
||||||
|
|
||||||
|
(( $+functions[_gsettings_info_schemas] )) || _gsettings_info_schemas() {
|
||||||
|
local -a schema_list
|
||||||
|
schema_list=(
|
||||||
|
${(@f)"$(gsettings $1 $2 list-schemas 2>/dev/null)"}
|
||||||
|
${(@f)"$(gsettings $1 $2 list-relocatable-schemas 2>/dev/null)"}
|
||||||
|
)
|
||||||
|
if [[ $#schema_list == 0 ]]; then
|
||||||
|
schema_list=(
|
||||||
|
${(@f)"$(gsettings list-schemas 2>/dev/null)"}
|
||||||
|
${(@f)"$(gsettings list-relocatable-schemas 2>/dev/null)"}
|
||||||
|
)
|
||||||
|
fi
|
||||||
|
_describe -t schemas 'schemas' schema_list -V
|
||||||
|
}
|
||||||
|
|
||||||
|
(( $+functions[_gsettings_info_keys] )) || _gsettings_info_keys() {
|
||||||
|
local -a key_list
|
||||||
|
key_list=(${(@f)"$(gsettings $1 $2 list-keys $3 2>/dev/null)"})
|
||||||
|
if [[ $#key_list == 0 ]]; then
|
||||||
|
key_list=(${(@f)"$(gsettings list-keys $3 2>/dev/null)"})
|
||||||
|
fi
|
||||||
|
_describe -t keys 'keys' key_list -V
|
||||||
|
}
|
||||||
|
|
||||||
|
_gsettings_info
|
|
@ -0,0 +1,18 @@
|
||||||
|
#compdef hoogle
|
||||||
|
|
||||||
|
# zsh completion for hoogle
|
||||||
|
|
||||||
|
_arguments -s -w \
|
||||||
|
"(-?)--help[Display help message]" \
|
||||||
|
"(--help)-?[Display help message]" \
|
||||||
|
"(-V)--version[Print version information]" \
|
||||||
|
"(--version)-V[Print version information]" \
|
||||||
|
"(-v)--verbose[Loud verbosity]" \
|
||||||
|
"(--verbose)-v[Loud verbosity]" \
|
||||||
|
"(-q)--quiet[Quiet verbosity]" \
|
||||||
|
"(--quiet)-q[Quiet verbosity]" \
|
||||||
|
"1:Commands:((\:'Perform a search (enter search term)' data\:'Generate Hoogle databases' server\:'Start a Hoogle server' combine\:'Combine multiple databases into one' convert\:'Convert an input file to a database' test\:'Run tests' dump\:'Dump sections of a database to stdout' rank\:'Generate ranking information' log\:'Analyse log files'))"
|
||||||
|
|
||||||
|
# Local Variables:
|
||||||
|
# mode:shell-script
|
||||||
|
# End:
|
|
@ -0,0 +1,160 @@
|
||||||
|
#compdef hub
|
||||||
|
|
||||||
|
# Zsh will source this file when attempting to autoload the "_hub" function,
|
||||||
|
# typically on the first attempt to complete the hub command. We define two new
|
||||||
|
# setup helper routines (one for the zsh-distributed version, one for the
|
||||||
|
# git-distributed, bash-based version). Then we redefine the "_hub" function to
|
||||||
|
# call "_git" after some other interception.
|
||||||
|
#
|
||||||
|
# This is pretty fragile, if you think about it. Any number of implementation
|
||||||
|
# changes in the "_git" scripts could cause problems down the road. It would be
|
||||||
|
# better if the stock git completions were just a bit more permissive about how
|
||||||
|
# it allowed third-party commands to be added.
|
||||||
|
|
||||||
|
(( $+functions[__hub_setup_zsh_fns] )) ||
|
||||||
|
__hub_setup_zsh_fns () {
|
||||||
|
(( $+functions[_git-alias] )) ||
|
||||||
|
_git-alias () {
|
||||||
|
_arguments \
|
||||||
|
'-s[output shell script suitable for eval]' \
|
||||||
|
'1::shell:(zsh bash csh)'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( $+functions[_git-browse] )) ||
|
||||||
|
_git-browse () {
|
||||||
|
_arguments \
|
||||||
|
'-u[output the URL]' \
|
||||||
|
'2::subpage:(wiki commits issues)'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( $+functions[_git-compare] )) ||
|
||||||
|
_git-compare () {
|
||||||
|
_arguments \
|
||||||
|
'-u[output the URL]' \
|
||||||
|
':[start...]end range:'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( $+functions[_git-create] )) ||
|
||||||
|
_git-create () {
|
||||||
|
_arguments \
|
||||||
|
'::name (REPOSITORY or ORGANIZATION/REPOSITORY):' \
|
||||||
|
'-p[make repository private]' \
|
||||||
|
'-d[description]:description' \
|
||||||
|
'-h[home page]:repository home page URL:_urls'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( $+functions[_git-fork] )) ||
|
||||||
|
_git-fork () {
|
||||||
|
_arguments \
|
||||||
|
'--no-remote[do not add a remote for the new fork]'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( $+functions[_git-pull-request] )) ||
|
||||||
|
_git-pull-request () {
|
||||||
|
_arguments \
|
||||||
|
'-f[force (skip check for local commits)]' \
|
||||||
|
'-b[base]:base ("branch", "owner\:branch", "owner/repo\:branch"):' \
|
||||||
|
'-h[head]:head ("branch", "owner\:branch", "owner/repo\:branch"):' \
|
||||||
|
- set1 \
|
||||||
|
'-m[message]' \
|
||||||
|
'-F[file]' \
|
||||||
|
- set2 \
|
||||||
|
'-i[issue]:issue number:' \
|
||||||
|
- set3 \
|
||||||
|
'::issue-url:_urls'
|
||||||
|
}
|
||||||
|
|
||||||
|
# stash the "real" command for later
|
||||||
|
functions[_hub_orig_git_commands]=$functions[_git_commands]
|
||||||
|
|
||||||
|
# Replace it with our own wrapper.
|
||||||
|
declare -f _git_commands >& /dev/null && unfunction _git_commands
|
||||||
|
_git_commands () {
|
||||||
|
local ret=1
|
||||||
|
# call the original routine
|
||||||
|
_call_function ret _hub_orig_git_commands
|
||||||
|
|
||||||
|
# Effectively "append" our hub commands to the behavior of the original
|
||||||
|
# _git_commands function. Using this wrapper function approach ensures
|
||||||
|
# that we only offer the user the hub subcommands when the user is
|
||||||
|
# actually trying to complete subcommands.
|
||||||
|
hub_commands=(
|
||||||
|
alias:'show shell instructions for wrapping git'
|
||||||
|
pull-request:'open a pull request on GitHub'
|
||||||
|
fork:'fork origin repo on GitHub'
|
||||||
|
create:'create new repo on GitHub for the current project'
|
||||||
|
browse:'browse the project on GitHub'
|
||||||
|
compare:'open GitHub compare view'
|
||||||
|
ci-status:'lookup commit in GitHub Status API'
|
||||||
|
)
|
||||||
|
_describe -t hub-commands 'hub command' hub_commands && ret=0
|
||||||
|
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
(( $+functions[__hub_setup_bash_fns] )) ||
|
||||||
|
__hub_setup_bash_fns () {
|
||||||
|
# TODO more bash-style fns needed here to complete subcommand args. They take
|
||||||
|
# the form "_git_CMD" where "CMD" is something like "pull-request".
|
||||||
|
|
||||||
|
# Duplicate and rename the 'list_all_commands' function
|
||||||
|
eval "$(declare -f __git_list_all_commands | \
|
||||||
|
sed 's/__git_list_all_commands/__git_list_all_commands_without_hub/')"
|
||||||
|
|
||||||
|
# Wrap the 'list_all_commands' function with extra hub commands
|
||||||
|
__git_list_all_commands() {
|
||||||
|
cat <<-EOF
|
||||||
|
alias
|
||||||
|
pull-request
|
||||||
|
fork
|
||||||
|
create
|
||||||
|
browse
|
||||||
|
compare
|
||||||
|
ci-status
|
||||||
|
EOF
|
||||||
|
__git_list_all_commands_without_hub
|
||||||
|
}
|
||||||
|
|
||||||
|
# Ensure cached commands are cleared
|
||||||
|
__git_all_commands=""
|
||||||
|
}
|
||||||
|
|
||||||
|
# redefine _hub to a much smaller function in the steady state
|
||||||
|
_hub () {
|
||||||
|
# only attempt to intercept the normal "_git" helper functions once
|
||||||
|
(( $+__hub_func_replacement_done )) ||
|
||||||
|
() {
|
||||||
|
# At this stage in the shell's execution the "_git" function has not yet
|
||||||
|
# been autoloaded, so the "_git_commands" or "__git_list_all_commands"
|
||||||
|
# functions will not be defined. Call it now (with a bogus no-op service
|
||||||
|
# to prevent premature completion) so that we can wrap them.
|
||||||
|
if declare -f _git >& /dev/null ; then
|
||||||
|
_hub_noop () { __hub_zsh_provided=1 } # zsh-provided will call this one
|
||||||
|
__hub_noop_main () { __hub_git_provided=1 } # git-provided will call this one
|
||||||
|
local service=hub_noop
|
||||||
|
_git
|
||||||
|
unfunction _hub_noop
|
||||||
|
unfunction __hub_noop_main
|
||||||
|
service=git
|
||||||
|
fi
|
||||||
|
|
||||||
|
if (( $__hub_zsh_provided )) ; then
|
||||||
|
__hub_setup_zsh_fns
|
||||||
|
elif (( $__hub_git_provided )) ; then
|
||||||
|
__hub_setup_bash_fns
|
||||||
|
fi
|
||||||
|
|
||||||
|
__hub_func_replacement_done=1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Now perform the actual completion, allowing the "_git" function to call our
|
||||||
|
# replacement "_git_commands" function as needed. Both versions expect
|
||||||
|
# service=git or they will call nonexistent routines or end up in an infinite
|
||||||
|
# loop.
|
||||||
|
service=git
|
||||||
|
declare -f _git >& /dev/null && _git
|
||||||
|
}
|
||||||
|
|
||||||
|
# make sure we actually attempt to complete on the first "tab" from the user
|
||||||
|
_hub
|
|
@ -0,0 +1,55 @@
|
||||||
|
#compdef mr
|
||||||
|
|
||||||
|
# completion for myrepos : http://myrepos.branchable.com/
|
||||||
|
|
||||||
|
local state
|
||||||
|
typeset -A opt_args
|
||||||
|
|
||||||
|
_arguments -s -w \
|
||||||
|
"1:Command:((bootstrap\:'Download a .mrconfig file from a URL and use it to checkout repositories into the specified directory.' \
|
||||||
|
checkout\:'Check out any repositories that are not already checked out.' \
|
||||||
|
ci\:'Commit changes to each repository.' \
|
||||||
|
co\:'Check out any repositories that are not already checked out.' \
|
||||||
|
commit\:'Commit changes to each repository.' \
|
||||||
|
config\:'Add, modify, remove, or print a value from a mrconfig file.' \
|
||||||
|
diff\:'Show a diff of uncommitted changes.' \
|
||||||
|
help\:'Display this help.' \
|
||||||
|
list\:'List the repositories that mr will act on.' \
|
||||||
|
log\:'Show the commit log.' \
|
||||||
|
ls\:'List the repositories that mr will act on.' \
|
||||||
|
offline\:'Advise mr that it is in offline mode.' \
|
||||||
|
online\:'Advise mr that it is in online mode again.' \
|
||||||
|
push\:'Push committed local changes to the remote repository.' \
|
||||||
|
record\:'Record changes to the local repository, but do not push them to the remote repository.' \
|
||||||
|
register\:'Register an existing repository in a mrconfig file.' \
|
||||||
|
remember\:'Remember a command, to be run later when mr re-enters online mode.' \
|
||||||
|
run\:'Run a specified command in each repository.' \
|
||||||
|
update\:'Update each repository from its configured remote repository.'))" \
|
||||||
|
'-d[Specify the topmost directory that mr should work in.]:directory:_dirs' \
|
||||||
|
'--directory[Specify the topmost directory that mr should work in.]:directory:_dirs' \
|
||||||
|
'-c[Use the specified mrconfig file.]:file:_files' \
|
||||||
|
'--config[Use the specified mrconfig file.]:file:_files' \
|
||||||
|
'-f[Force mr to act on repositories that would normally be skipped due to their configuration.]' \
|
||||||
|
'--force[Force mr to act on repositories that would normally be skipped due to their configuration.]' \
|
||||||
|
'-v[Be verbose.]' \
|
||||||
|
'--verbose[Be verbose.]' \
|
||||||
|
'-q[Be quiet (suppresses usual output)]' \
|
||||||
|
'--quiet[Be quiet (suppresses usual output)]' \
|
||||||
|
'-k[Accept untrusted SSL certificates when bootstrapping.]' \
|
||||||
|
'--insecure[Accept untrusted SSL certificates when bootstrapping.]' \
|
||||||
|
'-s[Expand the statistics line to include info about failed & skipped repositories.]' \
|
||||||
|
'--stats[Expand the statistics line to include info about failed & skipped repositories.]' \
|
||||||
|
'-i[Interactive mode.]' \
|
||||||
|
'--interactive[Interactive mode.]' \
|
||||||
|
'-n[Specify recursion depth (none if no number is specified)]::number:_guard "[0-9]#" "recursion depth (blank for no recursion)"' \
|
||||||
|
'--no-recurse[Specify recursion depth (none if no number is specified)]::number:_guard "[0-9]#" "recursion depth (blank for no recursion)"' \
|
||||||
|
'-j[Run the specified number of jobs in parallel (unlimited if no number is specified)]::number:_guard "[0-9]#" "number of parallel jobs (blank for unlimited)"' \
|
||||||
|
'--jobs[Run the specified number of jobs in parallel (unlimited if no number is specified)]::number:_guard "[0-9]#" "number of parallel jobs (blank for unlimited)"' \
|
||||||
|
'-t[Trust all mrconfig files (use with caution).]' \
|
||||||
|
'--trust-all[Trust all mrconfig files (use with caution).]'
|
||||||
|
|
||||||
|
# Local Variables:
|
||||||
|
# mode:shell-script
|
||||||
|
# End:
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
#compdef pccardctl lspcmcia
|
||||||
|
|
||||||
|
local cmds version verbosity socket
|
||||||
|
cmds="status\:'Display the current socket status flags.' config\:'Display the socket configuration.' ident\:'Display card identification information.' info\:'Like ident command, but output is formatted as series of Bourne-stype shell variable definitions.' ls\:'Display extended debugging information about the PCMCIA sockets and devices present in the system.' suspend\:'Shut down and then disable power for a socket.' resume\:'Restore power to a socket, and re-configure for use.' eject\:'Notify all client drivers that this card will be ejected, then cut power to the socket.' insert\:'Notify all client drivers that this card has just been inserted.'"
|
||||||
|
version='-V[Show version information and exit]'
|
||||||
|
verbosity='*-v[Increase the verbosity of the ls command.]'
|
||||||
|
socket="{_guard \"[0-9]#\" 'socket number'}"
|
||||||
|
|
||||||
|
case "$service" in
|
||||||
|
pccardctl)
|
||||||
|
_arguments : $version $verbosity "1:command:(($cmds))" "2:socket:$socket"
|
||||||
|
;;
|
||||||
|
lspcmcia)
|
||||||
|
_arguments : $version $verbosity "1:socket:$socket"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
# Local Variables:
|
||||||
|
# mode:shell-script
|
||||||
|
# End:
|
|
@ -0,0 +1,191 @@
|
||||||
|
#compdef pip
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Description
|
||||||
|
# -----------
|
||||||
|
#
|
||||||
|
# Completion script for pip (http://pypi.python.org/pypi/pip).
|
||||||
|
#
|
||||||
|
# Source: https://github.com/technolize/zsh-completion-funcs
|
||||||
|
#
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Authors
|
||||||
|
# -------
|
||||||
|
#
|
||||||
|
# * technolize (https://github.com/technolize)
|
||||||
|
#
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
local ret=1 state
|
||||||
|
|
||||||
|
local -a common_ops
|
||||||
|
common_ops=(
|
||||||
|
{-h,--help}"[show help]"
|
||||||
|
{-v,--verbose}"[give more output]"
|
||||||
|
{-V,--version}"[show version and exit]"
|
||||||
|
{-q,--quiet}"[give less output]"
|
||||||
|
"--log=[log file where a complete record will be kept]:file"
|
||||||
|
"--proxy=[specify a proxy in the form user:passwd@proxy.server:port]:proxy"
|
||||||
|
"--timeout=[set the socket timeout (default 15 seconds)]:second"
|
||||||
|
"--exists-action=[default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup]:action"
|
||||||
|
"--cert=[path to alternate CA bundle]:path"
|
||||||
|
)
|
||||||
|
|
||||||
|
_directories () {
|
||||||
|
_wanted directories expl directory _path_files -/ "$@" -
|
||||||
|
}
|
||||||
|
|
||||||
|
typeset -A opt_args
|
||||||
|
_arguments \
|
||||||
|
':subcommand:->subcommand' \
|
||||||
|
$common_ops \
|
||||||
|
'*::options:->options' && ret=0
|
||||||
|
|
||||||
|
case $state in
|
||||||
|
subcommand)
|
||||||
|
local -a subcommands
|
||||||
|
subcommands=(
|
||||||
|
"install:install packages"
|
||||||
|
"uninstall:uninstall packages"
|
||||||
|
"freeze:put all currently installed packages"
|
||||||
|
"list:list installed packages"
|
||||||
|
"show:show information about installed packages"
|
||||||
|
"search:search pypi"
|
||||||
|
"wheel:build wheels from your requirements"
|
||||||
|
"zip:zip dividual packages"
|
||||||
|
"unzip:unzip undividual packages"
|
||||||
|
"bundle:create pybundle"
|
||||||
|
"help:show available commands"
|
||||||
|
)
|
||||||
|
|
||||||
|
_describe -t subcommands 'pip subcommand' subcommands && ret=0
|
||||||
|
;;
|
||||||
|
|
||||||
|
options)
|
||||||
|
local -a args
|
||||||
|
args=(
|
||||||
|
$common_ops
|
||||||
|
)
|
||||||
|
|
||||||
|
local -a pi_ops
|
||||||
|
pi_ops=(
|
||||||
|
{-i,--index-url=}"[base URL of Python Package Index]:URL"
|
||||||
|
"--extra-index-url=[extra URLs of package indexes to use in addition to --index-url]:URL"
|
||||||
|
"--no-index[ignore package index (only looking at --find-links URLs instead)]"
|
||||||
|
{-f,--find-links=}"[URL to look for packages at]:URL"
|
||||||
|
{-M,--use-mirrors}"[use the PyPI mirrors as a fallback in case the main index is down]"
|
||||||
|
"--mirrors=[specific mirror URLs to query when --use-mirrors is used]:URL"
|
||||||
|
"--allow-external=[allow the installation of externally hosted files]:package"
|
||||||
|
"--allow-all-external[allow the installation of all externally hosted files]"
|
||||||
|
"--no-allow-external[disallow the installation of all externally hosted files]"
|
||||||
|
"--allow-insecure=[allow the installation of insecure and unverifiable files]:package"
|
||||||
|
"--no-allow-insecure[disallow the installation of insecure and unverifiable files]"
|
||||||
|
)
|
||||||
|
|
||||||
|
case $words[1] in
|
||||||
|
install | bundle)
|
||||||
|
args+=(
|
||||||
|
{-e,--editable=}"[install a package directly from a checkout]:VCS+REPOS_URL[@REV]#egg=PACKAGE"
|
||||||
|
{-r,--requirement=}"[install all the packages listed in the given requirements file]:filename:_files"
|
||||||
|
{-b,--build=}"[unpack packages into DIR]:directory:_directories"
|
||||||
|
{-t,--target=}"[install packages into DIR]:directory:_directories"
|
||||||
|
{-d,--download=}"[download packages into DIR instead of installing them]:directory:_directories"
|
||||||
|
"--download-cache=[cache downloaded packages in DIR]:directory:_directories"
|
||||||
|
"--src=[check out --editable packages into DIR]:directory:_directories"
|
||||||
|
{-U,--upgrade}"[upgrade all packages to the newest available version]"
|
||||||
|
"--force-reinstall[when upgrading, reinstall all packages even if they are already up-to-date]"
|
||||||
|
{-I,--ignore-installed}"[ignore the installed packages]"
|
||||||
|
"--no-deps[don't install package dependencies]"
|
||||||
|
"--no-install[download and unpack all packages, but don't actually install them]"
|
||||||
|
"--no-download[don't download any packages, just install the ones already downloaded]"
|
||||||
|
"--install-option=[extra arguments to be supplied to the setup.py install command]:options"
|
||||||
|
"--global-option=[Extra global options to be supplied to the setup.py call before the install command]:options"
|
||||||
|
"--user[install using the user scheme]"
|
||||||
|
"--egg[install as self contained egg file, like easy_install does]"
|
||||||
|
"--root=[Install everything relative to this alternate root directory]:directory:_directories"
|
||||||
|
"--use-wheel[find and prefer wheel archives when searching indexes and find-links locations]"
|
||||||
|
"--pre[include pre-release and development versions]"
|
||||||
|
"--no-clean[don't clean up build directories]"
|
||||||
|
$pi_ops
|
||||||
|
)
|
||||||
|
;;
|
||||||
|
|
||||||
|
uninstall)
|
||||||
|
args+=(
|
||||||
|
{-r,--requirement=}"[install all the packages listed in the given requirements file]:filename:_files"
|
||||||
|
{-y,--yes}"[don't ask for confirmation of uninstall deletions]"
|
||||||
|
)
|
||||||
|
;;
|
||||||
|
|
||||||
|
freeze)
|
||||||
|
args+=(
|
||||||
|
{-r,--requirement=}"[install all the packages listed in the given requirements file]:filename:_files"
|
||||||
|
{-f,--find-links=}"[URL to look for packages at]:URL"
|
||||||
|
{-l,--local}"[If in a virtualenv that has global access, do not list globally-installed packages]"
|
||||||
|
)
|
||||||
|
;;
|
||||||
|
|
||||||
|
list)
|
||||||
|
args+=(
|
||||||
|
{-o,--outdated}"[list outdated packages (excluding editables)]"
|
||||||
|
{-u,--uptodated}"[list uptodated packages (excluding editables)]"
|
||||||
|
{-e,--editable}"[list editable projects]"
|
||||||
|
{-l,--local}"[If in a virtualenv that has global access, do not list globally-installed packages]"
|
||||||
|
"--pre[include pre-release and development versions]"
|
||||||
|
$pi_ops
|
||||||
|
)
|
||||||
|
;;
|
||||||
|
|
||||||
|
show)
|
||||||
|
args+=(
|
||||||
|
{-f,--files}"[show the full list of installed files for each package]"
|
||||||
|
)
|
||||||
|
;;
|
||||||
|
|
||||||
|
search)
|
||||||
|
args+=(
|
||||||
|
"--index[base URL of Python Package Index]:URL"
|
||||||
|
)
|
||||||
|
;;
|
||||||
|
|
||||||
|
wheel)
|
||||||
|
args+=(
|
||||||
|
{-w,--wheel-dir=}"[build wheels into DIR, where the default is '<cwd>/wheelhouse']:directory:_directories"
|
||||||
|
"--use-wheel[find and prefer wheel archives when searching indexes and find-links locations]"
|
||||||
|
"--build-option=[extra arguments to be supplied to 'setup.py bdist_wheel']:options"
|
||||||
|
{-r,--requirement=}"[install all the packages listed in the given requirements file]:filename:_files"
|
||||||
|
"--download-cache=[cache downloaded packages in DIR]:directory:_directories"
|
||||||
|
"--no-deps[don't install package dependencies]"
|
||||||
|
{-b,--build=}"[directory to unpack packages into and build in]:directory:_directories"
|
||||||
|
"--global-option=[extra global options to be supplied to the setup.py call before the 'bdist_wheel' command]:options"
|
||||||
|
"--pre[include pre-release and development versions]"
|
||||||
|
"--no-clean[don't clean up build directories]"
|
||||||
|
$pi_ops
|
||||||
|
)
|
||||||
|
;;
|
||||||
|
|
||||||
|
unzip | zip)
|
||||||
|
args+=(
|
||||||
|
"--unzip[unzip a package]"
|
||||||
|
"--no-pyc[do not include .pyc files in zip files]"
|
||||||
|
{-l,--list}"[list the packages available, and their zip status]"
|
||||||
|
"--sort-files[with --list, sort packages according to how many files they contain]"
|
||||||
|
"--path=[restrict operation to the given paths]:paths"
|
||||||
|
{-n,--simulate}"[do not actually perform the zip/unzip operation]"
|
||||||
|
)
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
_arguments $args && ret=0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
return ret
|
||||||
|
|
||||||
|
# Local Variables:
|
||||||
|
# mode: Shell-Script
|
||||||
|
# sh-indentation: 2
|
||||||
|
# indent-tabs-mode: nil
|
||||||
|
# sh-basic-offset: 2
|
||||||
|
# End:
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
Loading…
Reference in New Issue