-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclipboard_modify.sh
executable file
·20 lines (20 loc) · 1.14 KB
/
clipboard_modify.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/bash
source /home/fabian/d/programs/bash_scripts/sane
while clipnotify; do
text="$(xsel -bo)"
# remove trash from YouTube links
if [[ "$text" == *"youtube.com/watch?v="* || "$text" == *"youtu.be/"* ]]; then
echo -En "$text" | sed "s/\\&list\\=[a-zA-Z0-9\\_\\-]+\\&index\\=[0-9]+(\\&t\\=[0-9]+)?//g;s/\\&pp\\=[A-Za-z0-9\\_\\-]+//g;s/\\?si\\=[A-Za-z0-9\\_\\-]+$|\\&si\\=[A-Za-z0-9\\_\\-]+|si\\=[A-Za-z0-9\\_\\-]+\\&//g;s/(\\=|\\%3D)*$//g;s/\\&feature\\=[a-z\\_]+//g" | xsel -bi
echo "edited YT link"
# remove trash from Twitch links
elif [[ "$text" == "https://www.twitch.tv/"* ]]; then
echo -En "$text" | sed "s/\\?filter\\=[a-z]+(\\&range\\=[a-z0-9]+)?\\&sort\\=[a-z]+//g" | xsel -bi
echo "edited Twitch link"
elif [[ "$text" == "https://www.google.com/imgres?q="* ]]; then
echo -n "$(echo "$text" | sed "s/https\\:\\/\\/www\\.google\\.com\\/imgres\\?q\\=[^\\&]+\\&imgurl\\=//;s/\\&imgrefurl\\=.+//;s/\\+/ /g;s/\\%/\\\x/g")" | xsel -bi
echo "edited Google image link"
# elif xsel -bo | file - | grep "ASCII text" >/dev/null; then
# # ensure that clipboard doesn't get cleared when closing a program
# echo -En "$text" | xsel -bi
fi
done