config/shell/browse/d: speed up and robustify
This commit is contained in:
parent
3ba0316e7d
commit
7df7c08730
|
@ -81,8 +81,9 @@ zoxide-fzf() {
|
|||
}
|
||||
# Locate directories and add 0 zoxide score
|
||||
locate-zox() {
|
||||
locate --basename --ignore-case "$@" |
|
||||
while read -r file; do test -d "$file" && echo "$file"; done |
|
||||
locate --existing --basename --ignore-case "$@" |
|
||||
# TODO too slow
|
||||
# while read -r file; do test -d "$file" && echo "$file"; done |
|
||||
sed 's/^/ 0 /'
|
||||
}
|
||||
# Switch directory heuristically using zoxide and locate
|
||||
|
@ -94,12 +95,12 @@ d() {
|
|||
# If not select with fzf, using locate to find extra options
|
||||
target="$(if test -n "$query" &&
|
||||
expr "$(echo "$query" | sed 's| \+\([^ ]\+\).*|\1|;q')" \> 20 \& \
|
||||
$(echo "$query" | sed 'N;s|/.* \([0-9]\)|> 10 * \1|;q' | sed 's| */.*||') >/dev/null #2>&1
|
||||
$(echo "$query" | sed 'N;s|/.* \([0-9]\+\) */.*|> 10 * \1|;q') >/dev/null #2>&1
|
||||
then echo "$query" | head -1
|
||||
else test -n "$query" && echo "$query"; locate-zox "$@"
|
||||
fi | zoxide-fzf)"
|
||||
test $? -lt 2 && test -z "$target" && sudo updatedb && target="$(locate --basename "$@" | fzf-dir)"
|
||||
test -n "$target" && cd "$target"
|
||||
test -n "$target" && cde "$target"
|
||||
}
|
||||
# Switch directory interactively using zoxide and locate
|
||||
di() {
|
||||
|
|
Loading…
Reference in New Issue