I was wondering if anyone already had completion files for samba utils like
'net' wbinfo...etc... I can never remember all the params, I keep wanting
to hit <tab> to autocomplete for options like I can on many other sys
utils.
So I started looking at examples of existing completion files and started
cobbling one together... if no one else has some (which would be great!),
I'll probably continue work on this in a spare cycle every once in a while,
or if anyone wants to add to it, I'd appreciate additions...
Other utils do host and user name lookup when the param or field being
auto-completed needs such -- similar features would be nice in this one,
but it's my first attempt at writing autocompletion for anything,
To use it, just 'source it' (i.e.: ". <filename>" or "source <filename>").
It just has 1st level and a few 2nd level cmds at this point, so it's
pretty basic, but it's already helpful, so I thought I toss it out for
others to use/enhance/abuse.. etc.
I'm working w/samba 3.5.11 and bash 4.1, so it's may have some specifics to
those versions. It doesn't have any of the ads sub commands in it, as my
current version doesn't have ads compiled in. I don't know if
alphabetizing the compgen lists is needed (would certainly allow search
optimizations optimization if so), but am trying for alphabetizing the
response lists...(but it may be unnecessary).
---
-linda
#!/bin/bash
function _net {
COMPREPLY=();
local cur prev;
_get_comp_words_by_ref -n : cur prev;
_expand || return 0;
case $prev in
_a_dummy_)
COMPREPLY=($(compgen -W '' -- ))
return 0
;;
cache)
COMPREPLY=($(compgen -W 'add del flush get list search
stabilize' -- ))
return 0
;;
conf)
COMPREPLY=($(compgen -W 'addshare delincludes delparm
delshare drop getincludes getparm import list listshares setincludes setparm
showshare' -- ))
return 0
;;
dom)
COMPREPLY=($(compgen -W 'join renamecomputer unjoin' --
))
return 0
;;
eventlog)
COMPREPLY=($(compgen -W 'dump export import' -- ))
return 0
;;
g_lock)
COMPREPLY=($(compgen -W 'do dump locks' -- ))
return 0
;;
groupmap)
COMPREPLY=($(compgen -W 'add addmem cleanup delete
delmem list listmem memberships modify set ' -- ))
return 0
;;
groupmember)
COMPREPLY=($(compgen -W 'add delete list' -- ))
return 0
;;
idmap)
COMPREPLY=($(compgen -W 'aclmapset delete dump restore
secret setmap' -- ))
return 0
;;
registry)
COMPREPLY=($(compgen -W 'createkey deletekey
deletevalue enumerate getsd getvalue getvalueraw setvalue' --))
return 0
;;
rpc)
COMPREPLY=($(compgen -W 'audit info join oldjoin
testjoin user password group share file printer changetrustpw trustdom
abortshutdown shutdown samdump vampire getsid rights service registry shell' --
))
return 0
;;
rap)
COMPREPLY=($(compgen -W 'admin domain file group
groupmember password printq server session share user validate ' -- ))
return 0
;;
sam)
COMPREPLY=($(compgen -W 'addmem createbuiltingroup
createdomaingroup createlocalgroup deletedomaingroup deletelocalgroup delmem
list listmem mapunixgroup policy rights set show unmapunixgroup' -- ))
return 0
;;
server)
COMPREPLY=($(compgen -W 'domain name' -- ))
return 0
;;
share)
COMPREPLY=($(compgen -W 'add allowed delete list
migrate users' -- ))
return 0
;;
status)
COMPREPLY=($(compgen -W 'sessions shares' -- ))
return 0
;;
*)
esac;
case $cur in
*)
COMPREPLY=($(compgen -W 'admin ads cache changesecretpw
changetrustpw conf dom domain eventlog file getauthuser getdomainsid
getlocalsid g_lock group groupmap groupmember help idmap join lookup maxrid
password printq rap registry rpc sam server service session setauthuser
setdomainsid setlocalsid share status time user usershare usersidlist validate'
-- "$cur" ))
return 0
;;
esac;
return 0
}
complete -F _net -o nospace net
# Local variables:
# mode shell-script
# sh-basic-offset: 2
# sh-indent-comment: t
# indent-tabs-mode: nil
# End:
# ex ts=2 sw=2 filetype=bash
--
To unsubscribe from this list go to the following URL and read the
instructions: https://lists.samba.org/mailman/options/samba