mirror of
https://github.com/wting/autojump
synced 2024-10-27 20:34:07 +00:00
ok this is already a little better
This commit is contained in:
parent
4b64944832
commit
1f2292708a
9
autojump
9
autojump
@ -62,6 +62,7 @@ elif ('--import','') in optlist:
|
|||||||
dicadd(path_dict,i[:-1])
|
dicadd(path_dict,i[:-1])
|
||||||
cPickle.dump(path_dict,open(dic_file,'w'),-1)
|
cPickle.dump(path_dict,open(dic_file,'w'),-1)
|
||||||
else:
|
else:
|
||||||
|
import re
|
||||||
completion=False
|
completion=False
|
||||||
if ('--completion','') in optlist:
|
if ('--completion','') in optlist:
|
||||||
completion=True
|
completion=True
|
||||||
@ -71,12 +72,12 @@ else:
|
|||||||
for k in path_dict.keys():
|
for k in path_dict.keys():
|
||||||
path_dict[k]*=0.9*max_keyweight/keyweight
|
path_dict[k]*=0.9*max_keyweight/keyweight
|
||||||
if not args: args=['']
|
if not args: args=['']
|
||||||
|
argument=re.sub("[0-9]*\__","",args[-1])
|
||||||
dirs=path_dict.items()
|
dirs=path_dict.items()
|
||||||
dirs.sort(key=lambda e:e[1],reverse=True)
|
dirs.sort(key=lambda e:e[1],reverse=True)
|
||||||
import re
|
|
||||||
found=False
|
found=False
|
||||||
for path,count in dirs:
|
for path,count in dirs:
|
||||||
if match(path,args[-1],path_dict): #First look for case-matching path
|
if match(path,argument,path_dict): #First look for case-matching path
|
||||||
if not completion:
|
if not completion:
|
||||||
print path
|
print path
|
||||||
found=True
|
found=True
|
||||||
@ -87,14 +88,14 @@ else:
|
|||||||
dirs.sort(key=lambda e:e[1],reverse=True)
|
dirs.sort(key=lambda e:e[1],reverse=True)
|
||||||
if not found:
|
if not found:
|
||||||
for path,count in dirs:
|
for path,count in dirs:
|
||||||
if match(path,args[-1],path_dict,re.IGNORECASE): #Then try to ignore case
|
if match(path,argument,path_dict,re.IGNORECASE): #Then try to ignore case
|
||||||
if not completion:
|
if not completion:
|
||||||
print path
|
print path
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
uniqadd(results,path)
|
uniqadd(results,path)
|
||||||
if completion:
|
if completion:
|
||||||
print " ".join(("%d)%s" % (n,r) for n,r in enumerate(results)))
|
print " ".join(("%d__%s" % (n,r) for n,r in enumerate(results)))
|
||||||
cPickle.dump(path_dict,open(dic_file+".tmp",'w'),-1)
|
cPickle.dump(path_dict,open(dic_file+".tmp",'w'),-1)
|
||||||
import shutil
|
import shutil
|
||||||
shutil.copy(dic_file+".tmp",dic_file) #cPickle.dump doesn't seem to be atomic, so this is more secure
|
shutil.copy(dic_file+".tmp",dic_file) #cPickle.dump doesn't seem to be atomic, so this is more secure
|
||||||
|
0
autojump.sh
Normal file → Executable file
0
autojump.sh
Normal file → Executable file
Loading…
Reference in New Issue
Block a user