_package_edit() { local context state state_descr line typeset -A opt_args local curcontext="$curcontext" _arguments -C \ "1:portage_conftype:->conftype"\ "2:portage_conffile:->confname" case $state in conftype) _arguments ':Portage Type:(accept_keywords accept_restrict env keywords license mask properties unmask use)' ;; confname) local -a conffiles conffiles=(/etc/portage/package.$words[2]/*(:t)) #printf '\n\n\n\n\naaaaa->%s<-aaaaa%saaaa\n\n\n\n' "$conffiles" "$words" #_arguments "2:portage_conffile:($conffiles)" if [[ $words[3] =~ '\w{3,}' ]]; then _message -r "maybe you need one of these:"$'\n'"$(cd /etc/portage/package.$words[2] 2>& - && grep -lFR $words[3] ./)" fi _values "Portage conffile" $conffiles ;; esac } package_edit() { local __su_mkdi=${__su_mkdir:-sudo mkdir} local __su_editor=${__su_editor:-sudoedit} local SUDO_EDITOR='vim -S /etc/vim/portage-'$1'-rc' #local SUDO_EDITOR="nano -w -Y /etc/portage" if [[ -d /etc/portage/package.$1 ]] { env SUDO_EDITOR="${SUDO_EDITOR}" $__su_editor /etc/portage/package.$1/$2 } elif [[ -n $2 ]] { $__su_mkdir etc/portage/package.$1 env SUDO_EDITOR="${SUDO_EDITOR}" $__su_editor /etc/portage/package.$1/$2 } else { env SUDO_EDITOR="${SUDO_EDITOR}" $__su_editor /etc/portage/package.$1 } } alias p.env="package_edit env" alias p.um="package_edit unmask" alias p.akw="package_edit accept_keywords" alias p.use="package_edit use" alias p.mask="package_edit mask" alias p.lic="package_edit license" alias mk.conf="sudoedit /etc/portage/make.conf" alias e-upd="sudo etc-update" alias s-upd="sudo emerge --update --deep --tree --with-bdeps=y @world" alias system-update="sudo emerge --update --deep --tree --with-bdeps=y @world" compdef _package_edit package_edit