#!/bin/sh _print_title() { echo "$(figlet mskor dev-env)" } _notes_locations_print() { echo "\t\ttodo.txt:\t$TODOTXTPATH" echo "\t\twiki:\t\t$VIMWIKIPATH" echo "\t\tvimrc:\t\t$MYVIMRC" echo "\t\tbashrc:\t\t$HOME/.bashrc" echo "\t\trss feeds:\t$HOME/.config/newsraft/feeds" } _help() { _print_title echo "setup-dev-env.sh usage: $0 [mode]" echo "\txn: Extract notes to:" _notes_locations_print echo "\tsn: Store notes:" _notes_locations_print echo "\tnotes: Launch note making tmux session." exit 1 } _extract_notes() { if [ ! -e "./archive.tar.gz" ]; then echo "archive.tar.gz does not exist." exit 1 fi mkdir tmp #gpg -o archive.tar.gz -d archive.tar.gz tar xzf archive.tar.gz -C . cp -r ./tmp/wiki $(dirname $VIMWIKIPATH) cp ./tmp/todo.txt $TODOTXTPATH cp ./tmp/vimrc $MYVIMRC cp ./tmp/bashrc $HOME/.bashrc cp ./tmp/rssfeeds $HOME/.config/newsraft/feeds rm -r ./tmp echo "Notes successfully extracted from archive." exit 0 } _storage_notes() { mkdir tmp cp $TODOTXTPATH ./tmp/ cp -r $VIMWIKIPATH ./tmp/ cp $MYVIMRC ./tmp/vimrc cp $HOME/.bashrc ./tmp/bashrc cp $HOME/.config/newsraft/feeds ./tmp/rssfeeds tar czf archive.tar.gz ./tmp/ rm -r tmp #gpg -c archive.tar.gz #rm archive.tar.gz echo "Notes successfully stored!" exit 0 } #_reverse(){ reversed=();local i;for ((i=$#;i>0;i--)); do reversed+=("${!i}");done; } # #_graph_notes() #{ # # i want this function to show me a graph of work created to work done # readarray -t arr < $TODOTXTPATH # for value in "${arr[@]}"; do # #mapfile -t dates < <(echo $value | grep -Po '(?/dev/null # declare dates # declare -A datemap # declare -A compdatemap # _reverse "${dates[@]}" && for i in "${reversed[@]}"; do ## if there are 2 options then do the following ## if there is one option then do the following # if [[ -z "${datemap["$i"]}" ]]; then # datemap[$i]=1 # else # datemap[$i]="$((datemap[$i] + 1))" # fi # # if one value, add 1 to that index on map # # if 2 values, add 1 to index of map and # done # if [[ ${#reversed[@]} == 2 ]]; then # echo "$datemap[$i]" # echo "COMPLETED ITEM" # fi # # # got the dates here, arrays of 2 mean the task was completed and should be added as [date1] [created] [date2] completed # done # for key in ${!datemap[@]} # do # echo "${key}, ${datemap[${key}]}" # done #} _launch_notes() { tmux new-session -d 'bash' tmux new-window 'newsraft' tmux new-window "calcurse" tmux new-window "vim -o $TODOTXTPATH $VIMWIKIPATH/index.md" tmux -2 attach-session -d } # main # check for the neccessary variables if [ -z "$VIMWIKIPATH" ]; then echo "VIMWIKIPATH not set." exit 1 fi if [ -z "$TODOTXTPATH" ]; then echo "TODOTXTPATH not set." exit 1 fi if [ -z "$MYVIMRC" ]; then echo "MYVIMRC not set." exit 1 fi if [ -z "$RSSFEEDSPATH" ]; then echo "RSSFEEDSPATH not set." exit 1 fi # run the user's command case "$1" in sn ) _storage_notes ;; xn ) _extract_notes ;; notes ) _launch_notes ;; #graph ) _graph_notes ;; * ) _help ;; esac