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:
parent
3936e28650
commit
3fa72536e9
11
autojump
11
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
|
||||
|
@ -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'
|
||||
|
Loading…
Reference in New Issue
Block a user