Created
November 17, 2019 09:46
-
-
Save tylerlmz1/50aabca2bc7ef919a72e61d755cc2c3c to your computer and use it in GitHub Desktop.
paste current time into active window, works in linux
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
dateString=$(date +"%Y-%m-%d") | |
timeString=$(date +"%H:%M:%S") | |
content="-- [ $dateString ] [ $timeString ] --" | |
# Preserve the current value of the clipboard | |
clipboard=$(xsel -b -o) | |
# Put text in primary buffer for Shift+Insert pasting | |
echo -n "$content" | xsel -p -i | |
# Put text in clipboard selection for apps like Firefox that | |
# insist on using the clipboard for all pasting | |
echo -n "$content" | xsel -b -i | |
# Paste text into current active window | |
sleep 0.3 | |
xdotool key shift+Insert | |
# Restore the original value of the clipboard | |
sleep 0.5 | |
echo $clipboard | xsel -b -i |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment