From 3a733d76f1155a04461e31e7ff6270256f6a335a Mon Sep 17 00:00:00 2001 From: tdro Date: Sat, 20 Nov 2021 23:03:06 -0500 Subject: .local/bin/,: Bail when nothing found Allow no-group and regex. --- .local/bin/, | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.local/bin/, b/.local/bin/, index 58ed5ef..47b2673 100755 --- a/.local/bin/, +++ b/.local/bin/, @@ -33,11 +33,14 @@ nix-index --nixpkgs https://github.com/NixOS/nixpkgs/archive/master.tar.gz { [ "${1:-}" = "-h" ] || [ "${1:-}" = "--help" ] || [ "$#" = 0 ]; } && help && exit databasePath=${XDG_DATA_HOME:-~/.cache}/nix-index -nixLocate='nix-locate --db '"$databasePath"' -- '"${1:-}" +nixLocate='nix-locate --db '"$databasePath"' --no-group --regex -- '"${1:-}" attributes=$($nixLocate | awk '{ print $1, $4 }' | sed 's|/nix/store/.[^-]*-||g') + +[ -z "$attributes" ] && printf "No files found containing '%s'\n" "${1:-}" && exit + attribute=$(printf '%s' "$attributes" | column --table | fzf | awk '{ print $1 }') -[ -z "$attribute" ] && exit +[ -z "$attribute" ] && exit printf '\nsetting up shell with %s path...\n' "$attribute" -- cgit v1.2.3