2022-08-13 13:26:55 -05:00
|
|
|
#!/usr/bin/env zsh
|
|
|
|
|
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
|
2022-07-06 11:55:14 -05:00
|
|
|
if [ $# -lt 1 ]; then
|
|
|
|
DIR=$HOME
|
2022-01-18 12:29:42 -06:00
|
|
|
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 $@
|
|
|
|
}
|
2022-07-06 11:53:10 -05:00
|
|
|
|
|
|
|
alias bathelp='bat --plain --language=help'
|
|
|
|
help() {
|
2022-07-06 11:55:14 -05:00
|
|
|
"$@" --help 2>&1 | bathelp
|
2022-07-06 11:53:10 -05:00
|
|
|
}
|
2022-08-26 11:32:56 -05:00
|
|
|
|
|
|
|
format-qmd() {
|
2022-08-30 23:08:41 -05:00
|
|
|
jupytext --from qmd $1 --pipe black
|
2022-08-26 11:32:56 -05:00
|
|
|
}
|