From 3fa72536e972a271d5e5c3f1d97c3b3294b90a3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=ABl=20Schaerer?= Date: Tue, 27 Apr 2010 10:08:07 +0200 Subject: [PATCH] completion now works with multiple patterns!!! --- autojump | 11 ++++------- autojump.bash | 10 +++++----- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/autojump b/autojump index 2e82ffa..d7ed164 100755 --- a/autojump +++ b/autojump @@ -139,12 +139,9 @@ else: if not args: patterns=[""] else: patterns=args - #if pattern is a full path, jump there - if len(patterns) == 1 and\ - len(patterns[0])>0 and\ - patterns[0][0]=="/" and\ - os.path.exists(patterns[0]): - if not completion : print patterns[0] + #if the last pattern is a full path, jump there + if len(patterns[-1])>0 and patterns[-1][0]=="/" and os.path.exists(patterns[-1]): + if not completion : print patterns[-1] else: endmatch=re.search("__([0-9]+)",patterns[-1]) if endmatch: @@ -171,5 +168,5 @@ else: if userchoice!=-1: if len(results) > userchoice-1 : print quotes+results[userchoice-1]+quotes elif len(results) > 1 and completion: - print "\n".join(("%s__%d__%s" % (" ".join(patterns),n+1,r) for n,r in enumerate(results[:8]))) + print "\n".join(("%s__%d__%s" % (patterns[-1],n+1,r) for n,r in enumerate(results[:8]))) elif results: print quotes+results[0]+quotes diff --git a/autojump.bash b/autojump.bash index b164ca0..d343346 100644 --- a/autojump.bash +++ b/autojump.bash @@ -18,11 +18,11 @@ _autojump() { local cur - COMPREPLY=() - unset COMP_WORDS[0] #remove "j" from the array - cur=${COMP_WORDS[*]} - IFS=$'\n' read -d '' -a COMPREPLY < <(autojump --bash --completion "$cur") - return 0 + cur=${COMP_WORDS[*]:1} + while read i + do + COMPREPLY=("${COMPREPLY[@]}" "${i}") + done < <(autojump --bash --completion $cur) } complete -F _autojump j AUTOJUMP='{ (autojump -a "$(pwd -P)"&)>/dev/null 2>>${HOME}/.autojump_errors;} 2>/dev/null'