2021-12-08 09:38:24 -06:00
|
|
|
function cl() {
|
2022-01-18 12:29:42 -06:00
|
|
|
DIR="$*"
|
|
|
|
# if no DIR given, go home
|
|
|
|
if [ $# -lt 1 ]; then
|
|
|
|
DIR=$HOME
|
|
|
|
fi
|
|
|
|
builtin cd "${DIR}" &&
|
|
|
|
# use your preferred ls command
|
|
|
|
ls -F --color=auto
|
2021-12-08 09:38:24 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#delete and reclone remote repo
|
2022-01-18 12:29:42 -06:00
|
|
|
reclone() {
|
|
|
|
basename=${PWD##*/}
|
|
|
|
remoteurl=$(git remote get-url --push origin)
|
|
|
|
cd ..
|
|
|
|
echo $basename
|
|
|
|
echo $remoteurl
|
|
|
|
rm -rf $basename
|
|
|
|
git clone $remoteurl
|
|
|
|
cd $basename
|
2021-12-08 09:38:24 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
# snakemake use all cores by default
|
|
|
|
sm() {
|
2022-01-18 12:29:42 -06:00
|
|
|
if [[ $* == *"-j"* || $* == *"--jobs"* || $* == *"--cores"* ]]; then
|
|
|
|
snakemake $@
|
|
|
|
else
|
|
|
|
snakemake -j all $@
|
|
|
|
fi
|
2021-12-08 09:38:24 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
function gi() {
|
2022-01-18 12:29:42 -06:00
|
|
|
curl -sL "https://www.toptal.com/developers/gitignore/api/$@"
|
|
|
|
}
|
2021-12-08 09:38:24 -06:00
|
|
|
|
|
|
|
# make pdfs or svgs from vegalite json's
|
2022-01-18 12:29:42 -06:00
|
|
|
mkvegapdf() {
|
|
|
|
vl2vg $1 | vg2pdf >$2
|
2021-12-08 09:38:24 -06:00
|
|
|
}
|
|
|
|
|
2022-01-18 12:29:42 -06:00
|
|
|
mkvegasvg() {
|
|
|
|
vl2vg $1 | vg2svg >$2
|
2021-12-08 09:38:24 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
# quick and dirty pdf generation from simple md
|
2022-01-18 12:29:42 -06:00
|
|
|
md2pdf() {
|
2021-12-08 09:38:24 -06:00
|
|
|
root=$1
|
|
|
|
# get extension and root path: https://stackoverflow.com/a/40928328
|
2022-01-18 12:29:42 -06:00
|
|
|
fname="${root#.}"
|
|
|
|
fname="${root%"$fname"}${fname%.*}"
|
2021-12-08 09:38:24 -06:00
|
|
|
ext="${root#"$fname"}"
|
|
|
|
echo "converting $root to pdf"
|
|
|
|
|
|
|
|
if [[ $ext != ".md" ]]; then
|
|
|
|
echo "error! expected a markdown file"
|
|
|
|
echo "unrecognized extension: $ext"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
pandoc -V geometry:a5paper -V geometry:margin=.5in --dpi=300 -o ${fname}.pdf $root
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-01-18 12:29:42 -06:00
|
|
|
py2nb2html() {
|
2021-12-08 09:38:24 -06:00
|
|
|
if [ $# -eq 0 ]; then
|
|
|
|
echo "No arguments provided"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
pyfile=$1
|
|
|
|
shift
|
|
|
|
echo "generating html file for $pyfile"
|
|
|
|
jupytext --to notebook -o - $pyfile | jupyter nbconvert --execute --to html --stdin $@
|
|
|
|
}
|