#compdef eselect # Author: Piotr 'qermit' Miedzik # implemented eselect functions: # compiler, binutils, bashcomp, env, kernel, lapack, mailer, opengl, profile, rc _eselect_compiler () { if (( CURRENT == 1 ));then _values "eselect module" \ 'help[Display a help message]' \ 'usage[Display a usage message]' \ 'version[Display version information]' \ 'getval[Print information for the given profile.]' \ 'list[List all installed compiler profiles.]' \ 'migrate[Convert gcc-1.x profiles. This will not overwrite existing profiles, so you should backup //etc/eselect/compiler first.]' \ 'set[Select a compiler profile.]' \ 'show[Print the current active configuration. It can take a CTARGET argument]' \ 'unset[Deactivate a selected profile.]' \ 'update[Refresh all the installed wrappers.]' elif (( CURRENT == 2 )); then if [[ $words[1] == 'set' ]];then local profile profile=`ls /etc/env.d/gcc |grep -v config` _tags profile && { compadd "$@" -k profile || compadd "$@" ${(kv)=profile} } elif [[ $words[1] == 'getval' ]];then local zm zm="BINPATH INFOPATH MANPATH LDPATH STDCXX_INCDIR GCC_SPECS CFLAGS" compadd ${(kv)=zm} fi fi } _eselect_binutils () { if (( CURRENT == 1 ));then _values "eselect module" \ 'help[Display a help message]' \ 'usage[Display a usage message]' \ 'version[Display version information]' \ 'list[List all installed version of binutils]' \ 'set[Activate one of the installed binutils]' \ 'show[Print the currently active binutils version]' elif (( CURRENT == 2 )); then if [[ $words[1] == 'set' ]];then local profile profile=`ls /etc/env.d/binutils |grep -v '^config'` _tags profile && { compadd "$@" -k profile || compadd "$@" ${(kv)=profile} } fi fi } _eselect_bashcomp () { if (( CURRENT == 1 ));then _values "eselect module" \ 'help[Display a help message]' \ 'usage[Display a usage message]' \ 'version[Display version information]' \ 'disable[Disable specified completion(s)]' \ 'enable[Enable specified completion(s)]' \ 'list[List available completions]' fi } _eselect_env () { if (( CURRENT == 1 ));then _values "eselect module" \ 'help[Display a help message]' \ 'usage[Display a usage message]' \ 'version[Display version information]' \ 'update[Collect environment variables from all scripts in /etc/env.d/]' fi } _eselect_kernel () { if (( CURRENT == 1 ));then _values "eselect module" \ 'help[Display a help message]' \ 'usage[Display a usage message]' \ 'version[Display version information]' \ 'list[List available kernel symlink targets]' \ 'set[Set a new kernel symlink target]' \ 'show[Show the current kernel symlink]' elif (( CURRENT == 2 )); then if [[ $words[1] == 'set' ]];then local profile profile=(/usr/src/linux-*(:t)) _tags profile && { compadd "$@" -k profile || compadd "$@" ${(kv)=profile} } fi fi } _eselect_lapack () { if (( CURRENT == 1 ));then _values "eselect module" \ 'help[Display a help message]' \ 'usage[Display a usage message]' \ 'version[Display version information]' \ 'list[List all installed LAPACK implementations]' \ 'scan[Scans the system for data about all installed LAPACK implementations]' \ 'set[Setup one of the installed LAPACK implementations as the active implementation]' \ 'show[Show the currently active LAPACK implementations]' elif (( CURRENT == 2 )); then if [[ $words[1] == 'set' ]];then fi fi } _eselect_mailer () { if (( CURRENT == 1 ));then _values "eselect module" \ 'help[Display a help message]' \ 'usage[Display a usage message]' \ 'version[Display version information]' \ 'list[List available mailer.conf profiles]' \ 'set[List available mailer.conf profiles]' \ 'show[Set a new mailer.conf profile]' elif (( CURRENT == 2 )); then if [[ $words[1] == 'set' ]];then fi fi } _eselect_opengl () { if (( CURRENT == 1 ));then _values "eselect module" \ 'help[Display a help message]' \ 'usage[Display a usage message]' \ 'version[Display version information]' \ 'list[List the available OpenGL implementations.]' \ 'set[Select the OpenGL implementation.]' \ 'show[Print the current OpenGL implementation.]' elif (( CURRENT == 2 )); then if [[ $words[1] == 'set' ]];then _values "opengl-update options" \ 'xorg-x11[Use libGL.so from X.Org]' \ 'xfree[Use libGL.so from XFree86]' \ 'nvidia[Use libGL.so from the NVidia drivers.]' fi fi } _eselect_profile () { if (( CURRENT == 1 ));then _values "eselect module" \ 'help[Display a help message]' \ 'usage[Display a usage message]' \ 'version[Display version information]' \ 'list[List the available OpenGL implementations.]' \ 'set[Select the OpenGL implementation.]' \ 'show[Print the current OpenGL implementation.]' elif (( CURRENT == 2 )); then if [[ $words[1] == 'set' ]];then local profile profile=$(sed -n -e "s|^x86[[:space:]]\+\([^[:space:]]\+\).*$|\1|p" /usr/portage/profiles/profiles.desc) _tags profile && { compadd "$@" -k profile || compadd "$@" ${(kv)=profile} } fi fi } _eselect_rc () { local gentoo_runlevels init_scripts used_scripts gentoo_runlevels=(/etc/runlevels/*(:t)) init_scripts=(/etc/init.d/*(:t)) used_scripts=$(ls /etc/runlevels/*/* |xargs -l basename |sort |uniq) if (( CURRENT == 1 ));then _values "eselect module" \ 'help[Display a help message]' \ 'usage[Display a usage message]' \ 'version[Display version information]' \ 'add[Add script to existing runlevel(s)]' \ 'delete[Delete script from existing runlevel(s)]' \ 'list[List all available init scripts]' \ 'pause[Pauses given set of init scripts manually]' \ 'restart[Restart given set of init scripts]' \ 'show[Show init script status for current runlevel]' \ 'start[Start given set of init scripts manually]' \ 'stop[Stop given set of init scripts manually]' elif (( CURRENT == 2 )); then case "$words[1]" in add|pause|restart|start|stop) _tags init_scripts && { compadd "$@" -k init_scripts || compadd "$@" ${(kv)=init_scripts} } ;; list) _tags gentoo_runlevels && { compadd "$@" -k gentoo_runlevels || compadd "$@" ${(kv)=gentoo_runlevels} } ;; delete) _tags used_scripts && { compadd "$@" -k used_scripts || compadd "$@" ${(kv)=used_scripts} } ;; esac elif (( CURRENT == 3 )); then case "$words[1]" in add|delete) _tags gentoo_runlevels && { compadd "$@" -k gentoo_runlevels || compadd "$@" ${(kv)=gentoo_runlevels} } ;; esac fi } _eselect () { if (( CURRENT == 2 ));then _values "eselect module" \ 'help[Display a help message]' \ 'list-modules[Find and display available modules]' \ 'usage[Display a usage message]' \ 'version[Display version information]' \ 'bashcomp[Manage contributed bash-completion scripts]' \ 'binutils[Manage installed versions of sys-devel/binutils]' \ 'blas[Manage installed BLAS implementations]' \ 'compiler[Manage the installed compilers.]' \ 'env[Manage environment variables set in /etc/env.d/]' \ 'kernel[Manage the /usr/src/linux symlink]' \ 'lapack[Manage installed LAPACK implementations]' \ 'mailer[Manage the mailwrapper profiles in /etc/mail]' \ 'opengl[Manage the OpenGL implementation used by your system]' \ 'profile[Manage the /etc/make.profile symlink]' \ 'rc[Manage /etc/init.d scripts in runlevels]' elif (( CURRENT > 2 ));then module=$words[2] # echo "$module" (( CURRENT-- )) shift words (( CURRENT-- )) shift words if [[ "${module}" == 'usage' ]]; then elif [[ "${module}" == 'compiler' ]]; then _eselect_compiler elif [[ "${module}" == 'binutils' ]]; then _eselect_binutils elif [[ "${module}" == 'bashcomp' ]]; then _eselect_bashcomp elif [[ "${module}" == 'env' ]]; then _eselect_env elif [[ "${module}" == 'kernel' ]]; then _eselect_kernel elif [[ "${module}" == 'lapack' ]]; then _eselect_lapack elif [[ "${module}" == 'mailer' ]]; then _eselect_mailer elif [[ "${module}" == 'opengl' ]]; then _eselect_opengl elif [[ "${module}" == 'profile' ]]; then _eselect_profile elif [[ "${module}" == 'rc' ]]; then _eselect_rc fi fi } case "$service" in ebuild) _ebuild "$@" && return 0 ;; esac