Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: simple completion example? (aptitude completion doesn't work)



Hi,

> It does work with the commands. It runs `aptitude -h' and parses the
> result to get a list of the commands (and descriptions) so perhaps you
> don't have aptitude installed.
Sure do :-)
But "aptitude<TAB>" just beeps.
"aptitude -h" lists all the available options.

Hm, I can't think of any settings in my RCs that would break the aptitude
completion but probably there is one, right?  I'll attach my completion
options to this mail.  Maybe one of them jumps at your eye...?

But then again... I tried the following:

condor:~>zsh -f
condor% echo $ZSH_VERSION 
4.2.5
condor% autoload -U compinit
condor% compinit -u
condor% xauth <TAB>
?         -- list available commands
add       -- add entry
exit      -- save changes and exit program
extract   -- extract entries into file
generate  -- use server to generate entry
help      -- print help
info      -- print information about entries
list      -- list entries
merge     -- merge entries from files
nextract  -- numerically extract entries
nlist     -- numerically list entries
nmerge    -- numerically merge entries
quit      -- abort changes and exit program
remove    -- remove entries
source    -- read commands from file

condor% aptitude <TAB>
BEEP

condor% aptitude --<TAB>
--assume-yes          -- assume yes answer to questions
--display-format      -- specify output format for search command
--download-only       -- just download packages - don't install
--help                -- display help information
--prompt              -- always display a prompt
--show-deps           -- show brief explanations of automatic installations and removals
--show-versions       -- show which versions of packages will be installed
--simulate            -- print actions without performing them
--sort                -- specify sort order
--verbose             -- causes some commands to display extra information
--version             -- display version information
--width               -- specify output width
--with-recommends     -- install recommended packages when installing new packages
--with-suggests       -- install suggested packages when installing new packages
--without-recommends  -- ignore recommended packages when installing new packages
--without-suggests    -- ignore suggested packages when installing new packages

So, xauth completion works but aptitude not.  Strange, isn't it?

> You could also look at _xauth but that doesn't handle options.
Ah, great, thanks!

Have a nice weekend,
 Andy.

-- 
                              o      _     _         _
  ------- __o       __o      /\_   _ \\o  (_)\__/o  (_)          -o)
  ----- _`\<,_    _`\<,_    _>(_) (_)/<_    \_| \   _|/' \/       /\\
  ---- (_)/ (_)  (_)/ (_)  (_)        (_)   (_)    (_)'  _\o_    _\_v
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Hain't we got all the fools in town on our side?  And hain't that a big
 enough majority in any town?  - Mark Twain, "Huckleberry Finn"
if /bin/true && [[ "$ZSH_VERSION_TYPE" == 'new' ]]; then
  autoload -U compinit
  compinit -u
else
  #print "\nAdvanced completion system not found; ignoring zstyle settings."
  which zstyle >/dev/null || function zstyle { }
  which compdef >/dev/null || function compdef { }
fi

## compstyle is obsoleted now
#which compstyle >/dev/null || alias compstyle=zstyle

# General completion technique
zstyle ':completion:*' completer _expand_dots _complete _match _correct _7slash
# oder auch: _approximate _history

# first try _match without appending a *
zstyle ':completion::match:*' original yes
zstyle ':completion::match:*' insert-unambiguous true
# options for approximate
zstyle ':completion::approximate:*' max-errors 2 numeric
zstyle ':completion::approximate:*' insert-unambiguous true

# don't complete the directory in which we are
zstyle ':completion:*' ignore-parents parent pwd

# don't complete the same filenames again
zstyle ':completion:*:(rm|cp|mv):*' ignore-line other

zstyle ':incremental' completer _complete _correct _7slash
zstyle ':predict' completer _complete

# Filename suffixes to ignore during completion
#fignore=(.o \~)
# better solution:
# filename suffixes to ignore during completion (except after rm command)
zstyle ':completion:*:*:(^rm):*:*files' ignored-patterns \
'*?.(o|c~)' '*?~'

# if there are other completions, always show them
unsetopt rec_exact

# we want . and .. to be completed, too
#zstyle ':completion:*:paths' special-dirs yes
zstyle ':completion:*:(cd|chdir|pushd|popd):*' special-dirs ..
# I want this for _all_ commands
zstyle ':completion:*:*:*' special-dirs ..

# complete case insensitive
#zstyle ":completion:*" matcher-list 'm:{A-ZÖÄÜa-zöäü}={a-zöäüA-ZÖÄÜ}'
zstyle ":completion:*" matcher-list 'm:{A-Zöäüa-zÖÄÜ}={a-zÖÄÜA-Zöäü}'
#zstyle ':completion:*' matcher-list '' 'r:|[._-]=* r:|=*' 'm:{a-zA-Z}={A-Za-z}'

zstyle ':completion:*' squeeze-slashes true

# menu selection if more than 5 files are to be completed
# use 'long' to start menu compl. if list is bigger than screen
#zstyle ':completion:*' menu yes=2 select=5 interactive
zstyle ':completion:*' menu select=5 interactive

# show the default prompt while scrolling during menu selection
MENUPROMPT=
setopt LIST_ROWS_FIRST LIST_PACKED

## completion caching
#zstyle ':completion::complete:*' use-cache 1
#zstyle ':completion::complete:*' cache-path ~/.zcompcache/$HOST
## Cache functions created by _regex_arguments
#zstyle '*' cache-path ~/.zsh/.cache-path
zstyle ':completion:*' use-cache on 
zstyle ':completion:*' cache-path ~/.zsh/cache/$HOST

# Expand partial paths
# ASp: too slow! :-(
#zstyle '*' expand 'yes'

## don't complete backup files as executables
#zstyle ':completion:*:complete:-command-::commands' ignored-patterns '*\~'

# Separate matches into groups
zstyle '*:matches' group 'yes'
zstyle ':completion:*' group-name ''
zstyle ':completion:*:*:-command-:*' group-order builtins functions aliases commands
zstyle ':completion:*' group-order files directories

# Describe each match group.
# This one assumes that your terminal has a dark background.
zstyle '*:descriptions' format "$fg_bold[yellow]%d$fg_no_bold[cyan]"

# Describe options in full
zstyle '*:options' description 'yes'
zstyle '*:options' auto-description '%d'

# don't show elements from cdpath when completing after cd
#zstyle ':completion:*:cd:*' tag-order local-directories path-directories

# emacs-like history-search (only search through the last 200 words)
zstyle '*:history-words' stop 'verbose'
zstyle '*:history-words' remove-all-dups 'yes'
zstyle '*:history-words' range '200'
# try slice by slice of each 500 words
#zstyle '*:history-words' range '200:500'

# Hosts, usernames, groups, ports
hosts=(
	"${(@)${(@s: :)${(@s:	:)${(@)${(@f)$(</etc/hosts)}%%\#*}#*[ 	]*}}:#}"
	$(<~/.zsh/.hosts.up)
	localhost
)
if [[ -r $HOME/.ssh/known_hosts ]]; then
  sshhosts=(
	${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[0-9]*}%%\ *}%%,*}
  )
# oder:
# zstyle -e ':completion:*:ssh:*' hosts \
#       'reply=($(sed -e "/^#/d" -e "s/ .*\$//" -e "s/,/ /g" \
#               /etc/ssh_known_hosts ~/.ssh/known_hosts 2>/dev/null))'
fi

#: ${(A)_etc_hosts:=${(s: :)${(ps:\t:)${${(f)"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}}
#hosts=(
#    "$_etc_hosts[@]"
#    localhost
#)

#ports=( "${(@)${(@)${(@f)$(</etc/services)}:#\#*}%%[ 	]*}" )

# groups=( $(cut -d: -f1 /etc/group) )
# groups=( $(ypcat group.byname | cut -d: -f1) ) # if you use NIS
# It can be done without forking, but it used too much memory in old zsh's:
groups=( "${(@)${(@f)$(</etc/group)}%%:*}" )
#groups=( "${(@)${(@f)$(ypcat groups)}%%:*}" ) # if you use NIS
users=( "${(@)${(@f)$(</etc/passwd)}%%:*}" )

if [[ "$USER" == "spiegl" && ( -x ~/bin/list.mail.aliases ) ]]; then
  muttaliases=( `~/bin/list.mail.aliases` )
  muttusers=( $muttaliases )
  mailusers=( $users `~/bin/list.mail.aliases -f` )
  #or:
  # _mutt_aliases=(${(o)${${(M)${(f)"$(< ~/.mutt/aliases)"}##alias*}/alias /}%% *})

  # to use these variables in all contexts
  zstyle ':completion:*:mutt:*' users $muttusers
  zstyle ':completion:*:mail:*' users $mailusers
  zstyle ':completion:*:checkalias:*' users $muttaliases

  # where to find mutt "mailboxes" and "alias" settings
  muttrc=~/.mutt/local
fi

zstyle ':completion:*' users $users
zstyle ':completion:*' hosts $hosts $sshhosts
#zstyle ':completion:*' groups $groups
#zstyle ':completion:*' ports $ports


# (user,host) pairs

# All my accounts:
#my_accounts=(
#    joe:
#    {joe,root}:mymachine.com
#    jbloggs:myothermachine.com
#)

# Other people's accounts:
#other_accounts=(
#    bob:
#    {fred,root}:hismachine.com
#    vera:hermachine.com
#)

#zstyle '*:my-accounts' users-hosts $my_accounts
#zstyle '*:other-accounts' users-hosts $other_accounts


# (host, port, user) triples for telnet

#  telnet_hosts_ports_users=(
#    host1::user1
#    host2::user2
#    mail-server:{smtp,pop3}:
#    news-server:nntp:
#    proxy-server:8000:
#  )
# }}}

# complete hostsnames here too
compdef _hosts vnc vnc-view
compdef _vnc xvncviewer

# completers for my aliases tarz, mktarz, ...
compdef _lstarz tarz mktarz lstarz untarz
compdef _lstar mktar lstar untar

# completions for some progs. not in default completion system
zstyle ':completion:*:*:mpg123:*' file-patterns \
'*.(mp3|MP3):mp3\ files *(-/):directories'

zstyle ':completion:*:*:ogg123:*' file-patterns \
'*.(ogg|OGG):ogg\ files *(-/):directories'

zstyle ':completion:*:*:vmware:*' file-patterns \
'*.(vmx|cfg):ogg\ files *(-/):directories'

# generic completions for programs which understand GNU long options(--help)
compdef _gnu_generic df casino wc alien Eterm pump hwclock date mv cp wordtrans rechnerbackup qiv rkhunter

# on processes completion complete all user processes
zstyle ':completion:*:processes' command 'ps -au$USER'

# add colors to processes for kill completion
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'

# show only active PCs for some network programs
#zstyle -e ':completion:*:vnc:*:hosts' hosts 'reply=( $(show.active.pcs) )'
#zstyle -e ':completion:*:vnc-view:*:hosts' hosts 'reply=( $(show.active.pcs) )'

zstyle ':completion:*' use-compctl false

# if no completion can be found, show all files
zstyle ':completion:*:*:muttf:argument*' tag-order globbed-files all-files

# complete according to modification time of files
zstyle ':completion:most-recent-file:*' match-original both
zstyle ':completion:most-recent-file::::' completer _menu _files _match
zstyle ':completion:most-recent-file:*' file-sort modification
zstyle ':completion:most-recent-file:*' file-patterns '*(.):normal\ files'
zstyle ':completion:most-recent-file:*' hidden all
#bindkey '^Xm' most-recent-file
zle -C most-recent-file menu-complete _generic



Messages sorted by: Reverse Date, Date, Thread, Author