mirror of
https://github.com/wting/autojump
synced 2024-10-27 20:34:07 +00:00
add tab completion printout
This commit is contained in:
parent
751ec6a7f2
commit
71861c4402
22
bin/autojump
22
bin/autojump
@ -50,12 +50,14 @@ from utils import has_uppercase
|
||||
from utils import is_osx
|
||||
from utils import last
|
||||
from utils import print_entry
|
||||
from utils import print_tab_completion_menu
|
||||
from utils import second
|
||||
from utils import surround_quotes
|
||||
from utils import take
|
||||
|
||||
VERSION = 'release-v21.8.0'
|
||||
FUZZY_MATCH_THRESHOLD = 0.6
|
||||
TAB_COMPLETION_COUNT = 9
|
||||
|
||||
|
||||
def set_defaults():
|
||||
@ -102,12 +104,9 @@ def parse_arguments():
|
||||
'-d', '--decrease', metavar='WEIGHT', nargs='?', type=int,
|
||||
const=15, default=False,
|
||||
help='decrease current directory weight')
|
||||
# parser.add_argument(
|
||||
# '-b', '--bash', action="store_true", default=False,
|
||||
# help='enclose directory quotes to prevent errors')
|
||||
# parser.add_argument(
|
||||
# '--complete', action="store_true", default=False,
|
||||
# help='used for tab completion')
|
||||
parser.add_argument(
|
||||
'--complete', action="store_true", default=False,
|
||||
help='used for tab completion')
|
||||
parser.add_argument(
|
||||
'--purge', action="store_true", default=False,
|
||||
help='remove non-existent paths from database')
|
||||
@ -287,8 +286,6 @@ def match_fuzzy(needles, haystack, ignore_case=False):
|
||||
|
||||
|
||||
def match_quicksilver(needles, haystack, ignore_case=False):
|
||||
"""
|
||||
"""
|
||||
return []
|
||||
|
||||
|
||||
@ -320,9 +317,12 @@ def main():
|
||||
|
||||
if args.add:
|
||||
save(config, first(add_path(load(config), args.add)))
|
||||
# elif args.complete:
|
||||
# config['match_cnt'] = 9
|
||||
# config['ignore_case'] = True
|
||||
elif args.complete:
|
||||
print_tab_completion_menu(
|
||||
separator=config['tab_menu_separator'],
|
||||
entries=take(
|
||||
TAB_COMPLETION_COUNT,
|
||||
find_matches(entriefy(load(config)), args.directory)))
|
||||
elif args.decrease:
|
||||
data, entry = decrease_path(load(config), get_pwd(), args.decrease)
|
||||
save(config, data)
|
||||
|
10
bin/utils.py
10
bin/utils.py
@ -110,6 +110,16 @@ def print_entry(entry):
|
||||
print(encode_local("%.1f:\t%s" % (entry.weight, entry.path)))
|
||||
|
||||
|
||||
def print_tab_completion_menu(separator, entries):
|
||||
for i, entry in enumerate(entries):
|
||||
print(encode_local(surround_quotes(
|
||||
'%s%d%s%s' % (
|
||||
separator,
|
||||
i,
|
||||
separator,
|
||||
entry.path))))
|
||||
|
||||
|
||||
def second(xs):
|
||||
it = iter(xs)
|
||||
try:
|
||||
|
Loading…
Reference in New Issue
Block a user