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
This commit is contained in:
parent
ade3b22990
commit
e1bad7d4f2
2 changed files with 153 additions and 6 deletions
57
dev-env.sh
57
dev-env.sh
|
@ -1,10 +1,11 @@
|
||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
|
|
||||||
_notes_locations_print()
|
_notes_locations_print()
|
||||||
{
|
{
|
||||||
echo "\t\ttodo.txt:\t$TODOTXTPATH"
|
echo "\t\ttodo.txt:\t$TODOTXTPATH"
|
||||||
echo "\t\twiki:\t\t$VIMWIKIPATH"
|
echo "\t\twiki:\t\t$VIMWIKIPATH"
|
||||||
echo "\t\tvimrc\t\t$MYVIMRC"
|
echo "\t\tvimrc\t\t$MYVIMRC"
|
||||||
|
echo "\t\tlog.txt\t\t$LOGTXTPATH"
|
||||||
}
|
}
|
||||||
|
|
||||||
_help()
|
_help()
|
||||||
|
@ -14,7 +15,7 @@ _help()
|
||||||
_notes_locations_print
|
_notes_locations_print
|
||||||
echo "\tsn: Store notes:"
|
echo "\tsn: Store notes:"
|
||||||
_notes_locations_print
|
_notes_locations_print
|
||||||
echo "\ttmux: Launch standard tmux session."
|
echo "\tnotes: Launch note making tmux session."
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,6 +31,7 @@ _extract_notes()
|
||||||
cp -r ./tmp/wiki $(dirname $VIMWIKIPATH)
|
cp -r ./tmp/wiki $(dirname $VIMWIKIPATH)
|
||||||
cp ./tmp/todo.txt $TODOTXTPATH
|
cp ./tmp/todo.txt $TODOTXTPATH
|
||||||
cp ./tmp/.vimrc $MYVIMRC
|
cp ./tmp/.vimrc $MYVIMRC
|
||||||
|
cp ./tmp/log.txt $LOGTXTPATH
|
||||||
rm -r ./tmp
|
rm -r ./tmp
|
||||||
echo "Notes successfully extracted from archive."
|
echo "Notes successfully extracted from archive."
|
||||||
exit 0
|
exit 0
|
||||||
|
@ -41,16 +43,52 @@ _storage_notes()
|
||||||
cp $TODOTXTPATH ./tmp/
|
cp $TODOTXTPATH ./tmp/
|
||||||
cp -r $VIMWIKIPATH ./tmp/
|
cp -r $VIMWIKIPATH ./tmp/
|
||||||
cp $MYVIMRC ./tmp/
|
cp $MYVIMRC ./tmp/
|
||||||
|
cp $LOGTXTPATH ./tmp/
|
||||||
tar czf archive.tar.gz ./tmp/
|
tar czf archive.tar.gz ./tmp/
|
||||||
rm -r tmp
|
rm -r tmp
|
||||||
echo "Notes successfully stored!"
|
echo "Notes successfully stored!"
|
||||||
exit 0
|
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'
|
# i want this function to show me a graph of work created to work done
|
||||||
tmux new-window 'bash'
|
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
|
tmux -2 attach-session -d
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,12 +114,19 @@ then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -z "$LOGTXTPATH" ];
|
||||||
|
then
|
||||||
|
echo "LOGTXTPATH not set."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# run the user's command
|
# run the user's command
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
sn ) _storage_notes ;;
|
sn ) _storage_notes ;;
|
||||||
xn ) _extract_notes ;;
|
xn ) _extract_notes ;;
|
||||||
tmux ) _launch_tmux ;;
|
notes ) _launch_notes ;;
|
||||||
|
graph ) _graph_notes ;;
|
||||||
* ) _help ;;
|
* ) _help ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
102
setup-dev-env.sh
Executable file
102
setup-dev-env.sh
Executable file
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue