From 134a57b601e53d13c4500024ece0aedf5dbfd8f5 Mon Sep 17 00:00:00 2001 From: Sergey V Date: Sat, 24 Sep 2016 23:34:18 +0300 Subject: [PATCH] bash-completion: complete -{i,b} when git (not rsync) used for repo When git is used for repo, no file SLACKBUILDS.TXT exists. In this case complete -{i,b} by find package directories in $REPO_ROOT/$REPO_NAME/ directory. --- src/usr/doc/contrib/sbopkg.bash | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/usr/doc/contrib/sbopkg.bash b/src/usr/doc/contrib/sbopkg.bash index 4b6b64c..8ec81ca 100644 --- a/src/usr/doc/contrib/sbopkg.bash +++ b/src/usr/doc/contrib/sbopkg.bash @@ -65,10 +65,20 @@ _sbopkg() esac done - if [ ! -r "$REPO_ROOT/$REPO_NAME/$REPO_BRANCH/SLACKBUILDS.TXT" ]; then - return 0 + if [ -d "$QUEUEDIR" ]; then + local queues=($(cd $QUEUEDIR; compgen -f -X "!*.sqf" -- "$cur")) + fi + + if [ -r "$REPO_ROOT/$REPO_NAME/$REPO_BRANCH/SLACKBUILDS.TXT" ]; then + COMPREPLY=($(sed -ne "/^SLACKBUILD NAME: $cur/{s/^SLACKBUILD NAME: //;p}" \ + $REPO_ROOT/$REPO_NAME/$REPO_BRANCH/SLACKBUILDS.TXT) + ${queues[@]}) + elif [ -d "$REPO_ROOT/$REPO_NAME/" ]; then + COMPREPLY=($(find $REPO_ROOT/$REPO_NAME \ + \! -path $REPO_ROOT/$REPO_NAME/'.git/*' \ + -mindepth 2 -maxdepth 2 \ + -type d -name $cur\* \ + -printf '%f\n') + ${queues[@]}) fi - COMPREPLY=( $( sed -ne "/^SLACKBUILD NAME: $cur/{s/^SLACKBUILD NAME: //;p}"\ - $REPO_ROOT/$REPO_NAME/$REPO_BRANCH/SLACKBUILDS.TXT ) - $( cd $QUEUEDIR; compgen -f -X "!*.sqf" -- "$cur" ) ) } && complete -o filenames -F _sbopkg sbopkg