# vim: ts=8:sw=4:sts=4:et:ft=zsh: # kate: byte-order-marker false; dynamic-word-wrap false; indent-mode normal; indent-pasted-text true; indent-width 4; keep-extra-spaces false; newline-at-eof true; remove-trailing-spaces all; replace-tabs true; replace-tabs-save true; show-tabs true; smart-home true; syntax Zsh; tab-width 8; word-wrap false; #----------------------------------------------------------------------- # # This function lists options with the no's in front removed for # improved comprehension, i.e. `norcs off' becomes `rcs on'. # The format is otherwise like that with `kshoptionprint' set, # i.e. you can see all options whether on or off. # It can take a list of option names or parts thereof to search for # via egrep. # # Written by Sweth Chandramouli with hacks by Bart Schaefer. # updated by Thilo Six # allopt() { local OPT_NAME OPT_VALUE LENGTH i local -a OPT_NAMES_ALL local -A OPT_ALL OPT_NAMES_ALL=(${(ok@)options}) # http://zsh.sourceforge.net/Guide/zshguide05.html LENGTH=$(( ${#${OPT_NAMES_ALL[(r)${(l.${#${(O@)OPT_NAMES_ALL//?/X}[1]}..?.)}]}} + 1 )) ### XXX note: # make a backup of ${(@)options} # this needs to be done because otherwise # the listing is inaccurat e.g. 'monitor' and 'zle' are always off # the set builtin treats them special within a pipe. compare this: # % builtin set -o # with # % builtin set -o | command grep -E '(\|\)' # OPT_ALL=(${(kv@)options}) { for i in ${OPT_NAMES_ALL} ; do echo "${i} ${OPT_ALL[$i]}" ; done | while read OPT_NAME OPT_VALUE ; do if [[ ${OPT_NAME#no} != ${OPT_NAME} ]] ; then OPT_VALUE=${(L)${${OPT_VALUE:s/on/OFF}:s/off/on}} OPT_NAME=${OPT_NAME#no} fi echo "${(r:${LENGTH}:)OPT_NAME} ${OPT_VALUE}" done } | { if [[ -n ${*} ]] ; then egrep ${(j.|.)${${${(L)@}#no}//[-_]/}} else cat fi } # }