Skip to content

Instantly share code, notes, and snippets.

@thingsiplay
Created January 5, 2022 08:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thingsiplay/5c6c034e302660aa205fddc02136c2a8 to your computer and use it in GitHub Desktop.
Save thingsiplay/5c6c034e302660aa205fddc02136c2a8 to your computer and use it in GitHub Desktop.
Clipboard editing scripts
#!/bin/sh
echo '' | xclip -selection clipboard -rmlastnl -in
xsel --clipboard --clear
#!/bin/sh
tmpfile=`mktemp -t clipedit.XXXXXX`
xclip -selection clipboard -out > "$tmpfile"
${VISUAL:-${EDITOR:-$( which vi)}} "$tmpfile"
xsel --clipboard < "$tmpfile"
rm -f "$tmpfile"
#!/bin/sh
# clipsed SEARCH REPLACE [DELIMITER]
if [ "$#" -ge 3 ]
then
e="s$3$1$3$2$3g"
else
e="s^$1^$2^g"
fi
xclip -selection clipboard -out | \
sed "$e" | \
xsel --clipboard --input
#!/bin/sh
s=`zenity --entry --text "search text"`
if [ ! -z "$s" ]
then
r=`zenity --entry --text "replace text"`
e="s^$s^$r^g"
xclip -selection clipboard -out | \
sed "$e" | \
xsel --clipboard --input
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment