Skip to content

Instantly share code, notes, and snippets.

@crabdancing
Created December 25, 2022 08:55
Show Gist options
  • Save crabdancing/9f716dbe90f0258a490b7d1798e8f620 to your computer and use it in GitHub Desktop.
Save crabdancing/9f716dbe90f0258a490b7d1798e8f620 to your computer and use it in GitHub Desktop.
#!/bin/bash
# This entire script was written by the circa 2022 public demo ChatGPT AI with the following prompt:
# "Write me a Bash script with 'safe mode' enabled, that dumps clipboard contents to a directory under $HOME/Clipboard in a .txt file named according to the current time in `%Y-%m-%d_%H:%M:%S` format"
# This is both useful and terrifying
# Regardless, I'm going to take credit for it and say it's Copyleft (C) Alexandria P., under the GNU GPLv3
# Enable safe mode
set -euo pipefail
# Get the current time in the desired format
time=$(date +%Y-%m-%d_%H:%M:%S)
# Create the directory to store the clipboard contents if it doesn't already exist
mkdir -p "$HOME/Clipboard"
# Dump the clipboard contents to a .txt file with the current time as the file name
xclip -selection clipboard -o > "$HOME/Clipboard/${time}.txt"
echo "Clipboard contents saved to $HOME/Clipboard/${time}.txt"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment