Hi,

Here in the patch, are two scripts for bash autocompletion, just like Nicolas's zsh scripts. There're instructions in the README file, but I wonder if those scripts could be installed automatically in the future, just like many other packages do?

Regards,
Ryan Li
>From c64238853d5d7b929b63b1fd72f58d62a5b369fa Mon Sep 17 00:00:00 2001
From: Ryan Li <r...@ryanium.com>
Date: Tue, 15 Sep 2009 19:45:02 +0800
Subject: [PATCH] Bash autocompletion for barry tools

---
 bash/README      |   14 ++++++++++
 bash/bjavaloader |   73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 bash/btool       |   41 ++++++++++++++++++++++++++++++
 3 files changed, 128 insertions(+), 0 deletions(-)
 create mode 100644 bash/README
 create mode 100755 bash/bjavaloader
 create mode 100755 bash/btool

diff --git a/bash/README b/bash/README
new file mode 100644
index 0000000..a74a84d
--- /dev/null
+++ b/bash/README
@@ -0,0 +1,14 @@
+Barry bash autocompletion
+========================
+
+The scripts in this directory are programmable
+completion functions for barry utils used in bash.
+To use them, simply copy the files in this directory
+except this README file to:
+	/etc/bash_completion.d/
+
+And to load manually, run the following command:
+	$ . /etc/bash_completion
+
+Programmable completion is for bash 3+ but is backwards
+compatiable with bash 2.05b.
diff --git a/bash/bjavaloader b/bash/bjavaloader
new file mode 100755
index 0000000..531eaaf
--- /dev/null
+++ b/bash/bjavaloader
@@ -0,0 +1,73 @@
+# -*- mode: shell-script; sh-basic-offset: 8; indent-tabs-mode: t -*-
+# ex: ts=8 sw=8 noet filetype=sh
+#
+# bjavaloader(1) completion by Ryan Li <r...@ryanium.com>
+
+have bjavaloader &&
+_bjavaloader()
+{
+	local cur prev
+	local cmd
+	declare -i cmd
+
+	COMREPLY=()
+	cur=`_get_cword`
+	prev=${COMP_WORDS[COMP_CWORD-1]}
+
+	cmd=0
+
+	for (( i = 0; i < COMP_CWORD; ++i )); do
+		case ${COMP_WORDS[$i]} in
+		@(dir|deviceinfo|load|wipe|save|erase| \
+			eventlog|cleareventlog|logstacktraces|screenshot|settime))
+			cmd=1
+			;;
+		esac
+	done
+
+	if [[ "$cur" == -* ]]; then
+		if [[ $cmd -eq 0 ]]; then
+			COMPREPLY=( $( compgen -W '-h -p -P -v' -- "$cur" ) )
+		else
+		case "$prev" in
+		dir)
+			COMPREPLY=( $( compgen -W '-s' -- "$cur" ) )
+			return 0
+			;;
+		wipe)
+			COMPREPLY=( $( compgen -W '-a -i' -- "$cur" ) )
+			return 0
+			;;
+		erase)
+			COMPREPLY=( $( compgen -W '-f' -- "$cur" ) )
+			return 0
+			;;
+		*)
+			;;
+		esac
+		fi
+	elif [[ $cmd -eq 0 ]]; then
+		COMPREPLY=( $( compgen -W 'dir deviceinfo \
+			load wipe save erase eventlog cleareventlog \
+			logstacktraces screenshot settime' -- "$cur" ) )
+	fi
+	case "$prev" in
+	-p)
+		COMPREPLY=( $( compgen -W \
+			'$( btool -l 2>&- | tail --lines=+2 | sed -e "s/.*PIN: \(.*\),.*/\1/g" )' \
+			-- "$cur" ) )
+		return 0
+		;;
+	load)
+		_filedir cod
+		return 0
+		;;
+	screenshot)
+		_filedir bmp
+		return 0
+		;;
+	*)
+		;;
+	esac
+} &&
+complete -F _bjavaloader bjavaloader
diff --git a/bash/btool b/bash/btool
new file mode 100755
index 0000000..7072ca3
--- /dev/null
+++ b/bash/btool
@@ -0,0 +1,41 @@
+# -*- mode: shell-script; sh-basic-offset: 8; indent-tabs-mode: t -*-
+# ex: ts=8 sw=8 noet filetype=sh
+#
+# btool(1) completion by Ryan Li <r...@ryanium.com>
+
+have btool &&
+_btool()
+{
+	local cur prev
+
+	COMPREPLY=()
+	cur=`_get_cword`
+
+	if [[ COMP_CWORD -eq 1 || "$cur" == -* ]]; then
+		COMPREPLY=( $( compgen -W '-B -N -a -c -C -d -e -h -i -l -L 
+			-m -M -n -p -P -s -S -t -T -v -X -z -Z' -- "$cur" ) )
+	else
+		prev=${COMP_WORDS[COMP_CWORD-1]}
+
+		case "$prev" in
+		-f)
+			_filedir
+			return 0
+			;;
+		-i)
+			COMPREPLY=( $( compgen -W \
+				'$( iconv --list | sed -e "s@//@@;" )' -- "$cur" ) )
+			return 0
+			;;
+		-p)
+			COMPREPLY=( $( compgen -W \
+				'$( btool -l | tail --lines=+2 | sed -e "s/.*PIN: \(.*\),.*/\1/g" )' \
+				-- "$cur" ) )
+			return 0
+			;;
+		*)
+			;;
+		esac
+	fi
+} &&
+complete -F _btool btool
-- 
1.6.3.3

------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
Barry-devel mailing list
Barry-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/barry-devel

Reply via email to