Created
February 27, 2012 10:09
-
-
Save dekokun/1922934 to your computer and use it in GitHub Desktop.
for Mac, Copy File to clipboard or Copy standard input to clipboard .
This file contains hidden or 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 | |
COMMAND=`basename $0` | |
usage(){ | |
echo "Usage: $COMMAND FILE" | |
echo "With no FILE, read standard input." | |
} | |
error(){ | |
local ERROR_MESSAGE=$@ | |
echo "$COMMAND: $ERROR_MESSAGE" | |
echo | |
usage | |
exit 1 | |
} | |
while getopts h flag | |
do | |
case $flag in | |
h) usage;exit 1;; | |
esac | |
done | |
if [ ! -z $1 ]; then | |
if [ -d $1 ];then | |
error "$1: It is Directory" | |
elif [ -e $1 ]; then | |
cat $1 | pbcopy | |
else | |
error "$1: No such file" | |
fi | |
elif [ -p /dev/stdin ]; then | |
pbcopy | |
else | |
error "No file and standard input" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment