Last active
July 14, 2021 09:31
-
-
Save hmble/ce73e4c94e251d7620f5526928345340 to your computer and use it in GitHub Desktop.
Track clipboard and save the clipboard content to a file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Change file location to your preferred path | |
filelocation="$HOME/Notes/bookamarks.txt" | |
# Thanks to https://stackoverflow.com/a/3184819 | |
regex='^(https?|ftp|file)://[-A-Za-z0-9\+&@#/%?=~_|!:,.;]*[-A-Za-z0-9\+&@#/%=~_|]$' | |
while clipnotify; do | |
text=$(xclip -o) | |
if [[ $(xclip -o) ]];then | |
if [[ $text =~ $regex ]];then | |
xclip -o >> $filelocation | |
echo "" >> $filelocation | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
My main gola for this is to only save the copied urls to a file so that I can later bulk import the bookmarks.
Prerequisite:
clipnotify
TODO: