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 decode
|
||||||
from utils import encode_local
|
from utils import encode_local
|
||||||
from utils import first
|
from utils import first
|
||||||
|
from utils import get_needle
|
||||||
from utils import get_needle_and_index
|
from utils import get_needle_and_index
|
||||||
from utils import get_pwd
|
from utils import get_pwd
|
||||||
from utils import has_uppercase
|
from utils import has_uppercase
|
||||||
@ -347,7 +348,7 @@ def main():
|
|||||||
needle = first(needles)
|
needle = first(needles)
|
||||||
|
|
||||||
if is_tab_entry(needle, TAB_SEPARATOR):
|
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)
|
needle, tab_index = get_needle_and_index(needle, TAB_SEPARATOR)
|
||||||
tab_entries = take(
|
tab_entries = take(
|
||||||
TAB_ENTRIES_COUNT,
|
TAB_ENTRIES_COUNT,
|
||||||
@ -357,11 +358,16 @@ def main():
|
|||||||
print(encode_local(surround_quotes(
|
print(encode_local(surround_quotes(
|
||||||
get_ith_path(tab_index, tab_entries))))
|
get_ith_path(tab_index, tab_entries))))
|
||||||
elif is_tab_partial_match(needle, TAB_SEPARATOR):
|
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:
|
else:
|
||||||
try:
|
try:
|
||||||
print(encode_local(surround_quotes(
|
print(encode_local(surround_quotes(
|
||||||
first(find_matches(entries, needles)).path)))
|
first(find_matches(entries, needles)).path)))
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
# always return something so the calling shell function has an
|
# always return something so the calling shell function has an
|
||||||
# argument to `cd` to
|
# argument to `cd` to
|
||||||
|
10
bin/utils.py
10
bin/utils.py
@ -52,6 +52,15 @@ def first(xs):
|
|||||||
return None
|
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):
|
def get_needle_and_index(tab_entry, separator):
|
||||||
"""
|
"""
|
||||||
Given a tab entry in the following format return the needle and index:
|
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))
|
return matches.group(1), int(matches.group(2))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_pwd():
|
def get_pwd():
|
||||||
try:
|
try:
|
||||||
return os.getcwdu()
|
return os.getcwdu()
|
||||||
|
Loading…
Reference in New Issue
Block a user