Skip to content

Instantly share code, notes, and snippets.

@waltervargas
Created January 28, 2018 22:26
Show Gist options
  • Save waltervargas/97ea991c62e78601e4c2fbb9e388e67c to your computer and use it in GitHub Desktop.
Save waltervargas/97ea991c62e78601e4c2fbb9e388e67c to your computer and use it in GitHub Desktop.
autoload colors; colors
rc=$reset_color
EDITOR=ec
export WALTERBIO_PATH=$HOME/git/walter.bio
function init {
cd $HOME/git/walter.bio
print -- $fg[magenta]\❁ $fg[yellow]"Initializing walter.bio" $rc
load_env
}
function load_env {
export MEDIUM_USER_ID="1"
export MEDIUM_INTEGRATION_TOKEN="1"
check "Setup ENV"
}
function message {
local msg=$1
print -- $fg[yellow] \❁$rc $msg
}
function check {
local msg=$1
print -- $fg[green] \✔$rc $msg
}
function draft {
case $1 in
create)
draft_create $2 $3 $4 $5
;;
ls)
draft_ls
;;
*)
draft_ls
;;
esac
}
function draft_ls {
ls $WALTERBIO_PATH/_drafts
}
function draft_create {
local file=$WALTERBIO_PATH/_drafts/$1.md
local title=$2
local date=$(date +"%F %T %z")
local categories=$(echo $4 | tr ',' ' ')
if [[ ! -e $file ]]; then
(cat <<EOF
---
layout: post
title: "${title}"
date: ${date}
categories: ${categories}
comments: true
crosspost_to_medium: true
---
## References
## Questions
If you have questions, you can ask me on this post as a Disqus comment.
[ref1]: https://
EOF
) > $file
fi
$EDITOR $WALTERBIO_PATH/_drafts/$1.md
}
init;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment