Last active
January 19, 2019 13:56
-
-
Save Hyvi/bb925d65ed018bf1fbce6a3ea19bbd26 to your computer and use it in GitHub Desktop.
用于截图部分代码,粘贴到keynote ///
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 | |
# 先安装highlight, "brew install highlight" | |
# Parse arguments | |
usage() { | |
echo "Usage: $0 [-h] [-v] [-f FILE] [-k fontsize] [-s startline] [-e endline]" | |
echo " -h Help. Display this message and quit." | |
echo " -v Version. Print version number and quit." | |
echo " -k Specify font-size." | |
echo " -f Specify file FILE." | |
echo " -s Specify the line number of the file that start from ." | |
echo " -e Specify the line number of the file that end to output ." | |
exit | |
} | |
optspec="hvf:s:k:e:" | |
fontsize=24 | |
while getopts "$optspec" optchar | |
do | |
case "${optchar}" in | |
h) usage ;; | |
v) version ;; | |
f) file=${OPTARG} ;; | |
k) fontsize=${OPTARG} ;; | |
s) startline=${OPTARG} ;; | |
e) endline=${OPTARG} ;; | |
*) usage ;; | |
esac | |
done | |
[ -z "$file" ] && usage | |
# [ -n "$fontsize" ] && fontsize=$fontsize | |
[ -z "$startline" ] && startline=0 | |
# [ -z "$endline" ] && endline=$lastline | |
if [ -n "$endline" ]; then | |
cat $file | head -n ${endline} | tail -n +${startline} | highlight -l -O rtf -K ${fontsize} -m ${startline} -S go - | pbcopy | |
else | |
cat $file | tail -n +${startline} | highlight -l -O rtf -K ${fontsize} -m ${startline} -S go - | pbcopy | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment