Last active
October 11, 2016 06:13
-
-
Save trickart/a7dc1f909e9ee95c665d to your computer and use it in GitHub Desktop.
Completion of cyg-fast command for bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_cyg-fast() | |
{ | |
local cur prev mirrordir arch pkg localpkg | |
cur="${COMP_WORDS[COMP_CWORD]}" | |
prev="${COMP_WORDS[COMP_CWORD-1]}" | |
if [ -e /etc/setup/last-mirror ]; then | |
mirrordir="$(head -1 /etc/setup/last-mirror | sed 's/:/%3a/g;s/\//%2f/g')" | |
fi | |
arch="$(arch | sed -e 's/^i686$/x86/g')" | |
if [ $COMP_CWORD -eq 1 ]; then | |
COMPREPLY=( $( compgen -W "install resume-install remove update show find describe packageof pathof" -- $cur)) | |
elif [ $COMP_CWORD -ge 2 ]; then | |
if [ "${COMP_WORDS[1]}" = "install" ]; then | |
pkg="$(awk '/@/ { print $2 }' "/setup/$mirrordir/$arch/setup.ini" | tr '\n' ' ')" | |
COMPREPLY=( $( compgen -W "$pkg" -- $cur)) | |
elif [ "${COMP_WORDS[1]}" = "remove" ]; then | |
localpkg="$(awk '/[^ ]+ [^ ]+ 0/ {print $1}' /etc/setup/installed.db | tr '\n' ' ')" | |
COMPREPLY=( $( compgen -W "$localpkg" -- $cur)) | |
fi | |
fi | |
} | |
complete -F _cyg-fast cyg-fast |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment