Files
repos_scripts/bkmark

29 lines
963 B
Bash
Executable File

#!/bin/sh
#script for bookmarking selected items and later using it..
data="$(wl-paste -p | tr '\n' '\`')"
file="$HOME/.cache/bookmarks"
if [ "$*" = "add" ];then
if [ -z "$data" ];then
notify-send "Please select anything to bookmark"
elif grep -q "${data}" "$file";then
notify-send "Already bookmarked"
else
printf "%s" "$data" >> "$file"
notify-send "Bookmarked" "$data"
fi
elif [ "$*" = "rm" ];then
data="$(cat "$file" | sed '/^$/d' | nl -n'ln')"
[ -z "$data" ] && notify-send "Bookmark is empty" && exit 0
del=$(printf "%s" "$data" | bemenu --fn 'Roboto 15' -i -c -W 0.6 -B 3 -l 30 -p "delete-bookmark :" | cut -f1)
[ -z "$del" ] || (sed -i "${del}d" "$file" && notify-send "Bookmarked deleted")
else
wtype -d 10 "$(cat "$file" | sed '/^$/d' | bemenu --fn 'Roboto 15' -i -c -W 0.6 -B 3 -l 30 -p "Put-bookmark :" | tr '\`' '\n')"
fi
sed -i '/^$/d' "$file"
printf "\n" >> "$file"