mirror of
https://github.com/CoolnsX/repos_scripts.git
synced 2025-12-20 07:15:20 +05:30
27 lines
853 B
Bash
Executable File
27 lines
853 B
Bash
Executable File
#!/bin/sh
|
|
|
|
#script for bookmarking selected items and later using it..
|
|
|
|
data="$(xclip -o | tr '\n' '\`')"
|
|
|
|
file="$HOME/.cache/bookmarks"
|
|
|
|
if [ "$*" = "add" ];then
|
|
if [ "$data" = "Error: target STRING not available" ];then
|
|
notify-send "Please select anything to bookmark"
|
|
elif grep -q "${data}" "$file";then
|
|
notify-send "Already bookmarked"
|
|
else
|
|
printf "%s" "$data" >> "$file"
|
|
printf "\n" >> "$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" | dmenu -p "delete-bookmark :" | cut -f1)
|
|
[ -z "$del" ] || (sed -i "${del}d" "$file" && notify-send "Bookmarked deleted")
|
|
else
|
|
xdotool type "$(cat "$file" | sed '/^$/d' | dmenu -p "Put-bookmark :" | tr '\`' '\n')"
|
|
fi
|