mirror of
https://github.com/wting/autojump
synced 2024-10-27 20:34:07 +00:00
finish partial tab match
This commit is contained in:
parent
30b9708654
commit
2a53341feb
12
bin/autojump
12
bin/autojump
@ -45,6 +45,7 @@ from data import save
|
||||
from utils import decode
|
||||
from utils import encode_local
|
||||
from utils import first
|
||||
from utils import get_needle
|
||||
from utils import get_needle_and_index
|
||||
from utils import get_pwd
|
||||
from utils import has_uppercase
|
||||
@ -347,7 +348,7 @@ def main():
|
||||
needle = first(needles)
|
||||
|
||||
if is_tab_entry(needle, TAB_SEPARATOR):
|
||||
# the needle is actually a tab entry here
|
||||
# the needle is a tab_entry
|
||||
needle, tab_index = get_needle_and_index(needle, TAB_SEPARATOR)
|
||||
tab_entries = take(
|
||||
TAB_ENTRIES_COUNT,
|
||||
@ -357,11 +358,16 @@ def main():
|
||||
print(encode_local(surround_quotes(
|
||||
get_ith_path(tab_index, tab_entries))))
|
||||
elif is_tab_partial_match(needle, TAB_SEPARATOR):
|
||||
print("tab_partial_match")
|
||||
# the needle is a partial tab_entry
|
||||
needle = get_needle(needle, TAB_SEPARATOR)
|
||||
tab_entries = take(
|
||||
TAB_ENTRIES_COUNT,
|
||||
find_matches(entriefy(load(config)), needle))
|
||||
print_tab_menu(needle, tab_entries, TAB_SEPARATOR)
|
||||
else:
|
||||
try:
|
||||
print(encode_local(surround_quotes(
|
||||
first(find_matches(entries, needles)).path)))
|
||||
first(find_matches(entries, needles)).path)))
|
||||
except AttributeError:
|
||||
# always return something so the calling shell function has an
|
||||
# argument to `cd` to
|
||||
|
10
bin/utils.py
10
bin/utils.py
@ -52,6 +52,15 @@ def first(xs):
|
||||
return None
|
||||
|
||||
|
||||
def get_needle(tab_entry, separator):
|
||||
"""
|
||||
Given a partial tab entry in the following format return the needle:
|
||||
|
||||
[needle]__
|
||||
"""
|
||||
return re.match(r'(.*)'+separator, tab_entry).group(1)
|
||||
|
||||
|
||||
def get_needle_and_index(tab_entry, separator):
|
||||
"""
|
||||
Given a tab entry in the following format return the needle and index:
|
||||
@ -66,7 +75,6 @@ def get_needle_and_index(tab_entry, separator):
|
||||
return matches.group(1), int(matches.group(2))
|
||||
|
||||
|
||||
|
||||
def get_pwd():
|
||||
try:
|
||||
return os.getcwdu()
|
||||
|
Loading…
Reference in New Issue
Block a user