q.sh/q-bookmarks

24 lines
576 B
Text
Raw Permalink Normal View History

#!/bin/sh
2021-10-10 20:26:06 +00:00
if [[ -z "$@" ]]; then
2024-11-03 23:36:22 +00:00
echo "^b .*$"
2021-10-10 20:26:06 +00:00
elif [[ "$1" == "--hint" ]]; then
2024-11-03 23:36:22 +00:00
shift
if [[ -f ~/.bookmarks.txt ]]; then
cat ~/.bookmarks.txt | awk '{printf("%s b", $1); for (i=2; i<=NF; i++) printf(" %s", $i); print("");}'
2024-11-03 23:36:22 +00:00
fi
2021-10-10 20:26:06 +00:00
elif [[ "$1" == "--complete" ]]; then
2024-11-03 23:36:22 +00:00
shift
if [[ -f ~/.bookmarks.txt ]]; then
cat ~/.bookmarks.txt | awk '{printf("%s b", $1); for (i=2; i<=NF; i++) printf(" %s", $i); print("");}'
2024-11-03 23:36:22 +00:00
fi
2021-10-10 20:26:06 +00:00
elif [[ "$1" == "--preview" ]]; then
2024-11-03 23:36:22 +00:00
shift
echo "$1"
2021-10-10 20:26:06 +00:00
elif [[ "$1" == "--run" ]]; then
2024-11-03 23:36:22 +00:00
shift
xdg-open "$2"
2021-10-10 20:26:06 +00:00
else
2024-11-03 23:36:22 +00:00
echo "Unexpected arguments: $@"
2021-10-10 20:26:06 +00:00
fi