- newblog.sh: Generate a new post blog with title, time, category, tag.
- hourlater.sh: Generate new post blog with title, time, category, tag. Can delay the published time.
- getlink4index.sh: Generate index.md containing directory and pdf links.
- gitsubmit.sh: Submit the revision by git.
- gitsubmit-general.sh: Submit the revision by git, use for many repositories.
- gitall.sh: Git pull/push several repositories.
- changeRSA.sh: Exchange the ssh-key for exchange user submitting git.
- init-changeUser.sh: Initial a repository by another user information. Need to setup the second github host(such as two.github.com)
- sphinx2jekyll.sh: Convert the off-line sphinx-generated website to jekyll mode.
Last active
December 19, 2015 20:01
-
-
Save platinhom/7dee08dd8df71dd29418 to your computer and use it in GitHub Desktop.
Some scripts for github page blog
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 | |
prefix="$1" | |
if [ -z $1 ];then | |
prefix="id_rsa2" | |
fi | |
mv ~/.ssh/$prefix ~/.ssh/${prefix}_tmp | |
mv ~/.ssh/${prefix}.pub ~/.ssh/${prefix}_tmp.pub | |
mv ~/.ssh/id_rsa ~/.ssh/$prefix | |
mv ~/.ssh/id_rsa.pub ~/.ssh/${prefix}.pub | |
mv ~/.ssh/${prefix}_tmp ~/.ssh/id_rsa | |
mv ~/.ssh/${prefix}_tmp.pub ~/.ssh/id_rsa.pub |
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 | |
# file: getlink.sh | |
# Author: Platinhom | |
# Last updated:2015.11.30 | |
# To list all the directory and pdf file in current directory into the index.md file. | |
# Notice the encoding problem. http://platinhom.github.io/2015/06/09/msys-utf8-problem/ | |
pd=`pwd` | |
echo "--- | |
title: PDF | |
layout: page | |
comments: yes | |
--- | |
## ${pd##*HomPDF/} | |
">index.md | |
echo "### Directory: ">>index.md | |
for dir in `ls` | |
do | |
if [ -d $dir ];then | |
echo "- [${dir}](./${dir})">>index.md | |
fi | |
done | |
echo "### PDF: ">>index.md | |
for pdffile in *.pdf | |
do | |
echo "- [${pdffile}](./$pdffile)">>index.md | |
done | |
## replace the gbk encoding file. | |
if [ ! -z "`file index.md|grep ISO-8859`" ];then | |
iconv -f GBK -t UTF-8 index.md > index-2.md | |
rm index.md | |
mv index-2.md index.md | |
fi |
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 --login | |
# Author: Hom 2015.10.13 | |
# Use for submit/pull for github | |
# Need set up: MYGIT_PATH, MYGIT_ALL | |
nowpwd=`pwd` | |
action=$1 | |
if [ -z $1 ];then | |
action='p' | |
fi | |
action=`echo $action | tr 'A-Z' 'a-z'` | |
if [[ ! ($action == "p" || $action == "s") ]];then | |
echo "Action don't know: should be s (submit) or p (pull)" | |
exit 1 | |
fi | |
if [ ! -z $MYGIT_PATH ];then | |
cd $MYGIT_PATH | |
if [ ! -z "$MYGIT_ALL" ];then | |
for dir in $MYGIT_ALL | |
do | |
cd $dir | |
if [ $action = "s" ];then | |
echo ${dir} submitting.. | |
./gitsubmit.sh | |
else | |
echo ${dir} pulling.... | |
git pull | |
fi | |
cd .. | |
done | |
else | |
echo "MYGIT_ALL should be set to project folder name as A B C D" | |
fi | |
cd $nowpwd | |
fi |
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 | |
# Easy tool to submit changes to Github | |
# Support $2 for comment. | |
project=`echo $1 |tr 'A-Z' 'a-z'` | |
nowpwd=`pwd` | |
ppath="$MYGIT_PATH" | |
if [ -z $ppath ];then | |
echo "No MyGit path! " | |
exit 1 | |
fi | |
branch="master" | |
case $project in | |
c*) | |
ppath="$GIT_CADDHOM_PATH" | |
branch="master" | |
;; | |
d*) | |
ppath="$GIT_DAILYTOOLS_PATH" | |
branch=gh-pages | |
;; | |
h*) | |
ppath="$GIT_HOMPDF_PATH" | |
branch=gh-pages | |
;; | |
m*) | |
ppath="$GIT_MOLSHOW_PATH" | |
branch=gh-pages | |
;; | |
*) | |
ppath="$GHPAGE_PATH" | |
branch="master" | |
;; | |
esac | |
comment=$2 | |
if [ -z $2 ];then | |
comment="regular" | |
fi | |
cd $ppath | |
git add -A | |
git commit -am "$comment" | |
# maybe you should revise this for your branch | |
git push origin $branch | |
cd $nowpwd |
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 | |
# file: gitsubmit.sh | |
comment=$1 | |
if [ -z $commend ];then | |
comment=regular | |
fi | |
cd .. | |
git add -A | |
git commit -am "$comment" | |
if [ ! -z $2 ];then | |
#git remote add gitcafe git@gitcafe.com:platinhom/platinhom.git | |
git push gitcafe master:gitcafe-pages | |
fi | |
# may be change to your branch here | |
git push origin master | |
cd - |
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 | |
# file: hourlater.sh | |
# Author: PlatinHom | |
# Last: 2015-06-21 | |
# It's use for generating new blog some hours later. | |
# Full Usage: "./hourlater.sh hour title category tag1 tag2" | |
# Simple Usage without category and tag: ".hourlater/.sh 0 title" | |
# You can register your sublime here. It's not nessary. | |
sublimecmd="/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" | |
hourchange=$1 | |
title=$2 | |
category=$3 | |
tag="${@:4}" | |
if [ -z $2 ];then | |
title="TempTitle-`date +%H%M%S`" | |
fi | |
if [ -z $3 ];then | |
category="Other" | |
fi | |
if [ -z $4 ];then | |
tag="Other" | |
fi | |
#GMT+8 after some hour | |
hour1=`expr 8 + $1` | |
# My blog use GMT+8:00 time zone-China | |
# For MacOS | |
if [ `uname -s` == "Darwin" ];then | |
today=`date -u -v "+${hour1}H" +"%Y-%m-%d"` | |
# In github's jekyll,you should enter GMT time (time zone UTC(+0:00)) | |
nowGMT=`date -u -v "+${1}H" +"%Y-%m-%d %H:%M:%S"` | |
# Other OS | |
else | |
today=`date -u -d "+${hour1} hour" +"%Y-%m-%d"` | |
nowGMT=`date -u -d "+${1} hour" +"%Y-%m-%d %H:%M:%S"` | |
fi | |
touch ./"${today}-${title}.md" | |
echo "---" >>./"${today}-${title}.md" | |
echo "layout: post" >>./"${today}-${title}.md" | |
echo "title: $title" >>./"${today}-${title}.md" | |
echo "date: $nowGMT" >>./"${today}-${title}.md" | |
echo "categories: $category" >>./"${today}-${title}.md" | |
echo "tags: $tag" >>./"${today}-${title}.md" | |
echo "---" >>./"${today}-${title}.md" | |
echo "" >>./"${today}-${title}.md" | |
echo "" >>./"${today}-${title}.md" | |
echo "------" >>./"${today}-${title}.md" | |
# Open the new blog by sublime. | |
# You can modify the program as you like. | |
if $(which sl);then | |
sl ./"${today}-${title}.md" & | |
elif [ -x "$sublimecmd" ];then | |
"$sublimecmd" ./"${today}-${title}.md" & | |
fi |
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 | |
# Usage test.sh Repo_name (No /!) | |
# Need to set up two.github.com as github.com firstly!! | |
SecondUserName="HelloWorld" | |
SecondEmail="secondMail@gmail.com" | |
if [ ! -d $1 ];then | |
exit 1 | |
fi | |
cd $1 | |
repname=$1 | |
# a=`pwd` | |
# repname=${a##*/} | |
git config --local user.email "$SecondEmail" | |
git config --local user.name "$SecondUserName" | |
git remote set-url origin git@two.github.com:${SecondUserName}/${repname}.git | |
if [ ! -z $2 ];then | |
echo "*.iml | |
.idea/ | |
.idea/scopes/scope_settings.xml | |
.idea/workspace.xml | |
.ipr | |
.iws | |
*~ | |
~* | |
*.diff | |
*.patch | |
*.bak | |
.DS_Store | |
Thumbs.db | |
.project | |
.*proj | |
.svn/ | |
*.swp | |
*.swo | |
*.pyc | |
*.pyo | |
build | |
node_modules | |
_site | |
sea-modules | |
.cache | |
_old | |
*.sublime-project | |
*.sublime-workspace | |
" > .gitignore | |
echo "#! /bin/bash | |
# file: gitsubmit.sh | |
comment=\$1 | |
if [ -z \$comment ];then | |
comment=regular | |
fi | |
git add -A | |
git commit -am \"\$comment\" | |
git push origin master"> gitsubmit.sh | |
#git lfs track *.tar.gz | |
#git lfs track *.zip | |
#git lfs track *.MYD | |
chmod +x gitsubmit.sh | |
./gitsubmit.sh Initialize | |
fi | |
cd .. |
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 | |
# File: newblog.sh | |
# Author: PlatinHom | |
# Create: 2015-06-21, Last: 2015.10.10 | |
# Full Usage: "./newblog.sh title category tag1 tag2" | |
# Simple Usage without category and tag: ".newblog/.sh title" | |
# You should export GHPAGE_PATH="path_to_your_username.github.com" | |
# You can register your sublime here. It's not nessary. | |
nowsys=`uname -s` | |
# For MacOS | |
if [ $nowsys == "Darwin" ];then | |
alias subl="/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" | |
# For MINGW in Window | |
elif [ ${nowsys:0:5} == "MINGW" ];then | |
alias subl="/c/Program\ Files/Sublime\ Text\ 3/subl.exe" | |
fi | |
# Open sub-shell alias | |
shopt -s expand_aliases | |
# Set the directory to your blog directory | |
# Default in MyGit | |
blogdir="./platinhom.github.com" | |
if [ ! -z $GHPAGE_PATH ];then | |
blogdir=$GHPAGE_PATH | |
fi | |
# START | |
title=$1 | |
category=$2 | |
tag="${@:3}" | |
if [ -z $1 ];then | |
title="TempTitle-`date +%H%M%S`" | |
fi | |
if [ -z $2 ];then | |
category="Other" | |
fi | |
if [ -z $3 ];then | |
tag="Other" | |
fi | |
# My blog use GMT+8:00 time zone-China | |
# For MacOS | |
if [ `uname -s` == "Darwin" ];then | |
today=`date -u -v "+8H" +"%Y-%m-%d"` | |
# Other OS | |
else | |
today=`date -u -d "+8 hour" +"%Y-%m-%d"` | |
fi | |
# In github's jekyll,you should enter GMT time (time zone UTC(+0:00)) | |
nowGMT=`date -u +"%Y-%m-%d %H:%M:%S"` | |
touch ${blogdir}/_posts/"${today}-${title}.md" | |
echo "---" >> ${blogdir}/_posts/"${today}-${title}.md" | |
echo "layout: post" >> ${blogdir}/_posts/"${today}-${title}.md" | |
echo "title: $title" >> ${blogdir}/_posts/"${today}-${title}.md" | |
echo "date: $nowGMT" >> ${blogdir}/_posts/"${today}-${title}.md" | |
echo "categories: $category" >> ${blogdir}/_posts/"${today}-${title}.md" | |
echo "tags: $tag" >> ${blogdir}/_posts/"${today}-${title}.md" | |
echo "---" >> ${blogdir}/_posts/"${today}-${title}.md" | |
echo "" >> ${blogdir}/_posts/"${today}-${title}.md" | |
echo "" >> ${blogdir}/_posts/"${today}-${title}.md" | |
echo "------" >> ${blogdir}/_posts/"${today}-${title}.md" | |
# Open the new blog by sublime. | |
# You can modify the program as you like. | |
if $(which sl);then | |
sl ${blogdir}/_posts/"${today}-${title}.md" & | |
else | |
subl ${blogdir}/_posts/"${today}-${title}.md" & | |
fi |
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 | |
# This script help to convert the sphinx generated web dir to jekyll web dir. | |
# To convert _??? to ???_ in dir name and html/js/php files. | |
# Directly copy this script to the root directory of sphinx-website and run it. | |
# Zhixiong Zhao, 2015.12.15 | |
sphinxdir="" | |
echo > sphinxdir_grep_tmp.log | |
nowsys=`uname -s` | |
# For MacOS | |
if [ $nowsys == "Darwin" ];then | |
echo "#!/bin/bash | |
function grepsed() | |
{ | |
grep -H \"\$2\" \"\$1\" >> sphinxdir_grep_tmp.log | |
sed -i \"\" \"s/\$2\//\$3\//g\" \"\$1\" | |
return 0; | |
} | |
grepsed \"\$1\" \"\$2\" \"\$3\" | |
">sphinxdir_tmp.sh | |
# For MINGW in Window | |
elif [ ${nowsys:0:5} == "MINGW" ];then | |
echo "#!/bin/bash | |
function grepsed() | |
{ | |
grep -H \"\$2\" \"\$1\" >> sphinxdir_grep_tmp.log | |
sed -i \"s/\$2\//\$3\//g\" \"\$1\" | |
return 0; | |
} | |
grepsed \"\$1\" \"\$2\" \"\$3\" | |
">sphinxdir_tmp.sh | |
fi | |
chmod +x sphinxdir_tmp.sh | |
for d in * ; do | |
if [ -d $d ];then | |
if [ ${d:0:1} = '_' ];then | |
sphinxdir="$sphinxdir $d" | |
fi | |
fi | |
done | |
# Modify the html/php/js files | |
for dir in $sphinxdir;do | |
dirname="${dir:1}_" | |
find . \( -iname "*.html" -or -iname "*.js" -or -iname "*.php" \) -exec ./sphinxdir_tmp.sh {} "$dir" "$dirname" \; | |
mv "$dir" "$dirname" | |
done | |
rm sphinxdir_tmp.sh |
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 | |
grep "TODO" *.md */*.md | |
grep "todo" *.md */*.md | |
grep "Todo" *.md */*.md | |
grep "ToDo" *.md */*.md | |
echo "End" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment