pld-ftp-admin: shell/bash_completion.sh (NEW) - bash completion for main ft...
glen
glen at pld-linux.org
Wed Feb 2 10:26:05 CET 2011
Author: glen Date: Wed Feb 2 09:26:05 2011 GMT
Module: pld-ftp-admin Tag: HEAD
---- Log message:
- bash completion for main ftp admin tools
---- Files affected:
pld-ftp-admin/shell:
bash_completion.sh (NONE -> 1.1) (NEW)
---- Diffs:
================================================================
Index: pld-ftp-admin/shell/bash_completion.sh
diff -u /dev/null pld-ftp-admin/shell/bash_completion.sh:1.1
--- /dev/null Wed Feb 2 10:26:05 2011
+++ pld-ftp-admin/shell/bash_completion.sh Wed Feb 2 10:26:00 2011
@@ -0,0 +1,101 @@
+# various completions for pld-ftp-admin tools
+# Author: Elan Ruusamäe <glen at pld-linux.org>
+
+# return list of pld ftp trees
+_pld_ftp_tree() {
+ local cur="$1"
+ if [ -z "$PLD_FTP_TREES" ]; then
+ local d
+ local -a trees
+ for d in ~/ftp/*/; do
+ d=${d%/}
+ d=${d##*/}
+ PLD_FTP_TREES+=" $d"
+ done
+ # kill leading space
+ PLD_FTP_TREES=${PLD_FTP_TREES# }
+ fi
+
+ COMPREPLY=( $( compgen -W "$PLD_FTP_TREES" -- "$cur" ) )
+}
+
+# return list of files in a tree
+_pld_ftp_tree_files() {
+ local tree="$1" cur="$2" file
+ local dir=~/ftp/$tree/SRPMS/.metadata
+
+ # generate reply from dir
+ COMPREPLY=( $( compgen -f -X "*.(src.rpm.info)" -- "$dir/$cur" ) )
+ # filter out dirname from results
+ for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
+ file=${COMPREPLY[$i]##*/}
+ COMPREPLY[$i]=$file
+ done
+}
+
+have gen-indexes &&
+_gen-indexes()
+{
+ local cur
+
+ COMPREPLY=()
+ _get_comp_words_by_ref cur
+
+ if [[ "$cur" == -* ]]; then
+ COMPREPLY=( $( compgen -W '\
+ -q --quiet --index \
+ --nopoldek --noyum --norpmrepo \
+ --poldek --yum --rpmrepo \
+ ' \
+ -- "$cur" ) )
+ else
+ _pld_ftp_tree "$cur"
+ fi
+} &&
+complete -F _gen-indexes gen-indexes
+
+have lintpkg &&
+_lintpkg()
+{
+ local cur
+
+ COMPREPLY=()
+ _get_comp_words_by_ref cur
+
+ # The first argument is an tree; the rest are files in a dir
+ _count_args :
+
+ if [[ $args == 1 ]]; then
+ _pld_ftp_tree "$cur"
+ else
+ _pld_ftp_tree_files "${COMP_WORDS[1]}" "$cur"
+ fi
+} &&
+complete -F _lintpkg lintpkg signpkg
+
+have mvpkg &&
+_mvpkg()
+{
+ local cur
+
+ COMPREPLY=()
+ _get_comp_words_by_ref cur
+
+ # The first two arguments are tree names; the rest are files in a dir
+ _count_args :
+
+ if [[ $args == 1 ]] || [[ $args == 2 ]]; then
+ _pld_ftp_tree "$cur"
+ else
+ _pld_ftp_tree_files "${COMP_WORDS[1]}" "$cur"
+ fi
+} &&
+complete -F _mvpkg mvpkg testmvpkg
+
+# Local variables:
+# mode: shell-script
+# sh-basic-offset: 4
+# sh-indent-comment: t
+# indent-tabs-mode: nil
+# End:
+# ex: ts=4 sw=4 et filetype=sh
================================================================
More information about the pld-cvs-commit
mailing list