diff --git a/README.md b/README.md index e69de29..0559065 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,14 @@ +# dev-env + +## requirements + +`$TODOTXTPATH` needs to be set to your todo.txt path +: `export TODOTXTPATH=~/todo.txt` + +`$VIMWIKIPATH` needs to be set to your vim wiki path +: `export VIMWIKIPATH=~/wiki` + +## usage + +- ./dev-env.sh xn -> extract notes +- ./dev-env.sh sn -> store notes diff --git a/dev-env.sh b/dev-env.sh new file mode 100755 index 0000000..8866db5 --- /dev/null +++ b/dev-env.sh @@ -0,0 +1,59 @@ +#!/bin/sh + + +_help() +{ + echo "Usage: $0 [mode]" + echo "\txn: Extract notes to $TODOTXTPATH and $VIMWIKIPATH." + echo "\tsn: Store notes from $TODOTXTPATH and $VIMWIKIPATH." + exit 1 +} + + +_extract_notes() +{ + if [ ! -e "./archive.tar.gz" ]; + then + echo "archive.tar.gz does not exist." + exit 1 + fi + mkdir tmp + tar xzf archive.tar.gz -C . + mv ./wiki $(dirname $VIMWIKIPATH) + mv ./todo.txt $TODOTXTPATH + rm -r ./tmp + echo "Notes successfully extracted from archive." + exit 0 +} + +_storage_notes() +{ + mkdir tmp + cp $TODOTXTPATH ./tmp/ + cp -r $VIMWIKIPATH ./tmp/ + tar czf archive.tar.gz ./tmp/ + rm -r tmp + echo "Notes successfully stored!" + exit 0 +} + + +if [ -z "$VIMWIKIPATH" ]; +then + echo "VIMWIKIPATH not set." + exit 1 +fi + +if [ -z "$TODOTXTPATH" ]; +then + echo "TODOTXTPATH not set." + exit 1 +fi + + +case "$1" in + sn ) _storage_notes ;; + xn ) _extract_notes ;; + * ) _help ;; +esac +