Fix cheat.sh non-default query ability

This commit is contained in:
ItsDrike 2021-12-24 04:46:48 +01:00
parent d04842084a
commit 1c73a80dfc
No known key found for this signature in database
GPG key ID: FB8CA11A2CF3A843

View file

@ -15,13 +15,18 @@ else
fi fi
# If the cheatsheet doesn't already include a query, select a query # If the cheatsheet doesn't already include a query, select a query
if echo "$selected" | grep -q "/"; then if echo "$selected" | grep -qe "[/:]"; then
query="" query=""
elif [ -n "$2" ]; then elif [ -n "$2" ]; then
query="$2" query="$2"
else else
options=$(curl -s "cheat.sh/$selected/:list") options=$(curl -s "cheat.sh/$selected/:list")
query=$(printf "\n$options" | fzf --bind=enter:print-query --prompt="cheat.sh query (can be empty): ") query="$(printf "\n$options" | \
fzf --bind=alt-enter:print-query \
--prompt="cheat.sh query>" \
--header="use alt-enter to enter non-listed query"\
)"
query=$(echo "$query" | tail -1)
fi fi
query="$(echo "$query" | tr ' ' '+')" query="$(echo "$query" | tr ' ' '+')"