q.sh/q-browse
2024-09-09 02:03:52 +01:00

22 lines
481 B
Bash
Executable file

#!/bin/sh
ENV_xdg_open=xdg-open
ENV_cut=cut
if [[ -z "$@" ]]; then
echo "^f .*$"
elif [[ "$1" == "--hint" ]]; then
shift
elif [[ "$1" == "--complete" ]]; then
shift
echo "0 $@"
elif [[ "$1" == "--preview" ]]; then
shift
URL="$(echo "$@" | $ENV_cut -d ' ' -f3-)"
echo "Will open '$URL' in firefox"
elif [[ "$1" == "--run" ]]; then
shift
URL="$(echo "$@" | $ENV_cut -d ' ' -f3-)"
(nohup $ENV_xdg_open "$URL" 2>/dev/null &)
sleep 0.01
fi