Change rules size only on SIGWINCH.
$COLUMNS isn't updated on SIGWINCH yet so "tput" is used.
For better performance ruler is calculated by substring.
Moving ruler handler to trap cleans console from garbage when "set -x" is set
in interactive session. It is useful during debugging of bash completion.
# -*- mode: shell-script -*-[[ "$OSTYPE" = cygwin ]] && shopt -s completion_strip_exe# user commands see only userscomplete -u su passwd write chfn groups slay w sux# bg completes with stopped jobscomplete -A stopped -P '"%' -S '"' bg# other job commandscomplete -j -P '"%' -S '"' fg jobs disown# readonly and unset complete with shell variablescomplete -v readonly unset# set completes with set optionscomplete -A setopt set# shopt completes with shopt optionscomplete -A shopt shopt# helptopicscomplete -A helptopic help# unalias completes with aliasescomplete -a unalias# bind completes with readline bindings (make this more intelligent)complete -A binding bind# type and which complete on commandscomplete -c command type which# builtin completes on builtinscomplete -b builtin_hgsyncew() { local cur=${COMP_WORDS[COMP_CWORD]} COMPREPLY=( $(compgen -W "--push --modified" -- $cur) ) return 0}complete -F _hgsyncew -o nospace hgsyncew_pathsearch() { local prev cur=${COMP_WORDS[COMP_CWORD]} [[ $COMP_CWORD > 0 ]] && prev=${COMP_WORDS[COMP_CWORD-1]} if [[ $prev = -d ]]; then COMPREPLY=() return 0 fi case "$cur" in -*) COMPREPLY=( $(compgen -W "-d --delimiter= -h --help" -- $cur ) ) ;; *) COMPREPLY=() ;; esac return 0}complete -F _pathsearch -o nospace pathsearch_mycd() { local cur cur=${COMP_WORDS[COMP_CWORD]} if [[ -z "${CDPATH:-}" ]] || [[ $cur == ?(.)?(.)/* ]] || [[ $cur == '~'/* ]]; then compopt -o dirnames; COMPREPLY=() return 0 fi local i j k for i in ${CDPATH//:/$'\n'}; do for j in $( compgen -d -- $i/$cur ); do COMPREPLY+=(${j#$i/}/) done done return 0}complete -F _mycd -o nospace cd_man() { local p local cur=${COMP_WORDS[COMP_CWORD]} if [[ $cur = /* || $cur = ./* ]]; then COMPREPLY=( $(compgen -f -- $cur) ) fi local IFS=':' for p in /usr/share/man $MANPATH; do [[ -n $p ]] || continue p=( $p/man*/* ) p=( ${p[@]##*/} ) p=( ${p[@]%.gz} ) p=( ${p[@]%.*} ) p=( $(compgen -W '${p[@]}' -- $cur ) ) COMPREPLY=( ${COMPREPLY[@]} ${p[@]} ) done}complete -F _man man_make() { local i mk local dir=. local cur=${COMP_WORDS[COMP_CWORD]} if [[ $cur = -* ]]; then COMPREPLY=( $(compgen -W "-C -f" -- "$cur") ) return 0 fi [[ $COMP_CWORD > 0 ]] && prev=${COMP_WORDS[COMP_CWORD-1]} for (( i=1; i < ${#COMP_WORDS[@]}-1; i++ )); do case ${COMP_WORDS[i]} in -f) mk=${COMP_WORDS[i+1]} ;; -C) dir=${COMP_WORDS[i+1]} ;; esac done if [[ $prev = -C ]]; then COMPREPLY=( $(compgen -d -- "$cur") ) return 0 fi if [[ $prev = -f ]]; then COMPREPLY=( $(cd $dir >/dev/null 2>&1; compgen -f -- "$cur") ) return 0 fi mk=$dir/$mk [[ -f $mk ]] || mk=$(eval echo $dir/[Mm]akefile) [[ -f $mk ]] || return 1 COMPREPLY=( $(compgen -W "$(sed -n -e '/^[[:alnum:]_-]*:/{s=^\([^:]*\):.*=\1=;p;}' $mk)" -- $cur) ) return 0}complete -F _make make gmake pmake_cygcheck() { local opt local cur=${COMP_WORDS[COMP_CWORD]} case $COMP_CWORD in 1) case $cur in -*) COMPREPLY=( $(compgen -W "-v --verbose -h --help -V --version -c --check-setup -s --sysinfo -k --keycheck -f --find-package -l --list-package -p --package-query" -- "$cur") ) return 0 ;; *) COMPREPLY=( $(compgen -c -- "$cur") ) return 0 ;; esac ;; 2) opt=${COMP_WORDS[1]} case $opt in -c|--check-setup|-l|--list-package) local pkgs=( /etc/setup/*.lst.gz ) pkgs=( ${pkgs[@]##*/} ) pkgs=( ${pkgs[@]%.lst.gz} ) COMPREPLY=( $(compgen -W '${pkgs[@]}' -- $cur ) ) return 0;; esac return 0;; esac return 0}complete -F _cygcheck cygcheck.exe cygcheck_lighty() { local cur=${COMP_WORDS[COMP_CWORD]} local mods=( /etc/lighttpd/conf-available/*.conf ) mods=( ${mods[@]##*/} ) mods=( ${mods[@]#??-} ) mods=( ${mods[@]%.conf} ) COMPREPLY=( $(compgen -W '${mods[@]}' -- $cur) ) return 0}complete -F _lighty lighty-disable-modcomplete -F _lighty lighty-enable-modcomplete -F _lighty lighttpd-disable-modcomplete -F _lighty lighttpd-enable-mod