Added completion functions
This commit is contained in:
parent
0168d60338
commit
a150d1753e
|
@ -0,0 +1,125 @@
|
|||
#compdef glances
|
||||
# ------------------------------------------------------------------------------
|
||||
# Copyright (c) 2011 Github zsh-users - https://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 glances (https://nicolargo.github.io/glances/).
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
# Authors
|
||||
# -------
|
||||
#
|
||||
# * loranger (https://github.com/loranger)
|
||||
# * Shohei Yoshida (https://github.com/syohex)
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
_glances() {
|
||||
_arguments \
|
||||
'(- *)'{-h,--help}'[show this help message and exit]' \
|
||||
'(- *)'{-V,--version}"[show program's version number and exit]" \
|
||||
'(-C,--config)'{-C,--config}'[path to the configuration file]: :_files' \
|
||||
'(--modules-list --module-list)'{--modules-list,--module-list}'[display modules list and exit]' \
|
||||
'(--disable-plugin --disable-plugins)'{--disable-plugin,--disable-plugins}'[disable plugin(comma separated list or all)]:plugin' \
|
||||
'(--enable-plugin --enable-plugins)'{--enable-plugin,--enable-plugins}'[enable plugin(comma separated list)]:plugin' \
|
||||
'--disable-process[disable process module]' \
|
||||
'--disable-webui[disable the Web Interface]' \
|
||||
'(--light --enable-light)'{--light,--enable-light}'[light mode for Curses UI]' \
|
||||
'(-0 --disable-irix)'{-0,--disable-irix}"[task's cpu usage will be divided by the total number of CPUs]" \
|
||||
'(-1 --percpu)'{-1,--percpu}'[start Clances in per CPU mode]' \
|
||||
'(-2 --disable-left-sidebar)'{-2,--disable-left-sidebar}'[disable network, disk I/O, FS and sensors modules]' \
|
||||
'(-3 --disable-quicklook)'{-3,--disable-quicklook}'[disable quick look module]' \
|
||||
'(-4 --full-quicklook)'{-4,--full-quicklook}'[disable all but quick look and load]' \
|
||||
'(-5 --disable-top)'{-5,--disable-top}'[disable top menu(QL, CPU, MEM, SWAP and LOAD)]' \
|
||||
'(-6 --menugpu)'{-6,--menugpu}'[start Glances in mean GPU mode]' \
|
||||
'--disable-history[disable stats history]' \
|
||||
'--disable-bold[disable bold mode in the terminal]' \
|
||||
'--disable-bg[disable background colors in the terminal]' \
|
||||
'--enable-irq[enable IRQ mode]' \
|
||||
'--enable-process-extended[enable extended stats on top process]' \
|
||||
'(--separator --enable-separator)'{--separator,--enable-separator}'[enable separator in the UI]' \
|
||||
'--sort-process[sort processes]: :(cpu_percent memory_percent username cpu_times io_counters name)' \
|
||||
'(--programs --program)'{--programs,--program}'[Accumulate processes by program]' \
|
||||
'--export[enable export module]:module' \
|
||||
'--export-csv-file[file path for CSV exporter]: :_files' \
|
||||
'--export-csv-overwrite[overwrite existing CSV file]' \
|
||||
'--export-json-file[file path for JSON exporter]: :_files' \
|
||||
'--export-graph-path[Folder for Graph exporter]: :_files -/' \
|
||||
'(-c --client)'{-c,--client}'[connect to a Glances server]:host:_hosts' \
|
||||
'(-s --server)'{-s,--server}'[run Glances in server mode]' \
|
||||
'--browser[start the client browser]' \
|
||||
'--disable-autodiscover[disable autodiscover feature]' \
|
||||
'(-p --port)'{-p,--port}'[define the client/server TCP port]' \
|
||||
'(-B --bind)'{-B,--bind}'[bind server to the given IPv4/IPv6 address or hostname]:host:_hosts' \
|
||||
'--username[define a client/server username]' \
|
||||
'--password[define a client/server password]' \
|
||||
'-u[use the given client/server username]:user_name' \
|
||||
'--snmp-community[SNMP community]:community' \
|
||||
'--snmp-port[SNMP community]:port' \
|
||||
'--snmp-version[SNMP version]:version:(1 2c 3)' \
|
||||
'--snmp-user[SNMP user]:user' \
|
||||
'--snmp-auth[SNMP auth]:auth' \
|
||||
'--snmp-force[force SNMP mode]' \
|
||||
'(-t --time)'{-t,--time}'[set minimum refresh rate in seconds(default: 2 sec)]:seconds' \
|
||||
'(-w --webserver)'{-w,--webserver}'[run Glances in web server mode]' \
|
||||
'--cached-time[set the server cache time(default: 1 sec)]:seconds' \
|
||||
'--stop-after[stop Glances after n fresh]:' \
|
||||
'--open-web-browser[try to open the Web UI in the default browser]' \
|
||||
'(-q --quiet)'{-q,--quiet}'[do not display the curses interface]' \
|
||||
'(-f --process-filter)'{-f,--process-filter}'[set the process filter pattern]:regexp' \
|
||||
'--process-short-name[force short name for processes name]' \
|
||||
'--process-long-name[force long name for processes name]' \
|
||||
'--stdout[display stats to stdout one stat per line]:stats' \
|
||||
'--stdout-json[display stats to stdout, JSON format]:stats' \
|
||||
'--stdout-csv[display stats to CSV, JSON format]:stats' \
|
||||
'--issue[test all plugins and exit]' \
|
||||
'--trace-malloc[trace memory allocation and display it at the end of the process]' \
|
||||
'--memory-leak[test memory leak]' \
|
||||
'--api-doc[display fields descriptions]'\
|
||||
'--hide-kernel-threads[hide kernel threads in process list]' \
|
||||
'(-b --byte)'{-b,--byte}'[display network rate in byte per second]' \
|
||||
'--diskio-show-ramfs[show RAM Fs in the DiskIO plugin]' \
|
||||
'--diskio-iops[show IO per second in the DiskIO plugin]' \
|
||||
'--fahrenheit[display temperature in Fahrenheit]' \
|
||||
'--fs-free-space[display FS free space instead of used]' \
|
||||
'--sparkline[display sparklines instead of bar in the curses interface]' \
|
||||
'--disable-unicode[disable unicode characters in the curses interface]' \
|
||||
'--theme-white[optimize display colors for white background ]' \
|
||||
'--disable-check-update[disable online Glances version check]' \
|
||||
'--strftime[strftime format string for displaying current date in standalone mode]' \
|
||||
}
|
||||
|
||||
_glances "$@"
|
||||
|
||||
# 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
|
|
@ -0,0 +1,82 @@
|
|||
#compdef mc
|
||||
# ------------------------------------------------------------------------------
|
||||
# Copyright (c) 2019 Sebastian Gniazdowski
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||
# permit persons to whom the Software is furnished to do so, subject to
|
||||
# the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included
|
||||
# in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
# OTHER DEALINGS IN THE SOFTWARE.
|
||||
# ------------------------------------------------------------------------------
|
||||
# Description
|
||||
# -----------
|
||||
#
|
||||
# Completion script for Midnight Commander 4.8.28 (https://midnight-commander.org/)
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
# Authors
|
||||
# -------
|
||||
#
|
||||
# * Sebastian Gniazdowski (https://github.com/psprint)
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
setopt localoptions warncreateglobal typesetsilent
|
||||
|
||||
local -a opts
|
||||
opts=(
|
||||
{-h,--help}'[show help on options]'
|
||||
--help-all'[show help on all options]'
|
||||
--help-terminal'[terminal options help]'
|
||||
--help-color'[color options help]'
|
||||
{-a,--stickchars}'[use stickchars to draw]'
|
||||
'(-c --color -b --nocolor)'{-b,--nocolor}'[requests to run in black and white]'
|
||||
'(-b --nocolor -c --color)'{-c,--color}'[request to run in color mode]'
|
||||
{-C,--colors=}'[specifies a color configuration]:arg:'
|
||||
--configure-options'[print configure options]'
|
||||
{-d,--nomouse}'[disable mouse support in text version]'
|
||||
{-d,--debuglevel=}'[save the debug level for SMB VFS]:debug level:(0 1 2 3 4 5 6 7 8 9 10)'
|
||||
{-e,--edit=}'[edit files]:file:_files'
|
||||
{-f,--datadir}'[print data directory]'
|
||||
{-F,--datadir-info}'[print extended info about used data directories]'
|
||||
{-g,--oldmouse}'[tries to use an old highlight mouse tracking]'
|
||||
{-k,--resetsoft}'[resets soft keys on HP terminals]'
|
||||
{-K,--keymap=}'[load definitions of key bindings from specified file]:file:_files'
|
||||
{-l,--ftplog=}'[log ftp dialog to specified file]:file:_files'
|
||||
--nokeymap"[don't load key bindings from any file, use default hardcoded keys]"
|
||||
{-P,--printwd=}'[print last working directory to specified file]:file:_files'
|
||||
{-s,--slow}'[to run on slow terminals]'
|
||||
{-S,--skin=}'[show mc with specified skin]:skin:'
|
||||
{-t,--termcap}'[tries to use termcap instead of terminfo]'
|
||||
'(-U --subshell -u --nosubshell)'{-u,--nosubshell}'[disables subshell support]'
|
||||
'(-u --nosubshell -U --subshell)'{-U,--subshell}'[enables subshell support (default)]'
|
||||
{-v,--view=}'[launches the file viewer on a file]:file:_files'
|
||||
{-V,--version}'[displays the current version]'
|
||||
{-x,--xterm}'[forces xterm features]'
|
||||
{-X,--no-x11}'[disable X11 support]'
|
||||
'*:pane directory:_directories'
|
||||
)
|
||||
|
||||
_arguments -s $opts
|
||||
|
||||
# Return value passes through
|
||||
|
||||
# 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
|
|
@ -0,0 +1,58 @@
|
|||
#compdef mkcert
|
||||
# ------------------------------------------------------------------------------
|
||||
# Copyright (c) 2023 Github zsh-users - https://github.com/zsh-users
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||
# permit persons to whom the Software is furnished to do so, subject to
|
||||
# the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included
|
||||
# in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
# OTHER DEALINGS IN THE SOFTWARE.
|
||||
# ------------------------------------------------------------------------------
|
||||
# Description
|
||||
# -----------
|
||||
#
|
||||
# Completion script for mkcert v1.4.4 (https://github.com/FiloSottile/mkcert)
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
# Authors
|
||||
# -------
|
||||
#
|
||||
# * Shohei Yoshida (https://github.com/syohex) <syohex@gmail.com>
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
_arguments \
|
||||
'(- *)-help[Print help message]' \
|
||||
'(- *)-version[Print version information]' \
|
||||
'-install[Install the local CA in the system trust store]' \
|
||||
'-uninstall[Uninstall the local CA]' \
|
||||
'-cert-file[Specify cert file output path]:path:_files' \
|
||||
'-key-file[Specify key file output path]:path:_files' \
|
||||
'-p12-file[Specify p12 file output path]:path:_files' \
|
||||
'-client[Generate a certificate for client authentication]' \
|
||||
'-ecdsa[Generate a certificate with an ECDSA key]' \
|
||||
'-pkcs12[Generate a ".p12" PKCS #12 file]' \
|
||||
'-csr[Generate a certificate based on the supplied CSR]:csr' \
|
||||
'(- *)-CAROOT[Print the CA certificate and key storage location]' \
|
||||
&& return 0
|
||||
|
||||
# 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
|
|
@ -0,0 +1,74 @@
|
|||
#compdef nano
|
||||
|
||||
local curcontext="$curcontext" state line
|
||||
local -i ret=1
|
||||
|
||||
_arguments -s -S -C \
|
||||
'(-)'{-A,--smarthome}'[enable smart home key]' \
|
||||
'(-B --backup)'{-B,--backup}'[save backups of existing files]' \
|
||||
'(-C --backupdir)'{-C+,--backupdir=}'[specify directory for saving unique backup files]:directory:_directories' \
|
||||
'(-D --boldtext)'{-D,--boldtext}'[use bold instead of reverse video text]' \
|
||||
'(-E --tabstospaces)'{-E,--tabstospaces}'[convert typed tabs to spaces]' \
|
||||
'(-F --multibuffer)'{-F,--multibuffer}'[read a file into a new buffer by default]' \
|
||||
'(-G --locking)'{-G,--locking}'[use vim-style lock files]' \
|
||||
'(-H --historylog)'{-H,--historylog}'[log & read search replace string history]' \
|
||||
'(-I --ignorercfiles)'{-I,--ignorercfiles}"[don't look at nanorc files]" \
|
||||
'(-J --guidestripe)'{-J+,--guidestripe=}'[show a guide bar at specified column]:number' \
|
||||
'(-K --rawsequences)'{-K,--rawsequences}'[fix numeric keypad key confusion problem]' \
|
||||
'(-L --nonewlines)'{-L,--nonewlines}"[don't add an automatic newline]" \
|
||||
'(-M --trimblanks)'{-M,--trimblanks}'[trim trailing spaces when hard-wrapping]' \
|
||||
'(-N --noconvert -u --unix)'{-N,--noconvert}"[don't convert files from DOS/Mac format]" \
|
||||
'(-O --bookstyle)'{-O,--bookstyle}'[leading whitespace means new paragraph]' \
|
||||
'(-P --positionlog)'{-P,--positionlog}'[log & read location of cursor position]' \
|
||||
'(-Q --quotestr)'{-Q+,--quotestr=}'[specify regular expression to match quoted parts of lines]:regex [^([ \t]*([!#%\:;>|}]|//))+]' \
|
||||
'(-R --restricted)'{-R,--restricted}'[restricted mode]' \
|
||||
'(-S --softwrap)'{-S,--softwrap}'[display overly long lines on multiple rows]' \
|
||||
'(-T --tabsize)'{-T+,--tabsize=}'[set width of a tab]:columns [8]' \
|
||||
'(-U --quickblank -c --constantshow -_ --minibar)'{-U,--quickblank}'[do quick statusbar blanking]' \
|
||||
'(- *)'{-V,--version}'[print version information and exit]' \
|
||||
'(-W --wordbounds -X --wordchars)'{-W,--wordbounds}'[detect word boundaries more accurately]' \
|
||||
'(-X --wordchars -W --wordbounds)'{-X+,--wordchars=}'[specify which other characters are word parts]:string' \
|
||||
'(-Y --syntax=)'{-Y+,--syntax=}'[syntax definition to use for coloring]:value' \
|
||||
'(-Z --zap)'{-Z,--zap}'[let backspace and delete erase a marked region]' \
|
||||
'(-a --atblanks)'{-a,--atblanks}'[when soft-wrapping, do it at whitespace]' \
|
||||
'(-b --breaklonglines -w --nowrap)'{-b,--breaklonglines}'[automatically hard-wrap overlong lines]' \
|
||||
'(-c --constantshow -U --quickblank)'{-c,--constantshow}'[show cursor position constantly]' \
|
||||
'(-d --rebinddelete)'{-d,--rebinddelete}'[fix Backspace/Delete confusion problem]' \
|
||||
'(-e --emptyline)'{-e,--emptyline}'[keep the line below the title bar empty]' \
|
||||
'(-f --rcfile)'{-f,--rcfile=}'[Use only specified file for configuring nano]:file:_files' \
|
||||
'(-g --showcursor)'{-g,--showcursor}'[show cursor in file browser & help text]' \
|
||||
'(- *)'{-h,--help}'[show help text and exit]' \
|
||||
'(-i --autoindent)'{-i,--autoindent}'[automatically indent new lines]' \
|
||||
'(-j --jumpyscrolling)'{-j,--jumpyscrolling}'[scroll by half-screen, not by line]' \
|
||||
'(-k --cutfromcursor)'{-k,--cutfromcursor}'[cut from cursor to end of line]' \
|
||||
'(-l --linenumbers)'{-l,--linenumbers}'[show line numbers in front of the text]' \
|
||||
'(-m --mouse)'{-m,--mouse}'[enable the use of the mouse]' \
|
||||
'(-n --noread)'{-n,--noread}"[don't read the file (only write it)]" \
|
||||
'(-o --operatingdir)'{-o+,--operatingdir=}'[set operating directory]:directory:_directories' \
|
||||
'(-p --preserve)'{-p,--preserve}'[preserve XON (^Q) and XOFF (^S) keys]' \
|
||||
'(-q --indicator)'{-q,--indicator}'[show a position+portion indicator]' \
|
||||
'(-r --fill)'{-r+,--fill=}'[set width for hard-wrap and justification]:width [-8]' \
|
||||
'(-s --speller)'{-s+,--speller=}'[enable alternate speller]:program:_command_names -e' \
|
||||
'(-t --tempfile)'{-t,--tempfile}'[auto save on exit, do not prompt]' \
|
||||
'(-u --unix -N --noconvert)'{-u,--unix}'[save a file by default in Unix format]' \
|
||||
'(-v --view)'{-v,--view}'[view mode (read-only)]' \
|
||||
'(-w --nowrap -b --breaklonglines)'{-w,--nowrap}"[don't hard-wrap long lines default]" \
|
||||
'(-x --nohelp)'{-x,--nohelp}"[don't show the two help lines]" \
|
||||
'(-y --afterends)'{-y,--afterends}'[make Ctrl+Right stop at word ends]' \
|
||||
'(-z --suspend)'{-z,--suspend}'[enable suspension]' \
|
||||
'(-% --stateflags)'{-%,--stateflags}'[show some states in the title bar]' \
|
||||
'(-_ --minibar -U --quickblank)'{-_,--minibar}'[suppress the title bar and show information at the bottom of the screen]' \
|
||||
'(-! --magic)'{-\!,--magic}'[try libmagic to determine applicable syntax]' \
|
||||
'(-0 --zero)'{-0,--zero}'[Hide all bars, use whole terminal]' \
|
||||
'(-t -q)*: :->args' && ret=0
|
||||
|
||||
if [[ -n $state ]]; then
|
||||
case $PREFIX in
|
||||
+) _message -e lines "start at a given line" ;;
|
||||
+[crCR]#[/?]) _message -e 'search string' ;;
|
||||
+<->,) _message -e 'column number' ;;
|
||||
*) _files && ret=0 ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
return ret
|
|
@ -0,0 +1,146 @@
|
|||
#compdef neofetch
|
||||
# ------------------------------------------------------------------------------
|
||||
# Description
|
||||
# -----------
|
||||
#
|
||||
# Completion script for neofetch (https://github.com/dylanaraps/neofetch)
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
# Authors
|
||||
# -------
|
||||
#
|
||||
# * Wu Zhenyu <wuzhenyu@ustc.edu>
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
_neofetch_files_none() {
|
||||
_alternative 'none:none:((none\:"Launch the script without a config file"))' 'files:file:_files'
|
||||
}
|
||||
_neofetch_sources() {
|
||||
_alternative 'choices:choices:(auto ascii wallpaper "command output")' 'files: :_files'
|
||||
}
|
||||
local func_names=(
|
||||
title underline os distro model kernel uptime packages shell resolution de wm
|
||||
wm_theme icons term term_font cpu gpu memory gpu_driver cpu_usage disk battery
|
||||
font song local_ip public_ip users locale cols
|
||||
)
|
||||
local colors=(black blue cyan default gray green magenta orange red white)
|
||||
local distros=(
|
||||
AIX Alpine AlterLinux Anarchy Android Antergos antiX
|
||||
"AOSC OS" "AOSC OS/Retro" Apricity ArcoLinux ArchBox
|
||||
ARCHlabs ArchStrike XFerience ArchMerge Arch Artix Arya
|
||||
Bedrock Bitrig BlackArch BLAG BlankOn BlueLight bonsai BSD
|
||||
BunsenLabs Calculate Carbs CentOS Chakra ChaletOS Chapeau
|
||||
Chrom Cleanjaro ClearOS Clear_Linux Clover Condres
|
||||
Container_Linux CRUX Cucumber Debian Deepin DesaOS Devuan
|
||||
DracOS DarkOs DragonFly Drauger Elementary EndeavourOS Endless
|
||||
EuroLinux Exherbo Fedora Feren FreeBSD FreeMiNT Frugalware
|
||||
Funtoo GalliumOS Garuda Gentoo Pentoo gNewSense GNOME GNU
|
||||
GoboLinux Grombyang Guix Haiku Huayra Hyperbola janus Kali
|
||||
KaOS KDE_neon Kibojoe Kogaion Korora KSLinux Kubuntu LEDE
|
||||
LFS Linux_Lite LMDE Lubuntu Lunar macos Mageia MagpieOS
|
||||
Mandriva Manjaro Maui Mer Minix LinuxMint MX_Linux Namib
|
||||
Neptune NetBSD Netrunner Nitrux NixOS Nurunner NuTyX
|
||||
OBRevenge OpenBSD openEuler OpenIndiana openmamba OpenMandriva
|
||||
OpenStage OpenWrt osmc Oracle OS Elbrus PacBSD Parabola
|
||||
Pardus Parrot Parsix TrueOS PCLinuxOS Peppermint popos
|
||||
Porteus PostMarketOS Proxmox Puppy PureOS Qubes Radix
|
||||
Raspbian Reborn_OS Redstar Redcore Redhat Refracted_Devuan
|
||||
Regata Rosa sabotage Sabayon Sailfish SalentOS Scientific
|
||||
Septor SereneLinux SharkLinux Siduction Slackware SliTaz
|
||||
SmartOS Solus Source_Mage Sparky Star SteamOS SunOS
|
||||
openSUSE_Leap openSUSE_Tumbleweed openSUSE SwagArch Tails
|
||||
Trisquel Ubuntu-Budgie Ubuntu-GNOME Ubuntu-MATE Ubuntu-Studio
|
||||
Ubuntu Venom Void Obarun windows10 Windows7 Xubuntu Zorin IRIX
|
||||
)
|
||||
local options=(
|
||||
--disable"[Allows you to disable an info line from appearing in the output]:func_name:($func_names)"
|
||||
--title_fqdn"[Hide/Show Fully Qualified Domain Name in title]:on/off:(on off)"
|
||||
--package_managers"[Hide/Show Package Manager names]:on/off:(on tiny off)"
|
||||
--os_arch"[Hide/Show OS architecture]:on/off:(on off)"
|
||||
--speed_type"[Change the type of cpu speed to display]:type:(current min max bios scaling_current scaling_min scaling_max cpufreq)"
|
||||
--speed_shorthand"[Whether or not to show decimals in CPU speed]:on/off:(on off)"
|
||||
--cpu_brand"[Enable/Disable CPU brand in output]:on/off:(on off)"
|
||||
--cpu_cores"[Whether or not to display the number of CPU cores]:type:(logical physical off)"
|
||||
--cpu_speed"[Hide/Show cpu speed]:on/off:(on off)"
|
||||
--cpu_temp"[Hide/Show cpu temperature]:C/F/off:(C F off)"
|
||||
--distro_shorthand"[Shorten the output of distro]:on/off:(on tiny off)"
|
||||
--kernel_shorthand"[Shorten the output of kernel]:on/off:(on off)"
|
||||
--uptime_shorthand"[Shorten the output of uptime]:on/off:(on tiny off)"
|
||||
--refresh_rate"[Whether to display the refresh rate of each monitor]:on/off:(on off)"
|
||||
--gpu_brand"[Enable/Disable GPU brand in output]:on/off:(on off)"
|
||||
--gpu_type"[Which GPU to display]:type:(all dedicated integrated)"
|
||||
--de_version"[Show/Hide Desktop Environment version]:on/off:(on off)"
|
||||
--gtk_shorthand"[Shorten output of gtk theme/icons]:on/off:(on off)"
|
||||
--gtk2"[Enable/Disable gtk2 theme/font/icons output]:on/off:(on off)"
|
||||
--gtk3"[Enable/Disable gtk3 theme/font/icons output]:on/off:(on off)"
|
||||
--shell_path"[Enable/Disable showing $SHELL path]:on/off:(on off)"
|
||||
--shell_version"[Enable/Disable showing $SHELL version]:on/off:(on off)"
|
||||
--disk_show"[Which disks to display]:value:('/' '/dev/sdXX' '/path/to/mount point')"
|
||||
--disk_subtitle"[What information to append to the Disk subtitle]:type:(name mount dir none)"
|
||||
--disk_percent"[Hide/Show disk percent]:on/off:(on off)"
|
||||
--ip_host"[URL to query for public IP]:url:_urls"
|
||||
--ip_timeout"[Public IP timeout (in seconds)]:int"
|
||||
--song_format"[Print the song data in a specific format]:format:(%artist% %album% %title%)"
|
||||
--song_shorthand"[Print the Artist/Album/Title on separate lines]:on/off:(on off)"
|
||||
--memory_percent"[Display memory percentage]:on/off:(on off)"
|
||||
--memory_unit"[Memory output unit]:kib/mib/gib:(kib mib gib)"
|
||||
--music_player"[Manually specify a player to use]:player-name"
|
||||
--colors"[Changes the text colors]:title color:($colors):@ color:($colors):underline color:($colors):subtitle color:($colors):colon color:($colors):info color:($colors)"
|
||||
--underline"[Enable/Disable the underline]:on/off:(on off)"
|
||||
--underline_char"[Character to use when underlining title]:char"
|
||||
--bold"[Enable/Disable bold text]:on/off:(on off)"
|
||||
--separator"[Changes the default ':' separator to the specified string]:string"
|
||||
--color_blocks"[Enable/Disable the color blocks]:on/off:(on off)"
|
||||
--col_offset"[Left-padding of color blocks]:auto/num"
|
||||
--block_width"[Width of color blocks in spaces]:num"
|
||||
--block_height"[Height of color blocks in lines]:num"
|
||||
--block_range"[Range of colors to print as blocks]:num::num"
|
||||
--bar_char"[Characters to use when drawing bars]:elapsed char::total char"
|
||||
--bar_border"[Whether or not to surround the bar with '\\[\\]']:on/off:(on off)"
|
||||
--bar_length"[Length in spaces to make the bars]:num"
|
||||
--bar_colors"[Colors to make the bar in elapsed, total]:num::num"
|
||||
--cpu_display"[Bar mode]:mode:(bar infobar barinfo off)"
|
||||
--memory_display"[Bar mode]:mode:(bar infobar barinfo off)"
|
||||
--battery_display"[Bar mode]:mode:(bar infobar barinfo off)"
|
||||
--disk_display"[Bar mode]:mode:(bar infobar barinfo off)"
|
||||
--backend"[Which image backend to use]:backend:(ascii caca chafa jp2a iterm2 off sixel tycat w3m kitty)"
|
||||
--source"[Which image or ascii file to use]:source:_neofetch_sources"
|
||||
--ascii"[Shortcut to use 'ascii' backend]:source:_neofetch_sources"
|
||||
--caca"[Shortcut to use 'caca' backend]:source:_neofetch_sources"
|
||||
--chafa"[Shortcut to use 'chafa' backend]:source:_neofetch_sources"
|
||||
--iterm2"[Shortcut to use 'iterm2' backend]:source:_neofetch_sources"
|
||||
--jp2a"[Shortcut to use 'jp2a' backend]:source:_neofetch_sources"
|
||||
--kitty"[Shortcut to use 'kitty' backend]:source:_neofetch_sources"
|
||||
--pot"[Shortcut to use 'pot' backend]:source:_neofetch_sources"
|
||||
--pixterm"[Shortcut to use 'pixterm' backend]:source:_neofetch_sources"
|
||||
--sixel"[Shortcut to use 'sixel' backend]:source:_neofetch_sources"
|
||||
--termpix"[Shortcut to use 'termpix' backend]:source:_neofetch_sources"
|
||||
--tycat"[Shortcut to use 'tycat' backend]:source:_neofetch_sources"
|
||||
--w3m"[Shortcut to use 'w3m' backend]:source:_neofetch_sources"
|
||||
--off"[Shortcut to use off backend (Disable ascii art)]"
|
||||
--ascii_colors"[Colors to print the ascii art]:title color:($colors):@ color:($colors):underline color:($colors):subtitle color:($colors):colon color:($colors):info color:($colors)"
|
||||
--ascii_distro"[Which Distro's ascii art to print]:distro:($distros)"
|
||||
--ascii_bold"[Whether or not to bold the ascii logo]:on/off:(on off)"
|
||||
{-L,--logo}"[Hide the info text and only show the ascii logo]"
|
||||
--loop"[Redraw the image constantly until Ctrl+C is used]"
|
||||
--size"[How to size the image]:00px or 00%:(auto none)"
|
||||
--crop_mode"[Which crop mode to use]:mode:(normal fit fill)"
|
||||
--crop_offset"[Change the crop offset for normal mode]:value:(northwest north northeast west center east southwest south southeast)"
|
||||
--xoffset"[How close the image will be to the left edge of the]:px"
|
||||
--yoffset"[How close the image will be to the top edge of the]:px"
|
||||
--bg_color"[Background color to display behind transparent image]:color:($colors)"
|
||||
--gap"[Gap between image and text]:num"
|
||||
--clean"[Delete cached files and thumbnails]"
|
||||
--config"[Specify a path to a custom config file]:files or none:_neofetch_files_none"
|
||||
--no_config"[Don't create the user config file]"
|
||||
'(- : *)'--print_config"[Print the default config file to stdout]"
|
||||
--stdout"[Turn off all colors and disables any ASCII/image backend]"
|
||||
'(- : *)'--help"[Print this text and exit]"
|
||||
'(- : *)'--version"[Show neofetch version]"
|
||||
-v"[Display error messages]"
|
||||
-vv"[Display a verbose log for error reporting]"
|
||||
'(- : *)'--gen-man"[Generate a manpage for Neofetch in your PWD]"
|
||||
)
|
||||
|
||||
_arguments $options "*::func_name:($func_names)"
|
|
@ -0,0 +1,500 @@
|
|||
#compdef nft
|
||||
# ------------------------------------------------------------------------------
|
||||
# Description
|
||||
# -----------
|
||||
#
|
||||
# Completion script for nft 0.9.0 (https://www.netfilter.org/projects/nftables/index.html).
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
# Authors
|
||||
# -------
|
||||
#
|
||||
# * Markus Richter ( https://github.com/mqus , <mqus@disroot.org>)
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
_nft(){
|
||||
local -a rules states prev args families options descriptors
|
||||
local state="start" line nextstate cmd_obj cmd_subcmd cmd_fam cmd_tab cmd_chain #curcontext="$curcontext"
|
||||
|
||||
options=(
|
||||
'(-)'{-h,--help}'[show help]' \
|
||||
'(-)'{-v,--version}'[print version information]' \
|
||||
"(-i --interactive)"{-i,--interactive}'[read input from interactive CLI]: :->end' \
|
||||
"(-f --file)"{-f,--file}'[read input from <filename>]:nftables rule file:_files' \
|
||||
'(-c --check -n --numeric -N)'{-c,--check}"[check command's validity without actually applying the changes]" \
|
||||
'(-j --json)'{-j,--json}'[format output in json]' \
|
||||
'(-c --check -N)*'{-n,--numeric}'[can be specified up to 3 times, Shows 1:network addresses(default behaviour), 2:internet services (port numbers) and 3:protocols, user IDs, and group IDs numerically]' \
|
||||
'(-s --stateless)'{-s,--stateless}'[omit stateful information of ruleset]' \
|
||||
'(-N -n --numeric -c --check)'-N'[translate IP addresses to names]' \
|
||||
'(-a --handle)'{-a,--handle}'[output rule handle]' \
|
||||
'(-e --echo)'{-e,--echo}'[echo what has been added, inserted or replaced]' \
|
||||
{-I,--includepath}'[add specified directory to the paths searched for include files]:include directory [/usr/share]:include directory:_directories'
|
||||
)
|
||||
|
||||
# start a state machine. The state is modified by _arguments if the
|
||||
# current argument (descriptors) cannot be completed. Each state has to define is successive state and the
|
||||
# 'descriptors' for _arguments, which essentially tells _arguments how to complete
|
||||
local _i=0
|
||||
while true;do
|
||||
(( _i+=1 ))
|
||||
#Guard for endless loops
|
||||
[[ $_i -gt 100 ]] && return 1
|
||||
|
||||
descriptors=()
|
||||
nextstate="end"
|
||||
case $state in
|
||||
(start)
|
||||
##if line is empty (at the start) or ends with semicolon, autocomplete subcommands,
|
||||
# else if we are after a space,complete a semicolon (end the current nft command) and start anew
|
||||
if [[ $line[1] = "" || $line[1] =~ ';$' ]] ; then
|
||||
descriptors=( ":: :_nft_subcommands" )
|
||||
nextstate="category"
|
||||
else
|
||||
if [[ $words =~ ' $' ]]; then
|
||||
descriptors=(':: :(\;)')
|
||||
else
|
||||
descriptors=(':argument: ')
|
||||
fi
|
||||
nextstate="start"
|
||||
fi
|
||||
;;
|
||||
(category)
|
||||
case $line[1] in
|
||||
(add | list | flush | delete | create | rename | insert | replace | reset)
|
||||
descriptors=( ":: :_nft_${line[1]}" )
|
||||
nextstate=$line[1]
|
||||
;;
|
||||
(monitor)
|
||||
descriptors=( ":: : _nft_mon_filter" )
|
||||
nextstate="mon1"
|
||||
;;
|
||||
(export)
|
||||
descriptors=( ":: :(ruleset)" ":: :_nft_out_format" )
|
||||
nextstate="preend"
|
||||
;;
|
||||
(describe)
|
||||
descriptors=( ":expression: ")
|
||||
nextstate="start" #x restart
|
||||
;;
|
||||
(*)
|
||||
return 1;
|
||||
;;
|
||||
esac
|
||||
|
||||
#descriptors=( "(ruleset)" )
|
||||
#nextstate="end"
|
||||
;;
|
||||
(mon1)
|
||||
case $line[1] in
|
||||
(new | destroy)
|
||||
# descriptors=( ":: :_nft_mon_keywords" ":: :_nft_out_format")
|
||||
descriptors=( ":: : _nft_mon_keywords")
|
||||
nextstate="mon1"
|
||||
;;
|
||||
(tables | chains | sets | rules | elements | ruleset)
|
||||
descriptors=( ":: : _nft_out_format")
|
||||
nextstate="preend"
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
#all completions for create and insert match with the completions of add
|
||||
(create | insert)
|
||||
state="add"
|
||||
;|
|
||||
#all completions for reset and flush match with the completions of list
|
||||
(reset | flush)
|
||||
state="list"
|
||||
;|
|
||||
#(add(^table)/create(^table)/delete/flush(^ruleset)/insert/list(^ruleset)/rename/replace)[family]table
|
||||
(reset | delete | insert | rename | replace | add | create | flush | list)
|
||||
if [[ $state = "add" && $line[1] = "table" ]]; then
|
||||
descriptors=( ":: :_nft_families" ":table name:")
|
||||
nextstate="start" #x restart
|
||||
elif [[ $state = "list" && ( $line[1] = "ruleset" || $line[1] = "tables" ) ]]; then
|
||||
descriptors=( ":: :_nft_families")
|
||||
nextstate="start" #x restart
|
||||
elif [[ $state = "delete" && $line[1] = "table" ]]; then
|
||||
descriptors=(": : _nft_table all-handle")
|
||||
nextstate="tcomplete-delete-table"
|
||||
else
|
||||
cmd_obj=$line[1]
|
||||
cmd_subcmd=$state
|
||||
descriptors=(": : _nft_table all")
|
||||
nextstate="tcomplete"
|
||||
fi
|
||||
;;
|
||||
(tcomplete-delete-table)
|
||||
# if only a family was completed, complete the table name.
|
||||
case $line[1] in
|
||||
(arp | bridge | inet | ip | ip6 | netdev)
|
||||
descriptors=(": : _nft_table ${line[1]}-handle")
|
||||
cmd_fam=$line[1]
|
||||
;;
|
||||
# if 'handle' was completed, complete the handle number.
|
||||
(handle)
|
||||
descriptors=(": : _nft_table_handle_all " )
|
||||
;;
|
||||
# else, complete nothing and go to the next state. default family is 'ip'
|
||||
(*)
|
||||
descriptors=()
|
||||
cmd_fam="ip"
|
||||
;;
|
||||
esac
|
||||
nextstate="delete-table"
|
||||
;;
|
||||
(tcomplete)
|
||||
# if only a family was completed, complete the table name.
|
||||
case $line[1] in
|
||||
(arp | bridge | inet | ip | ip6 | netdev)
|
||||
descriptors=(": : _nft_table ${line[1]}")
|
||||
cmd_fam=$line[1]
|
||||
;;
|
||||
# else, complete nothing and go to the next state. default family is 'ip'
|
||||
(*)
|
||||
descriptors=()
|
||||
cmd_fam="ip"
|
||||
;;
|
||||
esac
|
||||
nextstate="$cmd_subcmd-$cmd_obj"
|
||||
;;
|
||||
(list-table)
|
||||
descriptors=(":: :(\;)")
|
||||
nextstate="start"
|
||||
;;
|
||||
(delete-table)
|
||||
#if family AND handle were input, complete handle number for given family.
|
||||
if [[ $line[1] == "handle" ]]; then
|
||||
descriptors=(":table handle: _nft_table_handle $cmd_fam" )
|
||||
else
|
||||
descriptors=()
|
||||
fi
|
||||
nextstate="start"
|
||||
;;
|
||||
(delete-chain | delete-set | delete-quota | delete-counter | delete-ct\\ helper)
|
||||
cmd_tab=$line[1]
|
||||
descriptors=(": : _nft_object $cmd_fam $cmd_tab $cmd_obj true")
|
||||
nextstate="delete-obj-handle"
|
||||
;;
|
||||
(delete-obj-handle)
|
||||
if [[ $line[1] == "handle" ]]; then
|
||||
descriptors=(": : _nft_object_handle $cmd_fam $cmd_tab $cmd_obj")
|
||||
else
|
||||
descriptors=(": :(\;)")
|
||||
fi
|
||||
nextstate="start"
|
||||
;;
|
||||
(add-chain)
|
||||
descriptors=(":chain name:")
|
||||
nextstate="start"
|
||||
;;
|
||||
(rename-chain)
|
||||
cmd_tab=$line[1]
|
||||
descriptors=(": : _nft_object $cmd_fam $cmd_tab chain false")
|
||||
nextstate="add-chain"
|
||||
;;
|
||||
(replace-rule | delete-rule)
|
||||
cmd_tab=$line[1]
|
||||
descriptors=(": : _nft_object $cmd_fam $cmd_tab chain false")
|
||||
nextstate="repdel-rule"
|
||||
;;
|
||||
(repdel-rule)
|
||||
cmd_chain=$line[1]
|
||||
descriptors=(": :(handle)" ": : _nft_rule_handle $cmd_fam $cmd_tab ${line[1]}")
|
||||
if [[ $cmd_subcmd = "replace" ]];then
|
||||
nextstate="rule-stmt"
|
||||
else
|
||||
nextstate="start"
|
||||
fi
|
||||
;;
|
||||
(add-rule)
|
||||
cmd_tab=$line[1]
|
||||
descriptors=(": : _nft_object $cmd_fam $cmd_tab chain false")
|
||||
nextstate="add-rule-2"
|
||||
;;
|
||||
(add-rule-2)
|
||||
cmd_chain=$line[1]
|
||||
descriptors=(": :(handle index position)")
|
||||
nextstate="add-rule-3"
|
||||
;;
|
||||
(add-rule-3)
|
||||
case $line[1] in
|
||||
(index | position)
|
||||
descriptors=(":${line[1]}:")
|
||||
;;
|
||||
(handle)
|
||||
descriptors=(": : _nft_rule_handle $cmd_fam $cmd_tab $cmd_chain")
|
||||
;;
|
||||
(*)
|
||||
descriptors=()
|
||||
;;
|
||||
esac
|
||||
nextstate="rule-stmt"
|
||||
;;
|
||||
(rule-stmt)
|
||||
#TODO
|
||||
# _nft_rule $cmd_fam $cmd_tab $cmd_chain\
|
||||
# && return 0;
|
||||
descriptors=":expression: "
|
||||
nextstate="start"
|
||||
;;
|
||||
(list-set | list-map | delete-map | list-chain | list-flowtable | delete-flowtable | list-ct\\ helper | list-counter | list-quota | list-meter)
|
||||
cmd_tab=$line[1]
|
||||
descriptors=(": : _nft_object $cmd_fam $cmd_tab $cmd_obj false")
|
||||
nextstate="start"
|
||||
;;
|
||||
#TODO:
|
||||
#(add-element | delete-element)
|
||||
#(add-set | add-map)
|
||||
#(add-flowtable)
|
||||
#("add-ct\ helper")
|
||||
#(add-counter)
|
||||
#(add-quota)
|
||||
|
||||
(*)
|
||||
return 1;
|
||||
;;
|
||||
esac
|
||||
_arguments -C -s \
|
||||
"${options[@]}" \
|
||||
"${descriptors[@]}" \
|
||||
"*:: :->$nextstate" \
|
||||
&& return 0;
|
||||
|
||||
done
|
||||
} # end _nft
|
||||
|
||||
_nft_subcommands(){
|
||||
local commands=(
|
||||
'add:add a table, chain, rule, set, map, or object'
|
||||
'list:list a ruleset, table, chain, set, map, or object'
|
||||
'flush:flush (delete everything from) a ruleset, table, chain, set, or map'
|
||||
'export:print the ruleset in a machine readable format (json or xml)'
|
||||
'delete:delete a table, chain, rule, set, element, map, or object'
|
||||
'create:similar to add but returns an error for existing chain'
|
||||
'rename:rename the specified chain'
|
||||
'insert:similar to the add command, but the rule is prepended to the beginning of the chain or before the rule at the given position'
|
||||
'replace:similar to the add command, but replaces the specified rule'
|
||||
'reset:list-and-reset stateful object'
|
||||
'monitor:listen to Netlink events'
|
||||
'describe:show information about the type of an expression and its data type'
|
||||
)
|
||||
_describe -t commands 'nft subcommand' commands "$@"
|
||||
}
|
||||
_nft_mon_filter(){
|
||||
local monitor_filters=(
|
||||
'new:show only events of created objects'
|
||||
'destroy:show only events of deleted objects'
|
||||
)
|
||||
_describe -t monitor_filters 'nft monitor' monitor_filters -J monitor_filters "$@"
|
||||
_nft_mon_keywords
|
||||
}
|
||||
|
||||
_nft_mon_keywords(){
|
||||
local monitor_keywords=(
|
||||
'tables:show table events'
|
||||
'chains:show chain events'
|
||||
'sets:show set events'
|
||||
'rules:show rule events'
|
||||
'elements:show only events of element objects'
|
||||
'ruleset:show ruleset events, such as table, chain, rule, set, counters and quotas'
|
||||
)
|
||||
_describe -t monitor_keywords 'nft monitor' monitor_keywords -J monitor_keywords "$@"
|
||||
_nft_out_format
|
||||
}
|
||||
|
||||
_nft_out_format(){
|
||||
local monitor_format=(
|
||||
'json:format output to JSON'
|
||||
'xml:format output to XML'
|
||||
)
|
||||
_describe -t monitor_format "output format" monitor_format -J monitor_format "$@"
|
||||
}
|
||||
|
||||
_nft_add(){
|
||||
local commands=(
|
||||
'table:add a new table'
|
||||
'flowtable:add a new flowtable'
|
||||
'chain:add a chain to a table'
|
||||
'rule:add a rule to an existing chain'
|
||||
'set:add a set to a table'
|
||||
'map:add a map to a table'
|
||||
'element:add one or multiple element(s) to a set or map'
|
||||
'ct\ helper:add a ct helper to a table'
|
||||
'counter:add a named counter to a table'
|
||||
'quota:add a named quota helper to a table'
|
||||
)
|
||||
_describe -t commands 'nft add' commands "$@"
|
||||
}
|
||||
|
||||
_nft_create(){
|
||||
local commands=(
|
||||
"table:add a table, but return an error if it already exists"
|
||||
"chain:add a chain to a table, but return an error if it already exists"
|
||||
"flowtable:add a flowtable, but return an error if it already exists"
|
||||
)
|
||||
_describe -t commands 'nft create' commands "$@"
|
||||
}
|
||||
|
||||
_nft_delete(){
|
||||
local commands=(
|
||||
"table:delete the specified table"
|
||||
"chain:delete the specified chain, chain must be empty and mustn't be used as jump target"
|
||||
"rule:delete the specified rule, rule must be referable to by a handle"
|
||||
"set:delete the specified set"
|
||||
"map:delete the specified map"
|
||||
"element:delete element(s) from the specified set/map"
|
||||
"flowtable:delete the specified flowtable"
|
||||
"ct\ helper:delete the specified ct helper"
|
||||
"counter:delete the specified counter"
|
||||
"quota:delete the specified quota"
|
||||
)
|
||||
_describe -t commands 'nft delete' commands "$@"
|
||||
}
|
||||
|
||||
_nft_flush(){
|
||||
local commands=(
|
||||
"ruleset:clear the whole ruleset, including removing all tables and containing objects"
|
||||
"table:flush all chains and rules of the specified table"
|
||||
"chain:flush all rules of the specified chain"
|
||||
"set:remove all elements from the specified set"
|
||||
"map:remove all elements from the specified map"
|
||||
)
|
||||
_describe -t commands 'nft flush' commands "$@"
|
||||
}
|
||||
|
||||
_nft_insert(){
|
||||
local commands=(
|
||||
"rule:prepend a rule to the beginning of the chain or before the rule with the given handle"
|
||||
)
|
||||
_describe -t commands 'nft insert' commands "$@"
|
||||
}
|
||||
|
||||
_nft_list(){
|
||||
local commands=(
|
||||
"ruleset:print the ruleset in human-readable format"
|
||||
"tables:list all tables (undocumented)"
|
||||
"table:list all chains and rules of the specified table"
|
||||
"chain:list all rules of the specified chain"
|
||||
"set:display the elements in the specified set"
|
||||
"map:display the elements in the specified map"
|
||||
"flowtable:list all flowtables"
|
||||
"ct\ helper:display stateful information the ct helper holds"
|
||||
"counter:display stateful information the counter holds"
|
||||
"quota:display stateful information the quota holds"
|
||||
)
|
||||
_describe -t commands 'nft list' commands "$@"
|
||||
}
|
||||
|
||||
_nft_rename(){
|
||||
local commands=(
|
||||
"chain:replace a chain"
|
||||
)
|
||||
_describe -t commands 'nft rename' commands "$@"
|
||||
}
|
||||
|
||||
_nft_replace(){
|
||||
local commands=(
|
||||
"rule:replace a rule"
|
||||
)
|
||||
_describe -t commands 'nft replace' commands "$@"
|
||||
}
|
||||
|
||||
_nft_reset(){
|
||||
local commands=(
|
||||
'ct\ helper:reset and list a ct helper to a table'
|
||||
'counter:reset and list a counter from a table'
|
||||
'quota:reset and list a quota object a table'
|
||||
)
|
||||
_describe -t commands 'nft reset' commands "$@"
|
||||
}
|
||||
_nft_families(){
|
||||
local families=(
|
||||
"ip:IPv4 address family"
|
||||
"ip6:IPv6 address family"
|
||||
"inet:internet (IPv4+IPv6) address family"
|
||||
"arp:ARP address family, handling IPv4 ARP packets"
|
||||
"bridge:Bridge address family, handling packets which traverse a bridge device"
|
||||
"netdev:Netdev address family, handling packets from ingress"
|
||||
)
|
||||
_describe -t families 'nft families' families "$@"
|
||||
}
|
||||
|
||||
_nft_table(){
|
||||
# complete the names of tables and the families of existing tables
|
||||
#$1 can be: all all-handle <family> <family>-handle
|
||||
local tables=()
|
||||
if [[ "$1" =~ "^all" ]]; then
|
||||
local families=( ${(f)"$(_call_program -p tables nft list tables 2>/dev/null \
|
||||
| cut -d\ -f2 )"} )
|
||||
# ip is the default family, search also for table names there
|
||||
1="${1/all/ip}"
|
||||
_describe -t families "family" families -J "family"
|
||||
fi
|
||||
if [[ "$1" =~ "-handle$" ]]; then
|
||||
tables=("handle:address the table by handle")
|
||||
#remove -handle from $1 to be able to complete table names
|
||||
1="${1/-handle/}"
|
||||
_describe -t tables "table" tables -V "handle"
|
||||
fi
|
||||
case $1 in
|
||||
(arp | bridge | inet | ip | ip6 | netdev)
|
||||
tables=( ${(f)"$(_call_program -p tables nft -a list ruleset 2>/dev/null \
|
||||
| grep '^table '"$1" | sed 's/table // ;s/{ # handle // ;s/\(\S*\) \(\S*\) \(\S*\)/\2:type \1, handle \3/' )"} )
|
||||
_describe -t tables "table" tables -V "table-name"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
_nft_table_handle(){
|
||||
# complete the handles of tables with the specified family (with the table name in the description)
|
||||
#$1:protocol family
|
||||
local tables=( ${(f)"$(_call_program -p tables nft -a list ruleset 2>/dev/null \
|
||||
| grep '^table '"$1" | sed 's/table // ;s/{ # handle // ;s/\(\S*\) \(\S*\) \(\S*\)/\3:\2(type \1)/' )"} )
|
||||
echo $1 > /tmp/znfttab
|
||||
_describe -t tables "table handle" tables
|
||||
}
|
||||
|
||||
_nft_table_handle_all(){
|
||||
# complete the handles of tables of all families (with the table name in the description)
|
||||
local tables=( ${(f)"$(_call_program -p tables nft -a list ruleset 2>/dev/null \
|
||||
| grep '^table' | sed 's/table // ;s/{ # handle // ;s/\(\S*\) \(\S*\) \(\S*\)/\3:\2(type \1)/' )"} )
|
||||
_describe -t tables "table handle" tables
|
||||
}
|
||||
|
||||
_nft_object(){
|
||||
# complete the names of objects contained directly in a table (with the handle number in the description)
|
||||
#$1:protocol family
|
||||
#$2:table
|
||||
#$3:object type (chain/set/map/flowtable/ct helper/counter/quota/meter)
|
||||
#$4:include 'handle'?
|
||||
local objects=( ${(f)"$(_call_program -p objects nft -a list table $1 $2 2>/dev/null\
|
||||
| grep ""\\s\*$3"" | sed 's/\s*'"$3"' // ;s/ { # \(.*\)/:(\1)/' )"} )
|
||||
if $4 ;then
|
||||
objects+=( "handle:address $3 by handle")
|
||||
fi
|
||||
_describe -t objects "$3" objects
|
||||
}
|
||||
|
||||
_nft_object_handle(){
|
||||
# complete handles of objects contained directly in a table (with the name in the description)
|
||||
#$1:protocol family
|
||||
#$2:table
|
||||
#$3:object type (chain/set/ct helper/counter/quota)
|
||||
local handles=( ${(f)"$(_call_program -p handles nft -a list table $1 $2 2>/dev/null\
|
||||
| grep ""\\s\*$3"" | sed 's/\s*'"$3"' // ;s/ { # handle// ;s/\(\S*\) \(\S*\)/\2:\1/' )"} )
|
||||
_describe -t handles "$3-handle" handles
|
||||
}
|
||||
|
||||
_nft_rule_handle(){
|
||||
# complete the handles of rules (and put the rule into the description)
|
||||
#$1:protocol family
|
||||
#$2:table
|
||||
#$3:chain name
|
||||
local rules=( ${(f)"$(_call_program -p nft-rule-handle nft -a list chain $1 $2 $3 2>/dev/null \
|
||||
|grep -v '^\s*\(table\|chain\|type\|\}\)'|sed 's/^\s*\(.*\) # handle \(\S*\)$/\2:\1/' )"} )
|
||||
# don't sort those entries alphabetically, so they get shown in the order they are executed in nftables
|
||||
_describe -t rules "rule" rules -V "rules"
|
||||
}
|
||||
|
||||
#currently, only the `nft` command is covered by this script.
|
||||
_nft "$@"
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,246 @@
|
|||
#compdef openvpn3
|
||||
# ------------------------------------------------------------------------------
|
||||
# Copyright (c) 2011 Github zsh-users - https://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 openvpn 3 (https://github.com/openvpn/openvpn3) (https://openvpn.net/openvpn-client-for-linux/).
|
||||
# version: 13_beta-1 (Jul 1 2021)
|
||||
# openvpn 3/Linux git:makepkg:2031975261858750 (openvpn3)
|
||||
# openvpn core 3.git:HEAD:ce0c9963 linux x86_64 64-bit
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
# Author
|
||||
# -------
|
||||
#
|
||||
# * undg (https://github.com/undg)
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
local sessions_configs_names=$(openvpn3 sessions-list | grep 'Config name:' | awk '{print $3}' | xargs)
|
||||
local sessions_paths=$(openvpn3 sessions-list | grep 'Path:' | awk '{print $2}' | xargs)
|
||||
local sessions_interfaces=$(openvpn3 sessions-list | grep 'Device:' | awk '{print $4}' | xargs)
|
||||
local sessions_users=$(openvpn3 sessions-list | grep 'Owner:' | awk '{print $2}' | xargs)
|
||||
local sessions_names=$(openvpn3 sessions-list | grep 'Session name:' | awk '{print $2}' | xargs)
|
||||
local configs_names=$(openvpn3 configs-list | awk 'count&&!--count; /\/net\/openvpn\//{count=2}' | awk '{print $1}' | xargs)
|
||||
local configs_paths=$(openvpn3 configs-list | grep '/net/openvpn/v3/configuration/' | xargs)
|
||||
|
||||
_openvpn3_config-acl(){
|
||||
_arguments \
|
||||
{-s,--show}"[Show the current access control lists]" \
|
||||
{-o,--path}"[OBJ-PATH Path to the configuration in the configuration manager]: :($configs_paths)" \
|
||||
{-h,--help}"[This help screen]" \
|
||||
{-c,--config}"[CONFIG-NAME Alternative to --path, where configuration profile name is used instead]: :($configs_names)" \
|
||||
{-S,--seal}"[Make the configuration profile permanently read-only]" \
|
||||
{-R,--revoke}"[<UID | username> Revoke this user access from this configuration profile]" \
|
||||
{-G,--grant}"[<UID | username> Grant this user access to this configuration profile]" \
|
||||
"--public-access[<true|false> Set/unset the public access flag]" \
|
||||
"--lock-down[<true|false> Set/unset the lock-down flag.Will disable config retrieval for users]: :(true false)" \
|
||||
"--config-path[OBJ-PATH Alias for --path]: :($configs_paths)" \
|
||||
}
|
||||
|
||||
_openvpn3_config-import(){
|
||||
_arguments \
|
||||
{-p,--persistent}"[Make the configuration profile persistent through service restarts]" \
|
||||
{-n,--name}"[NAME Provide a different name for the configuration (default: CFG-FILE)]" \
|
||||
{-h,--help}"[This help screen]" \
|
||||
{-c,--config}"[CFG-FILE Configuration file to import]: :_files" \
|
||||
}
|
||||
|
||||
_openvpn3_config-manage(){
|
||||
_arguments \
|
||||
{-s,--show}"[Show current configuration options]" \
|
||||
{-r,--rename}"[NEW-CONFIG-NAME Renames the configuration]" \
|
||||
{-o,--path}"[CONFIG-PATH Path to the configuration in the configuration manager]: :($configs_paths)" \
|
||||
{-h,--help}"[This help screen]" \
|
||||
{-c,--config}"[CONFIG-NAME Alternative to --path, where configuration profile name is used instead]: :($configs_names)" \
|
||||
"--unset-override[<name> Removes the <name> override]" \
|
||||
"--tls-version-min[<tls_1_0|tls_1_1|tls_1_2|tls_1_3> Sets the minimal TLS version for the control channel]: :(tls_1_0 tls_1_1 tls_1_2 tls_1_3)" \
|
||||
"--tls-cert-profile[<legacy preferred suiteb> Sets the control channel tls profile]: :(legacy preferred suiteb)" \
|
||||
"--server-override[<value> Replace the remote, connecting to this server instead the server specified in the configuration]" \
|
||||
"--proxy-username[<value> HTTP Proxy username to authenticate as]" \
|
||||
"--proxy-port[<value> HTTP Proxy port to connect on]" \
|
||||
"--proxy-password[<value> HTTP Proxy password to use for authentication]" \
|
||||
"--proxy-host[<value> HTTP Proxy to connect via, overrides configuration file http-proxy]" \
|
||||
"--proxy-auth-cleartext[<true|false> Adds the boolean override proxy-auth-cleartext]: :(true false)" \
|
||||
"--proto-override[<tcp|udp> Overrides the protocol being used]: :(tcp upd)" \
|
||||
"--port-override[<value> Replace the remote port, connecting to this port instead of the configuration value]" \
|
||||
"--persist-tun[<true|false> Adds the boolean override persist-tun]: :(true false)" \
|
||||
"--ipv6[<yes|no|default> Sets the IPv6 policy of the client]: :(yes no default)" \
|
||||
"--force-cipher-aes-cbc[<true|false> Adds the boolean override force-cipher-aes-cbc]: :(true false)" \
|
||||
"--dns-sync-lookup[<true|false> Adds the boolean override dns-sync-lookup]: :(true false)" \
|
||||
"--dns-setup-disabled[<true|false> Adds the boolean override dns-setup-disabled]: :(true false)" \
|
||||
"--dns-fallback-google[<true|false> Adds the boolean override dns-fallback-google]: :(true false)" \
|
||||
"--config-path[CONFIG-PATH Alias for --path]: :($configs_paths)" \
|
||||
"--auth-fail-retry[<true|false> Adds the boolean override auth-fail-retry]: :(true false)" \
|
||||
"--allow-compression[<no asym yes> Set compression mode]: :(no asym yes)" \
|
||||
}
|
||||
|
||||
_openvpn3_config-remove(){
|
||||
_arguments \
|
||||
{-o,--path}"[OBJ-PATH Path to the configuration in the configuration manager]: :($configs_paths)" \
|
||||
{-h,--help}"[This help screen]" \
|
||||
{-c,--config}"[CONFIG-NAME Alternative to --path, where configuration profile name is used instead]: :($configs_names)" \
|
||||
"--force[Force the deletion process without asking for confirmation]" \
|
||||
"--config-path[OBJ-PATH Alias for --path]: :($configs_paths)" \
|
||||
}
|
||||
|
||||
_openvpn3_config-show(){
|
||||
_arguments \
|
||||
{-o,--path}"[OBJ-PATH Path to the configuration in the configuration manager]: :($configs_paths)" \
|
||||
{-j,--json}"[Dump the configuration in JSON format]" \
|
||||
{-h,--help}"[This help screen]" \
|
||||
{-c,--config}"[CONFIG-NAME Alternative to --path, where configuration profile name is used instead]: :($configs_names)" \
|
||||
"--config-path[OBJ-PATH Alias for --path]: :($configs_paths)" \
|
||||
}
|
||||
|
||||
_openvpn3_configs-list(){
|
||||
_arguments \
|
||||
{-h,--help}"[This help screen]" \
|
||||
}
|
||||
|
||||
_openvpn3_help(){
|
||||
_arguments \
|
||||
{-h,--help}"[This help screen]" \
|
||||
}
|
||||
|
||||
_openvpn3_log(){
|
||||
_arguments \
|
||||
{-h,--help}"[This help screen]" \
|
||||
{-c,--config}"[CONFIG-NAME Alternative to --session-path, where configuration profile name is used instead]: :($sessions_configs_names $configs_names)" \
|
||||
{-I,--interface}"[INTERFACE Alternative to --session-path, where tun interface name is used instead]: :($sessions_interfaces)" \
|
||||
"--session-path[SESSION-PATH Receive log events for a specific session]: :($sessions_paths)" \
|
||||
"--log-level[LOG-LEVEL Set the log verbosity level of messages to be shown (default: 4)]" \
|
||||
"--config-events[Receive log events issued by the configuration manager]" \
|
||||
}
|
||||
|
||||
_openvpn3__session-acl(){
|
||||
_arguments \
|
||||
{-s,--show}"[Show the current access control lists]" \
|
||||
{-o,--path}"[SESSION-PATH Path to the session in the session manager]: :($sessions_paths)" \
|
||||
{-h,--help}"[This help screen]" \
|
||||
{-c,--config}"[CONFIG-NAME Alternative to --path, where configuration profile name is used instead]: :($sessions_configs_names)" \
|
||||
{-R,--revoke}"[<UID | username> Revoke this user access from this session]" \
|
||||
{-I,--interface}"[INTERFACE Alternative to --path, where tun interface name is used instead]: :($sessions_interfaces)" \
|
||||
{-G,--grant}"[<UID | username> Grant this user access to this session]" \
|
||||
"--session-path[SESSION-PATH Alias for --path]: :($sessions_paths)" \
|
||||
"--public-access[<true|false> Set/unset the public access flag]: :(true false)" \
|
||||
"--allow-log-access[<true|false> Can users granted access also access the session log?]: :(true false)" \
|
||||
}
|
||||
|
||||
_openvpn3_session-manage(){
|
||||
_arguments \
|
||||
{-o,--path}"[SESSION-PATH Path to the session in the session manager]: :($sessions_paths)" \
|
||||
{-h,--help}"[This help screen]" \
|
||||
{-c,--config}"[CONFIG-NAME Alternative to --path, where configuration profile name is used instead]: :($sessions_configs_names)" \
|
||||
{-R,--resume}"[Resumes a paused VPN session]" \
|
||||
{-P,--pause}"[Pauses the VPN session]" \
|
||||
{-I,--interface}"[INTERFACE Alternative to --path, where tun interface name is used instead]: :($sessions_interfaces)" \
|
||||
{-D,--disconnect}"[Disconnects a VPN session]" \
|
||||
"--session-path[SESSION-PATH Alias for --path]: :($sessions_paths)" \
|
||||
"--restart[Disconnect and reconnect a running VPN session]" \
|
||||
"--cleanup[Clean up stale sessions]" \
|
||||
}
|
||||
|
||||
_openvpn3_session-start(){
|
||||
_arguments \
|
||||
{-p,--config-path}"[CONFIG-PATH Configuration path to an already imported configuration]: :($configs_paths)" \
|
||||
{-h,--help}"[This help screen]" \
|
||||
{-c,--config}"[CONFIG-FILE Configuration file to start directly]: :_files" \
|
||||
"--persist-tun[Enforces persistent tun/seamless tunnel (requires --config)]" \
|
||||
}
|
||||
|
||||
_openvpn3_session-stats(){
|
||||
_arguments \
|
||||
{-o,--path}"[SESSION-PATH Path to the configuration in the configuration manager]: :($sessions_paths)" \
|
||||
{-j,--json}"[Dump the configuration in JSON format]" \
|
||||
{-h,--help}"[This help screen]" \
|
||||
{-c,--config}"[CONFIG-NAME Alternative to --path, where configuration profile name is used instead]: :($sessions_configs_names)" \
|
||||
{-I,--interface}"[INTERFACE Alternative to --path, where tun interface name is used instead]: :($sessions_interfaces)" \
|
||||
"--session-path[SESSION-PATH Alias for --path]: :($sessions_paths)" \
|
||||
}
|
||||
|
||||
_openvpn3_sessions-list(){
|
||||
_arguments \
|
||||
{-h,--help}"[This help screen]" \
|
||||
}
|
||||
|
||||
_openvpn3_shell-completion(){
|
||||
_arguments \
|
||||
{-h,--help}"[This help screen]" \
|
||||
"--list-commands[List all available commands]" \
|
||||
"--list-options[COMMAND List all available options for a specific command]: :($(openvpn3 shell-completion --list-commands))" \
|
||||
"--arg-helper[OPTION Used together with --list-options, lists value hint to an option]"
|
||||
}
|
||||
|
||||
_openvpn3_version(){
|
||||
_arguments \
|
||||
{-h,--help}"[This help screen]" \
|
||||
}
|
||||
|
||||
|
||||
_openvpn3_command(){
|
||||
local -a _openvpn3_cmds
|
||||
_openvpn3_cmds=(
|
||||
"config-acl: Manage access control lists for configurations" \
|
||||
"config-import: Import configuration profiles" \
|
||||
"config-manage: Manage configuration properties" \
|
||||
"config-remove: Remove an available configuration profile" \
|
||||
"config-show: Show/dump a configuration profile" \
|
||||
"configs-list: List all available configuration profiles" \
|
||||
"help: This help screen" \
|
||||
"log: Receive log events as they occur" \
|
||||
"session-acl: Manage access control lists for sessions" \
|
||||
"session-manage: Manage VPN sessions" \
|
||||
"session-start: Start a new VPN session" \
|
||||
"session-stats: Show session statistics" \
|
||||
"sessions-list: List available VPN sessions" \
|
||||
"shell-completion: Helper function to provide shell completion data" \
|
||||
"version: Show program version information" \
|
||||
)
|
||||
|
||||
if ((CURRENT == 1)); then
|
||||
_describe -t commands 'openvpn3 commands' _openvpn3_cmds
|
||||
else
|
||||
local curcontext="$curcontext"
|
||||
cmd="${${_openvpn3_cmds[(r)$words[1]:*]%%:*}}"
|
||||
if (($#cmd)); then
|
||||
if (( $+functions[_openvpn3_$cmd] )); then
|
||||
_openvpn3_$cmd
|
||||
else
|
||||
_message "no options for $cmd"
|
||||
fi
|
||||
else
|
||||
_message "no more options"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
_arguments \
|
||||
{-h,--help}"[that This help screen]" \
|
||||
"*::openvpn3 commands:_openvpn3_command" \
|
||||
|
|
@ -0,0 +1,145 @@
|
|||
#compdef ufw
|
||||
# ------------------------------------------------------------------------------
|
||||
# Copyright (c) 2016 Github zsh-users - https://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 The Uncomplicated Firewall (ufw). (https://launchpad.net/ufw).
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
# Authors
|
||||
# -------
|
||||
#
|
||||
# * Jindřich Pilař (https://github.com/JindrichPilar)
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
|
||||
_ufw_logging() {
|
||||
|
||||
local params additional second
|
||||
second=$words[2]
|
||||
|
||||
if [ ! -z $second ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
params=(
|
||||
"on"
|
||||
"off"
|
||||
)
|
||||
|
||||
additional=(
|
||||
"low"
|
||||
"medium"
|
||||
"high"
|
||||
"full"
|
||||
)
|
||||
|
||||
_describe -t params 'on/off' params
|
||||
_describe -t additional 'level' additional
|
||||
}
|
||||
|
||||
|
||||
_ufw_delete() {
|
||||
local rules complrules second
|
||||
|
||||
second=$words[2]
|
||||
|
||||
if [ ! -z $second ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
complrules=()
|
||||
rules=("${(f)$(ufw status | tr -s ' ' | tail -n +5 | tr -s '\n')}")
|
||||
|
||||
for ((i=1; i<=${#rules[@]}; i++)); do
|
||||
complrules+=("$i:$rules[i]");
|
||||
done
|
||||
|
||||
_describe -t complrules 'Rules' complrules
|
||||
}
|
||||
|
||||
_ufw() {
|
||||
local curcontext="$curcontext" ret=1
|
||||
local -a state line commands
|
||||
|
||||
commands=(
|
||||
"enable:enable the firewall"
|
||||
"disable:disable the firewall"
|
||||
"default:set default policy"
|
||||
"logging:set logging level"
|
||||
"allow:add allow rule"
|
||||
"deny:add deny rule"
|
||||
"reject:add reject rule"
|
||||
"limit:add limit rule"
|
||||
"delete:delete rule"
|
||||
"insert:insert rule at position"
|
||||
"route:add route rule"
|
||||
"reload:reload firewall"
|
||||
"reset:reset firewall"
|
||||
"status:show firewall status"
|
||||
"show:show firewall report"
|
||||
"version:display version information"
|
||||
"prepend:add rule before all of the same type"
|
||||
)
|
||||
|
||||
_arguments -C -s -S -n \
|
||||
'(- 1 *)'--version"[display version information]: :->full" \
|
||||
'(- 1 *)'{-h,--help}'[display usage information]: :->full' \
|
||||
'(- 1 *)'--dry-run"[don't modify anything, just show the changes]: :->cmds" \
|
||||
'1:cmd:->cmds' \
|
||||
'*:: :->args' && ret=0
|
||||
|
||||
case "$state" in
|
||||
(cmds)
|
||||
_describe -t commands 'commands' commands
|
||||
;;
|
||||
(args)
|
||||
local cmd
|
||||
cmd=$words[1]
|
||||
case "$cmd" in
|
||||
(logging)
|
||||
_ufw_logging && ret=0
|
||||
;;
|
||||
(delete)
|
||||
_ufw_delete && ret=0
|
||||
;;
|
||||
(*)
|
||||
_default && ret=0
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
(*)
|
||||
;;
|
||||
esac
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
_ufw
|
||||
|
|
@ -0,0 +1,127 @@
|
|||
#compdef vnstat
|
||||
# ------------------------------------------------------------------------------
|
||||
# Copyright (c) 2012 Github zsh-users - https://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 vnstat 2.10
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
# Authors
|
||||
# -------
|
||||
#
|
||||
# * Aaron Schrab <aaron@schrab.com>
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
local curcontext="$curcontext" state state_descr line ret=1
|
||||
typeset -A opt_args
|
||||
|
||||
local period="-d --days -h --hours -m --months -w --weeks"
|
||||
|
||||
_arguments -C : \
|
||||
'--add[create database entry for interface specified]' \
|
||||
'(-b --begin)'{-b,--begin}'[begin the list output with a specific date]:date:' \
|
||||
'--config[specify alternate configuration file]:file:_files' \
|
||||
"($period)"{-d,--days}'[show traffic for days]' \
|
||||
"($period)"{-h,--hours}'[show traffic for last 24 hours]' \
|
||||
"($period)"{-m,--months}'[show traffic for months]' \
|
||||
"($period)"{-w,--weeks}'[show traffic for 7 days]' \
|
||||
"($period)"{-y,--years}'[show traffic statistics for the last year]' \
|
||||
"($period)"{-5,--fiveminutes}'[show traffic statistic with a 5 minute resolution for the last hours]' \
|
||||
'--dbdir[specify database directory]:directory:_files -/' \
|
||||
'--dbiflist[List interfaces currently in the database]::mode:->dbiflist' \
|
||||
'(-D --debug)'{-D,--debug}'[show additional debug output]' \
|
||||
'(-e --end)'{-e,--end}'[end the list output with a specific date]:date:' \
|
||||
'--delete[delete database and stop monitoring selected interface]' \
|
||||
'--dumpdb[dump database in parseable format]' \
|
||||
'(--disable)--enable[enable updates for selected interface]' \
|
||||
'(--enable)--disable[disable updates for selected interface]' \
|
||||
'(-hg --hoursgraph)'{-hg,--hoursgraph}'[show traffic statistics using a bar graph]' \
|
||||
'(-i --iface)'{-i,--iface}'[specify interface for actions]:interface:->interface' \
|
||||
'--iflist[list available interfaces]' \
|
||||
'--limit[set the maximum number of shown entries]:limit:' \
|
||||
'(-l --live)'{-l,--live}'[display current transfer rate]:mode:->live' \
|
||||
'--json[show database content in json format]' \
|
||||
'--locale[specify locale]:locale:' \
|
||||
'--nick[set nickname for alias]:nickname:' \
|
||||
'--oneline[traffic summary in one-line, parseable format]' \
|
||||
'(-q --query)'{-q,--query}'[force database query mode]' \
|
||||
'--remove[delete the database entry for the interface specified]' \
|
||||
'--rename[rename the interface specified in the database with new name]' \
|
||||
'(-r --reset)'{-r,--reset}'[reset internal counters]' \
|
||||
'--setalias[set alias as an alias for the selected interface]:alias:' \
|
||||
'(-ru --rateunit)'{-ru,--rateunit}'[swap configured rate unit]' \
|
||||
'(-s --short)'{-s,--short}'[use short output mode]' \
|
||||
'--showconfig[show current configuration]' \
|
||||
'--style[modify content and style of output]:style:->style' \
|
||||
'--sync[synchronize internal counters]' \
|
||||
'--testkernel[test kernel boot time information]' \
|
||||
'(-t --top)'{-t,--top}'[show all time top traffic days]' \
|
||||
'(-tr --traffic)'{-tr,--traffic}'[calculate amount of traffic in given time]:seconds:' \
|
||||
'--xml[show database content in XML format]' \
|
||||
'(-)'{-v,--version}'[show current version]' \
|
||||
'(-)'{-\?,--help}'[show command summary]' \
|
||||
'(-)--longhelp[show complete options list]' \
|
||||
&& ret=0
|
||||
|
||||
case "$state" in
|
||||
(live)
|
||||
_values 'live mode' \
|
||||
'0[packets per second]' \
|
||||
'1[traffic counters]' && ret=0
|
||||
;;
|
||||
(style)
|
||||
_values 'output style' \
|
||||
'0[narrow output]' \
|
||||
'1[enable bar column]' \
|
||||
'2[bar column with average traffic rate]' \
|
||||
'3[enable average traffic rate]' \
|
||||
'4[disable use of terminal control characters]' && ret=0
|
||||
;;
|
||||
(interface)
|
||||
local interfaces="$(_call_program interfaces 'vnstat --iflist')"
|
||||
interfaces="${interfaces#*:}"
|
||||
_values -s + 'interface' ${(z)interfaces} && ret=0
|
||||
;;
|
||||
(dbiflist)
|
||||
_values 'mode' \
|
||||
'0[one line verbose format]' \
|
||||
'1[one interface per line]' \
|
||||
&& ret=0
|
||||
;;
|
||||
esac
|
||||
|
||||
return ret
|
||||
|
||||
# Local Variables:
|
||||
# mode: Shell-Script
|
||||
# sh-indentation: 2
|
||||
# indent-tabs-mode: nil
|
||||
# sh-basic-offset: 2
|
||||
# End:
|
||||
# vim: filetype=zsh shiftwidth=2 tabstop=2 expandtab
|
|
@ -0,0 +1,25 @@
|
|||
#compdef wg-quick
|
||||
# ------------------------------------------------------------------------------
|
||||
# Description
|
||||
# -----------
|
||||
#
|
||||
# Completion script for wg-quick (a script for easy managemant of wireguard
|
||||
# VPN tunnels) (https://www.wireguard.com/)
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
# Authors
|
||||
# -------
|
||||
#
|
||||
# * Nicolas Lenz <nicolas@eisfunke.com>
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
# The possible modes
|
||||
local modes=('up\:"bring a wireguard interface up"'\
|
||||
'down\:"tear down and remove a wireguard interface"'\
|
||||
'save\:"save configuration of a running wireguard interface"')
|
||||
|
||||
# 1: Complete mode
|
||||
# 2: Complete interface with all .conf files in /etc/wireguard without the filename extension.
|
||||
_arguments "1:mode:((${modes}))"\
|
||||
'2:interface:_path_files -W /etc/wireguard -g "*.conf(^/:r)"'
|
Loading…
Reference in New Issue