summaryrefslogtreecommitdiff
path: root/.zsh/zshfunctions
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2011-03-13 16:39:06 +0100
committerRené 'Necoro' Neumann <necoro@necoro.net>2011-03-13 16:39:07 +0100
commitb4f9d6e0b325c71c62b19825b42758e8110ee871 (patch)
tree7d50915ac598b9a2122ede3a73ffa1503d4b4a14 /.zsh/zshfunctions
parenta7e5edd0a7297bb415b0d834491af2602cdb9d0e (diff)
downloaddotfiles-b4f9d6e0b325c71c62b19825b42758e8110ee871.tar.gz
dotfiles-b4f9d6e0b325c71c62b19825b42758e8110ee871.tar.bz2
dotfiles-b4f9d6e0b325c71c62b19825b42758e8110ee871.zip
Enhanced the open_ebuild function
Diffstat (limited to '.zsh/zshfunctions')
-rw-r--r--.zsh/zshfunctions35
1 files changed, 29 insertions, 6 deletions
diff --git a/.zsh/zshfunctions b/.zsh/zshfunctions
index 70ce3b5..92f88f2 100644
--- a/.zsh/zshfunctions
+++ b/.zsh/zshfunctions
@@ -14,14 +14,37 @@ _cdu ()
# Open the ebuild with a specified command
open_ebuild ()
{
- local ebuild=$(equery --debug w $2 2> /dev/null)
-
- if [[ -z $ebuild ]]; then
- echo "Trying masked packages too..."
- ebuild=$(equery --debug w -m $2 2> /dev/null)
+ local ebuild sel
+ local -a elist
+
+ ebuild="$(equery w $2 2>&1 )"
+ if [[ $? -ne 0 ]]; then
+ if [[ $ebuild == *"Ambiguous"* ]]; then
+ elist=(${(f)ebuild})
+
+ # remove the first line
+ shift elist
+
+ echo "Ambiguous package name '$2' -- choose from: "
+ cat -n <<< ${(F)elist}
+ read "sel?Selection: "
+
+ if [[ -z $elist[$sel] ]]; then
+ echo "Invalid choice."
+ return 1
+ else
+ # the "=" is needed to strip the leading spaces and the quotes
+ open_ebuild $1 ${=elist[$sel]}
+ return $?
+ fi
+
+ elif [[ $ebuild == *"No packages matching"* ]]; then
+ echo "Trying masked packages too..."
+ ebuild=$(equery w -m $2 2>&1)
+ fi
fi
- if [[ -n $ebuild ]]; then
+ if [[ $? -eq 0 ]]; then
$1 $ebuild
else
echo "No ebuild found"