So I have the following script which will show me my bookmarks in dmenu then open the selected Item in firefox.
#!/bin/sh
declare -a bookmarks
bookmarks=(
https://www.reddit.com/
https://www.youtube.com/
https://github.com/
https://www.veganricha.com/
)
input="$2"
addnew() {
bookmarks+=("$input")
}
while getopts a: option; do
case "${option}" in
a) addnew && exit 0 ;;
esac
done
menu="dmenu -i -l 10 -p "Bookmarks""
items=$(printf '%s\n' "${bookmarks[@]}" | $menu )
[ -n "$items" ] && firefox $items || exit 0
when you run it with the -a flag, you can add an Item to the list (the last copied item in my case)
./bookmarks -a $(xclicp -o)
and it does indeed add the item. what I want is to write the changes to the script. so the newly added item using -a flag be written to the script.
I tried and searched a lot but couldn't figure it out, hope someone can help
Thank you in advance