This gist contains completion scripts for samba-tool
and net
from the Samba CLI.
They may not be entirely complete as the Samba project is a dynamic one and the target is moving.
net |
#!/bin/bash | |
_samba_tool_completion() { | |
local cur prev words cword | |
_init_completion -n : || return | |
# Main samba-tool commands for auto-completion | |
local main_commands="computer contact dbcheck delegation dns domain drs dsacl forest fsmo gpo group ldapcmp ntacl ou processes rodc schema shell sites spn testparm time user visualize" | |
# Subcommands for computer, contact, delegation, dns, ou, domain, drs, dsacl, forest, fsmo, gpo, group, and ntacl | |
local computer_subcommands="add create delete edit list move show" | |
local contact_subcommands="add create delete edit list move rename show" | |
local delegation_subcommands="add-principal add-service del-principal del-service for-any-protocol for-any-service show" | |
local dns_subcommands="add cleanup delete query roothints serverinfo update zonecreate zonedelete zoneinfo zonelist zoneoptions" | |
local ou_subcommands="add create delete list listobjects move rename" | |
local domain_subcommands="auth backup claim classicupgrade dcpromo demote exportkeytab functionalprep info join leave level passwordsettings provision schemaupgrade tombstones trust" | |
local drs_subcommands="bind clone-dc-database kcc options replicate showrepl uptodateness" | |
local dsacl_subcommands="delete get set" | |
local forest_subcommands="directory_service" | |
local fsmo_subcommands="seize show transfer" | |
local gpo_subcommands="aclcheck admxload backup create cse del dellink fetch getinheritance getlink list listall listcontainers load manage remove restore setinheritance setlink show" | |
local group_subcommands="add addmembers addunixattrs create delete edit list listmembers move removemembers rename show stats" | |
local ntacl_subcommands="changedomsid get getdosinfo set sysvolcheck sysvolreset" | |
case "$prev" in | |
samba-tool) | |
COMPREPLY=($(compgen -W "$main_commands" -- "$cur")) | |
;; | |
computer) | |
COMPREPLY=($(compgen -W "$computer_subcommands" -- "$cur")) | |
;; | |
contact) | |
COMPREPLY=($(compgen -W "$contact_subcommands" -- "$cur")) | |
;; | |
delegation) | |
COMPREPLY=($(compgen -W "$delegation_subcommands" -- "$cur")) | |
;; | |
dns) | |
COMPREPLY=($(compgen -W "$dns_subcommands" -- "$cur")) | |
;; | |
ou) | |
COMPREPLY=($(compgen -W "$ou_subcommands" -- "$cur")) | |
;; | |
domain) | |
COMPREPLY=($(compgen -W "$domain_subcommands" -- "$cur")) | |
;; | |
drs) | |
COMPREPLY=($(compgen -W "$drs_subcommands" -- "$cur")) | |
;; | |
dsacl) | |
COMPREPLY=($(compgen -W "$dsacl_subcommands" -- "$cur")) | |
;; | |
forest) | |
COMPREPLY=($(compgen -W "$forest_subcommands" -- "$cur")) | |
;; | |
fsmo) | |
COMPREPLY=($(compgen -W "$fsmo_subcommands" -- "$cur")) | |
;; | |
gpo) | |
COMPREPLY=($(compgen -W "$gpo_subcommands" -- "$cur")) | |
;; | |
group) | |
COMPREPLY=($(compgen -W "$group_subcommands" -- "$cur")) | |
;; | |
ntacl) | |
COMPREPLY=($(compgen -W "$ntacl_subcommands" -- "$cur")) | |
;; | |
# Placeholder for additional logic to complete subcommand arguments or options. | |
*) | |
;; | |
esac | |
} | |
complete -F _samba_tool_completion samba-tool |