1
0
mirror of https://github.com/wting/autojump synced 2024-10-27 20:34:07 +00:00

completion now works with multiple patterns!!!

This commit is contained in:
Joël Schaerer 2010-04-27 10:08:07 +02:00
parent 3936e28650
commit 3fa72536e9
2 changed files with 9 additions and 12 deletions

View File

@ -139,12 +139,9 @@ else:
if not args: patterns=[""] if not args: patterns=[""]
else: patterns=args else: patterns=args
#if pattern is a full path, jump there #if the last pattern is a full path, jump there
if len(patterns) == 1 and\ if len(patterns[-1])>0 and patterns[-1][0]=="/" and os.path.exists(patterns[-1]):
len(patterns[0])>0 and\ if not completion : print patterns[-1]
patterns[0][0]=="/" and\
os.path.exists(patterns[0]):
if not completion : print patterns[0]
else: else:
endmatch=re.search("__([0-9]+)",patterns[-1]) endmatch=re.search("__([0-9]+)",patterns[-1])
if endmatch: if endmatch:
@ -171,5 +168,5 @@ else:
if userchoice!=-1: if userchoice!=-1:
if len(results) > userchoice-1 : print quotes+results[userchoice-1]+quotes if len(results) > userchoice-1 : print quotes+results[userchoice-1]+quotes
elif len(results) > 1 and completion: 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 elif results: print quotes+results[0]+quotes

View File

@ -18,11 +18,11 @@
_autojump() _autojump()
{ {
local cur local cur
COMPREPLY=() cur=${COMP_WORDS[*]:1}
unset COMP_WORDS[0] #remove "j" from the array while read i
cur=${COMP_WORDS[*]} do
IFS=$'\n' read -d '' -a COMPREPLY < <(autojump --bash --completion "$cur") COMPREPLY=("${COMPREPLY[@]}" "${i}")
return 0 done < <(autojump --bash --completion $cur)
} }
complete -F _autojump j complete -F _autojump j
AUTOJUMP='{ (autojump -a "$(pwd -P)"&)>/dev/null 2>>${HOME}/.autojump_errors;} 2>/dev/null' AUTOJUMP='{ (autojump -a "$(pwd -P)"&)>/dev/null 2>>${HOME}/.autojump_errors;} 2>/dev/null'