项目作者: mqus

项目描述 :
The completion script for nft commands in a zsh shell.
高级语言:
项目地址: git://github.com/mqus/zsh-nft-completion.git
创建时间: 2018-09-08T12:45:58Z
项目社区:https://github.com/mqus/zsh-nft-completion

开源协议:GNU General Public License v3.0

下载


NOTE: This completion script has been moved to https://github.com/zsh-users/zsh-completions . This means it will most likely be installable via your package manager. You can still open issues here but the fixes will be applied there.

nft completion for zsh

This is an attempt to create zsh command completion for nft (the nftables user space utility). As I’m neither an expert in nft nor an expert in zsh, this simply works but may seem awful to experts of these domains. So please help me make this a better utility by making constructive criticism ;) .

Currently implemented subcommands: all commands listed in the man page, except the content of the add commands (eg. add rule, add set, add map, etcpp) and delete element. I’m currently working on add rule.

how to install:

Generally you have to enable command completion first:

Then you have to copy _nft in a directory of you choice, for this example we choose ~/.zsh

And enable loading that completion function by adding ~/.zsh to fpath. This must happen before compinit or sourcing ohmyzsh.sh

  1. fpath+=$HOME/.zsh
  2. # source ohmyzsh.sh or autoload -Uz compinit

tips:

If you want to have your tables/chains/… completed when you are not a root user but using sudo, you have to add the following to your .zshrc :

  1. zstyle ':completion::complete:*' gain-privileges 1

This will allow all completion scripts to search for completions with sudo if your command starts with sudo as well.

BUT: this also means that will allow (unchecked) scripts to run commands as sudo, so beware of the dangers!