From e1bad7d4f248ac026f63be0c9c4e37c44dc036b0 Mon Sep 17 00:00:00 2001 From: Michal Skorczak Date: Tue, 4 Feb 2025 16:56:59 +0000 Subject: [PATCH] Added: setup-dev-env.sh should install everything I need/want, added the first taste of graphs from the todo list, probably would have to be it's own script though --- dev-env.sh | 57 +++++++++++++++++++++++--- setup-dev-env.sh | 102 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 153 insertions(+), 6 deletions(-) create mode 100755 setup-dev-env.sh diff --git a/dev-env.sh b/dev-env.sh index 9864e53..e03346b 100755 --- a/dev-env.sh +++ b/dev-env.sh @@ -1,10 +1,11 @@ -#!/bin/sh +#!/bin/bash _notes_locations_print() { echo "\t\ttodo.txt:\t$TODOTXTPATH" echo "\t\twiki:\t\t$VIMWIKIPATH" echo "\t\tvimrc\t\t$MYVIMRC" + echo "\t\tlog.txt\t\t$LOGTXTPATH" } _help() @@ -14,7 +15,7 @@ _help() _notes_locations_print echo "\tsn: Store notes:" _notes_locations_print - echo "\ttmux: Launch standard tmux session." + echo "\tnotes: Launch note making tmux session." exit 1 } @@ -30,6 +31,7 @@ _extract_notes() cp -r ./tmp/wiki $(dirname $VIMWIKIPATH) cp ./tmp/todo.txt $TODOTXTPATH cp ./tmp/.vimrc $MYVIMRC + cp ./tmp/log.txt $LOGTXTPATH rm -r ./tmp echo "Notes successfully extracted from archive." exit 0 @@ -41,16 +43,52 @@ _storage_notes() cp $TODOTXTPATH ./tmp/ cp -r $VIMWIKIPATH ./tmp/ cp $MYVIMRC ./tmp/ + cp $LOGTXTPATH ./tmp/ tar czf archive.tar.gz ./tmp/ rm -r tmp echo "Notes successfully stored!" exit 0 } -_launch_tmux() +_reverse(){ reversed=();local i;for ((i=$#;i>0;i--)); do reversed+=("${!i}");done; } + +_graph_notes() { - tmux new-session -d 'vim $TODOTXTPATH $VIMWIKIPATH/index.md' - tmux new-window 'bash' + # 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 'vim $TODOTXTPATH $VIMWIKIPATH/index.md $LOGTXTPATH' tmux -2 attach-session -d } @@ -76,12 +114,19 @@ then exit 1 fi +if [ -z "$LOGTXTPATH" ]; +then + echo "LOGTXTPATH not set." + exit 1 +fi + # run the user's command case "$1" in sn ) _storage_notes ;; xn ) _extract_notes ;; - tmux ) _launch_tmux ;; + notes ) _launch_notes ;; + graph ) _graph_notes ;; * ) _help ;; esac diff --git a/setup-dev-env.sh b/setup-dev-env.sh new file mode 100755 index 0000000..48bc99f --- /dev/null +++ b/setup-dev-env.sh @@ -0,0 +1,102 @@ +#!/bin/sh + +# This is a script for setting up all the things I like :3 + +_install() +{ + echo "Installing!" + exit 0 +} + +_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" +} + +_help() +{ + _print_title + echo "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 + tar xzf archive.tar.gz -C . + cp -r ./tmp/wiki $(dirname $VIMWIKIPATH) + cp ./tmp/todo.txt $TODOTXTPATH + cp ./tmp/.vimrc $MYVIMRC + 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/ + tar czf archive.tar.gz ./tmp/ + rm -r tmp + echo "Notes successfully stored!" + exit 0 +} + +_launch_notes() +{ + tmux new-session -d 'bash' + tmux new-window 'vim $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 + +# run the user's command + +case "$1" in + sn ) _storage_notes ;; + xn ) _extract_notes ;; + notes ) _launch_notes ;; + install ) _install ;; + * ) _help ;; +esac +