154 lines
3.1 KiB
Bash
Executable file
154 lines
3.1 KiB
Bash
Executable file
#!/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\tlog.txt:\t$LOGTXTPATH"
|
|
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.gpg" ];
|
|
then
|
|
echo "archive.tar.gz.gpg does not exist."
|
|
exit 1
|
|
fi
|
|
mkdir tmp
|
|
#gpg -o archive.tar.gz -d archive.tar.gz.gpg
|
|
tar xzf archive.tar.gz -C .
|
|
cp -r ./tmp/wiki $(dirname $VIMWIKIPATH)
|
|
cp ./tmp/todo.txt $TODOTXTPATH
|
|
cp ./tmp/.vimrc $MYVIMRC
|
|
cp ./tmp/log.txt $LOGTXTPATH
|
|
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/
|
|
cp $LOGTXTPATH ./tmp/
|
|
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 '(?<!:)[[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2}') &>/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
|
|
}
|
|
|
|
# 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 "$LOGTXTPATH" ];
|
|
then
|
|
echo "LOGTXTPATH 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
|
|
|