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

fix completions for zsh

This commit is contained in:
Joel Schaerer 2010-07-07 23:51:42 +02:00
parent 9f7835c738
commit 8e1ab9ca54

View File

@ -139,15 +139,19 @@ else:
if not args: patterns=[""] if not args: patterns=[""]
else: patterns=args else: patterns=args
#if the last pattern is a full path, jump there #if the last pattern contains a full path, jump there
if len(patterns[-1])>0 and patterns[-1][0]=="/" and os.path.exists(patterns[-1]): #the regexp is because we need to support stuff like "j wo jo__3__/home/joel/workspace/joel" for zsh
if not completion : print patterns[-1] last_pattern_path = re.sub("(.*)__","",patterns[-1])
#print >> stderr, last_pattern_path
if len(last_pattern_path)>0 and last_pattern_path[0]=="/" and os.path.exists(last_pattern_path):
if not completion : print last_pattern_path
else: else:
endmatch=re.search("__([0-9]+)",patterns[-1]) #check for ongoing completion, and act accordingly
endmatch=re.search("__([0-9]+)",patterns[-1]) #user has selected a completion
if endmatch: if endmatch:
userchoice=int(endmatch.group(1)) userchoice=int(endmatch.group(1))
patterns[-1]=re.sub("__[0-9]+.*","",patterns[-1]) patterns[-1]=re.sub("__[0-9]+.*","",patterns[-1])
else: else: #user hasn't selected a completion, display the same choices again
endmatch=re.match("(.*)__",patterns[-1]) endmatch=re.match("(.*)__",patterns[-1])
if endmatch: patterns[-1]=endmatch.group(1) if endmatch: patterns[-1]=endmatch.group(1)