-
-
Save ccsalvesen/5beeed76e6907cbaba52 to your computer and use it in GitHub Desktop.
copy files and directories to clipboard. paste in a terminal window.
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
#!/bin/bash | |
if [[ $# -lt 1 ]]; then | |
echo "${0} - copy selfextracting archive of files to clipboard." | |
echo "" | |
echo "Syntax: $0 <file(s)>" | |
exit 1 | |
fi | |
TEMPFILE=$(mktemp) | |
out=$(which xclip 2>/dev/null || echo '/bin/cat') | |
( | |
echo -n 'echo "' | |
tar -c -j --exclude-vcs -f - ${@} | base64 -w0 #$(tput cols) | |
echo '"| base64 -d - | tar xjvf -' | |
) | tee ${TEMPFILE} | ${out} && \ | |
echo "Copied self extracting archive of ${@} to clipboard. ($(du -h ${TEMPFILE}|cut -f1))" && \ | |
rm -f ${TEMPFILE} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment