Facebook
From Social Rhinoceros, 2 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 335
  1. compdump () {
  2.         # undefined
  3.         builtin autoload -XUz
  4. }
  5. compinit () {
  6.         emulate -L zsh
  7.         setopt extendedglob
  8.         typeset _i_dumpfile _i_files _i_line _i_done _i_dir _i_autodump=1
  9.         typeset _i_tag _i_file _i_addfiles _i_fail=ask _i_check=yes _i_name
  10.         while [[ $# -gt 0 && $1 = -[dDiuC] ]]
  11.         do
  12.                 case "$1" in
  13.                         (-d) _i_autodump=1
  14.                                 shift
  15.                                 if [[ $# -gt 0 && "$1" != -[dfQC] ]]
  16.                                 then
  17.                                         _i_dumpfile="$1"
  18.                                         shift
  19.                                 fi ;;
  20.                         (-D) _i_autodump=0
  21.                                 shift ;;
  22.                         (-i) _i_fail=ign
  23.                                 shift ;;
  24.                         (-u) _i_fail=use
  25.                                 shift ;;
  26.                         (-C) _i_check=
  27.                                 shift ;;
  28.                 esac
  29.         done
  30.         typeset -gHA _comps _services _patcomps _postpatcomps
  31.         typeset -gHA _compautos
  32.         typeset -gHA _lastcomp
  33.         if [[ -n $_i_dumpfile ]]
  34.         then
  35.                 typeset -g _comp_dumpfile="$_i_dumpfile"
  36.         else
  37.                 typeset -g _comp_dumpfile="${ZDOTDIR:-$HOME}/.zcompdump"
  38.         fi
  39.         typeset -gHa _comp_options
  40.         _comp_options=(bareglobqual extendedglob glob multibyte multifuncdef nullglob rcexpandparam unset NO_allexport NO_aliases NO_cshnullglob NO_cshjunkiequotes NO_errexit NO_errreturn NO_globassign NO_globsubst NO_histsubstpattern NO_ignorebraces NO_ignoreclosebraces NO_kshglob NO_ksharrays NO_kshtypeset NO_markdirs NO_octalzeroes NO_posixbuiltins NO_posixidentifiers NO_shwordsplit NO_shglob NO_warnnestedvar NO_warncreateglobal)
  41.         typeset -gH _comp_setup='local -A _comp_caller_options;
  42.              _comp_caller_options=(${(kv)options[@]});
  43.              setopt localoptions localtraps localpatterns ${_comp_options[@]};
  44.              local IFS=$'\'\ \\t\\r\\n\\0\'';
  45.              builtin enable -p \| \~ \( \? \* \[ \< \^ \# 2>&-;
  46.              exec </dev/null;
  47.              trap - ZERR;
  48.              local -a reply;
  49.              local REPLY;
  50.              local REPORTTIME;
  51.              unset REPORTTIME'
  52.         typeset -ga compprefuncs comppostfuncs
  53.         compprefuncs=()
  54.         comppostfuncs=()
  55.         : $funcstack
  56.         compdef () {
  57.                 local opt autol type func delete eval new i ret=0 cmd svc
  58.                 local -a match mbegin mend
  59.                 emulate -L zsh
  60.                 setopt extendedglob
  61.                 if (( ! $# ))
  62.                 then
  63.                         print -u2 "$0: I need arguments"
  64.                         return 1
  65.                 fi
  66.                 while getopts "anpPkKde" opt
  67.                 do
  68.                         case "$opt" in
  69.                                 (a) autol=yes  ;;
  70.                                 (n) new=yes  ;;
  71.                                 ([pPkK]) if [[ -n "$type" ]]
  72.                                         then
  73.                                                 print -u2 "$0: type already set to $type"
  74.                                                 return 1
  75.                                         fi
  76.                                         if [[ "$opt" = p ]]
  77.                                         then
  78.                                                 type=pattern
  79.                                         elif [[ "$opt" = P ]]
  80.                                         then
  81.                                                 type=postpattern
  82.                                         elif [[ "$opt" = K ]]
  83.                                         then
  84.                                                 type=widgetkey
  85.                                         else
  86.                                                 type=key
  87.                                         fi ;;
  88.                                 (d) delete=yes  ;;
  89.                                 (e) eval=yes  ;;
  90.                         esac
  91.                 done
  92.                 shift OPTIND-1
  93.                 if (( ! $# ))
  94.                 then
  95.                         print -u2 "$0: I need arguments"
  96.                         return 1
  97.                 fi
  98.                 if [[ -z "$delete" ]]
  99.                 then
  100.                         if [[ -z "$eval" ]] && [[ "$1" = *\=* ]]
  101.                         then
  102.                                 while (( $# ))
  103.                                 do
  104.                                         if [[ "$1" = *\=* ]]
  105.                                         then
  106.                                                 cmd="${1%%\=*}"
  107.                                                 svc="${1#*\=}"
  108.                                                 func="$_comps[${_services[(r)$svc]:-$svc}]"
  109.                                                 [[ -n ${_services[$svc]} ]] && svc=${_services[$svc]}
  110.                                                 [[ -z "$func" ]] && func="${${_patcomps[(K)$svc][1]}:-${_postpatcomps[(K)$svc][1]}}"
  111.                                                 if [[ -n "$func" ]]
  112.                                                 then
  113.                                                         _comps[$cmd]="$func"
  114.                                                         _services[$cmd]="$svc"
  115.                                                 else
  116.                                                         print -u2 "$0: unknown command or service: $svc"
  117.                                                         ret=1
  118.                                                 fi
  119.                                         else
  120.                                                 print -u2 "$0: invalid argument: $1"
  121.                                                 ret=1
  122.                                         fi
  123.                                         shift
  124.                                 done
  125.                                 return ret
  126.                         fi
  127.                         func="$1"
  128.                         [[ -n "$autol" ]] && autoload -Uz "$func"
  129.                         shift
  130.                         case "$type" in
  131.                                 (widgetkey) while [[ -n $1 ]]
  132.                                         do
  133.                                                 if [[ $# -lt 3 ]]
  134.                                                 then
  135.                                                         print -u2 "$0: compdef -K requires <widget> <comp-widget> <key>"
  136.                                                         return 1
  137.                                                 fi
  138.                                                 [[ $1 = _* ]] || 1="_$1"
  139.                                                 [[ $2 = .* ]] || 2=".$2"
  140.                                                 [[ $2 = .menu-select ]] && zmodload -i zsh/complist
  141.                                                 zle -C "$1" "$2" "$func"
  142.                                                 if [[ -n $new ]]
  143.                                                 then
  144.                                                         bindkey "$3" | IFS=$' \t' read -A opt
  145.                                                         [[ $opt[-1] = undefined-key ]] && bindkey "$3" "$1"
  146.                                                 else
  147.                                                         bindkey "$3" "$1"
  148.                                                 fi
  149.                                                 shift 3
  150.                                         done ;;
  151.                                 (key) if [[ $# -lt 2 ]]
  152.                                         then
  153.                                                 print -u2 "$0: missing keys"
  154.                                                 return 1
  155.                                         fi
  156.                                         if [[ $1 = .* ]]
  157.                                         then
  158.                                                 [[ $1 = .menu-select ]] && zmodload -i zsh/complist
  159.                                                 zle -C "$func" "$1" "$func"
  160.                                         else
  161.                                                 [[ $1 = menu-select ]] && zmodload -i zsh/complist
  162.                                                 zle -C "$func" ".$1" "$func"
  163.                                         fi
  164.                                         shift
  165.                                         for i
  166.                                         do
  167.                                                 if [[ -n $new ]]
  168.                                                 then
  169.                                                         bindkey "$i" | IFS=$' \t' read -A opt
  170.                                                         [[ $opt[-1] = undefined-key ]] || continue
  171.                                                 fi
  172.                                                 bindkey "$i" "$func"
  173.                                         done ;;
  174.                                 (*) while (( $# ))
  175.                                         do
  176.                                                 if [[ "$1" = -N ]]
  177.                                                 then
  178.                                                         type=normal
  179.                                                 elif [[ "$1" = -p ]]
  180.                                                 then
  181.                                                         type=pattern
  182.                                                 elif [[ "$1" = -P ]]
  183.                                                 then
  184.                                                         type=postpattern
  185.                                                 else
  186.                                                         case "$type" in
  187.                                                                 (pattern) if [[ $1 = (#b)(*)=(*) ]]
  188.                                                                         then
  189.                                                                                 _patcomps[$match[1]]="=$match[2]=$func"
  190.                                                                         else
  191.                                                                                 _patcomps[$1]="$func"
  192.                                                                         fi ;;
  193.                                                                 (postpattern) if [[ $1 = (#b)(*)=(*) ]]
  194.                                                                         then
  195.                                                                                 _postpatcomps[$match[1]]="=$match[2]=$func"
  196.                                                                         else
  197.                                                                                 _postpatcomps[$1]="$func"
  198.                                                                         fi ;;
  199.                                                                 (*) if [[ "$1" = *\=* ]]
  200.                                                                         then
  201.                                                                                 cmd="${1%%\=*}"
  202.                                                                                 svc=yes
  203.                                                                         else
  204.                                                                                 cmd="$1"
  205.                                                                                 svc=
  206.                                                                         fi
  207.                                                                         if [[ -z "$new" || -z "${_comps[$1]}" ]]
  208.                                                                         then
  209.                                                                                 _comps[$cmd]="$func"
  210.                                                                                 [[ -n "$svc" ]] && _services[$cmd]="${1#*\=}"
  211.                                                                         fi ;;
  212.                                                         esac
  213.                                                 fi
  214.                                                 shift
  215.                                         done ;;
  216.                         esac
  217.                 else
  218.                         case "$type" in
  219.                                 (pattern) unset "_patcomps[$^@]" ;;
  220.                                 (postpattern) unset "_postpatcomps[$^@]" ;;
  221.                                 (key) print -u2 "$0: cannot restore key bindings"
  222.                                         return 1 ;;
  223.                                 (*) unset "_comps[$^@]" ;;
  224.                         esac
  225.                 fi
  226.         }
  227.         typeset _i_wdirs _i_wfiles
  228.         _i_wdirs=()
  229.         _i_wfiles=()
  230.         autoload -Uz compaudit
  231.         if [[ -n "$_i_check" ]]
  232.         then
  233.                 typeset _i_q
  234.                 if ! eval compaudit
  235.                 then
  236.                         if [[ -n "$_i_q" ]]
  237.                         then
  238.                                 if [[ "$_i_fail" = ask ]]
  239.                                 then
  240.                                         if ! read -q "?zsh compinit: insecure $_i_q, run compaudit for list.
  241. Ignore insecure $_i_q and continue [y] or abort compinit [n]? "
  242.                                         then
  243.                                                 print -u2 "$0: initialization aborted"
  244.                                                 unfunction compinit compdef
  245.                                                 unset _comp_dumpfile _comp_secure compprefuncs comppostfuncs _comps _patcomps _postpatcomps _compautos _lastcomp
  246.                                                 return 1
  247.                                         fi
  248.                                         _i_wfiles=()
  249.                                         _i_wdirs=()
  250.                                 else
  251.                                         (( $#_i_wfiles )) && _i_files=("${(@)_i_files:#(${(j:|:)_i_wfiles%.zwc})}")
  252.                                         (( $#_i_wdirs )) && _i_files=("${(@)_i_files:#(${(j:|:)_i_wdirs%.zwc})/*}")
  253.                                 fi
  254.                         fi
  255.                         typeset -g _comp_secure=yes
  256.                 fi
  257.         fi
  258.         autoload -Uz compdump compinstall
  259.         _i_done=''
  260.         if [[ -f "$_comp_dumpfile" ]]
  261.         then
  262.                 if [[ -n "$_i_check" ]]
  263.                 then
  264.                         IFS=$' \t' read -rA _i_line < "$_comp_dumpfile"
  265.                         if [[ _i_autodump -eq 1 && $_i_line[2] -eq $#_i_files && $ZSH_VERSION = $_i_line[4] ]]
  266.                         then
  267.                                 builtin . "$_comp_dumpfile"
  268.                                 _i_done=yes
  269.                         fi
  270.                 else
  271.                         builtin . "$_comp_dumpfile"
  272.                         _i_done=yes
  273.                 fi
  274.         fi
  275.         if [[ -z "$_i_done" ]]
  276.         then
  277.                 typeset -A _i_test
  278.                 for _i_dir in $fpath
  279.                 do
  280.                         [[ $_i_dir = . ]] && continue
  281.                         (( $_i_wdirs[(I)$_i_dir] )) && continue
  282.                         for _i_file in $_i_dir/^([^_]*|*~|*.zwc)(N)
  283.                         do
  284.                                 _i_name="${_i_file:t}"
  285.                                 (( $+_i_test[$_i_name] + $_i_wfiles[(I)$_i_file] )) && continue
  286.                                 _i_test[$_i_name]=yes
  287.                                 IFS=$' \t' read -rA _i_line < $_i_file
  288.                                 _i_tag=$_i_line[1]
  289.                                 shift _i_line
  290.                                 case $_i_tag in
  291.                                         (\#compdef) if [[ $_i_line[1] = -[pPkK](n|) ]]
  292.                                                 then
  293.                                                         compdef ${_i_line[1]}na "${_i_name}" "${(@)_i_line[2,-1]}"
  294.                                                 else
  295.                                                         compdef -na "${_i_name}" "${_i_line[@]}"
  296.                                                 fi ;;
  297.                                         (\#autoload) autoload -Uz "$_i_line[@]" ${_i_name}
  298.                                                 [[ "$_i_line" != \ # ]] && _compautos[${_i_name}]="$_i_line"  ;;
  299.                                 esac
  300.                         done
  301.                 done
  302.                 if [[ $_i_autodump = 1 ]]
  303.                 then
  304.                         compdump
  305.                 fi
  306.         fi
  307.         for _i_line in complete-word delete-char-or-list expand-or-complete expand-or-complete-prefix list-choices menu-complete menu-expand-or-complete reverse-menu-complete
  308.         do
  309.                 zle -C $_i_line .$_i_line _main_complete
  310.         done
  311.         zle -la menu-select && zle -C menu-select .menu-select _main_complete
  312.         bindkey '^i' | IFS=$' \t' read -A _i_line
  313.         if [[ ${_i_line[2]} = expand-or-complete ]] && zstyle -a ':completion:' completer _i_line && (( ${_i_line[(i)_expand]} <= ${#_i_line} ))
  314.         then
  315.                 bindkey '^i' complete-word
  316.         fi
  317.         unfunction compinit compaudit
  318.         autoload -Uz compinit compaudit
  319.         return 0
  320. }
  321. compinstall () {
  322.         # undefined
  323.         builtin autoload -XUz
  324. }
  325. polet% cat .zshrc
  326. # Lines configured by zsh-newuser-install
  327. HISTFILE=~/.histfile
  328. HISTSIZE=1000
  329. SAVEHIST=1000
  330. bindkey -e
  331. # End of lines configured by zsh-newuser-install
  332. # The following lines were added by compinstall
  333. zstyle :compinstall filename '/home/observer/.zshrc'
  334.  
  335. autoload -Uz compinit
  336. compinit
  337. # End of lines added by compinstall
  338.