mirror of
https://github.com/wting/autojump
synced 2024-10-27 20:34:07 +00:00
Autocomplete for jc and jco
This commit is contained in:
parent
72313dbc51
commit
69bfdf4cfe
@ -202,9 +202,9 @@ def handle_tab_completion(needle, entries):
|
|||||||
print_local(tab_path)
|
print_local(tab_path)
|
||||||
elif tab_index:
|
elif tab_index:
|
||||||
get_ith_path = lambda i, iterable: last(take(i, iterable)).path
|
get_ith_path = lambda i, iterable: last(take(i, iterable)).path
|
||||||
print_local(get_ith_path(
|
matches_from_index = find_matches(entries, [tab_needle], check_entries=False)
|
||||||
tab_index,
|
matching_path = get_ith_path(tab_index, matches_from_index)
|
||||||
find_matches(entries, [tab_needle], check_entries=False)))
|
print_local(matching_path)
|
||||||
elif tab_needle:
|
elif tab_needle:
|
||||||
# found partial tab completion entry
|
# found partial tab completion entry
|
||||||
print_tab_menu(
|
print_tab_menu(
|
||||||
|
@ -29,8 +29,32 @@ _autojump() {
|
|||||||
$comps
|
$comps
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
complete -F _autojump j
|
complete -F _autojump j jo
|
||||||
|
|
||||||
|
_complete_autojump_c() {
|
||||||
|
local current_word
|
||||||
|
SAVE_IFS=$IFS
|
||||||
|
IFS=$'\n'
|
||||||
|
COMPREPLY=()
|
||||||
|
current_word="${COMP_WORDS[COMP_CWORD]}"
|
||||||
|
# tabbing on empty "prefix", e.g. jc <tab>
|
||||||
|
if [ -z "$current_word" ]; then
|
||||||
|
autocomplete_pattern="$PWD"
|
||||||
|
# tabbing when last item is a number jc /some/path.*first.*second__2<tab> #FIXME?
|
||||||
|
elif [[ "$current_word" =~ ^[0-9]+$ ]]; then
|
||||||
|
autocomplete_pattern="${PWD}__$current_word"
|
||||||
|
# tabbing when last item contains .*, e.g. jc /some/path.*first.*second<tab>
|
||||||
|
elif [[ "$current_word" =~ .*\.\*.* ]]; then
|
||||||
|
autocomplete_pattern="$current_word"
|
||||||
|
# tabbing when there are tokens, e.g. jc first second<tab>
|
||||||
|
else
|
||||||
|
autocomplete_pattern="${PWD}.*${current_word}"
|
||||||
|
fi
|
||||||
|
comps=$(autojump --complete "$autocomplete_pattern")
|
||||||
|
COMPREPLY=($(compgen -W "$comps" --))
|
||||||
|
IFS=$SAVE_IFS
|
||||||
|
}
|
||||||
|
complete -F _complete_autojump_c jc jco
|
||||||
|
|
||||||
# change pwd hook
|
# change pwd hook
|
||||||
autojump_add_to_database() {
|
autojump_add_to_database() {
|
||||||
|
Loading…
Reference in New Issue
Block a user