diff --git a/.config/shell/browse b/.config/shell/browse index 932f7d9..1551949 100644 --- a/.config/shell/browse +++ b/.config/shell/browse @@ -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() {