dev
Joe 3 years ago
parent 3e4756ca04
commit 1e1fa00356
Signed by: joe
GPG Key ID: 8595A3F8F2CE1B74
  1. 75
      ysm.sh

@ -0,0 +1,75 @@
#!/bin/bash
default_extension="ysess"
default_name="last.$default_extension"
default_format="+%x_%H:%M:%S"
default_action="increment"
default_path="$HOME/.ysess"
default_s_path="$HOME/.ysess/*.ysess"
Configure() {
echo Configuring
case "$1" in
name ) echo -n "last.ysess";;
format ) echo -n "+%x_%H:%M:%S";;
action ) echo -n "increment";;
path ) echo -n "$HOME/.ysess";;
s_path ) echo -n "$HOME/.ysess/*.ysess";;
esac
}
name="$default_name"
date_format="$default_date_format"
action="$default_action"
CreateFiles() {
if [ ! -d "$default_path" ]; then
mkdir $HOME/.ysess
touch $HOME/.ysess/last.name
fi
}
CreateArray() {
sessions=($default_s_path)
}
UserInput() {
read -r -p "$(echo -e '\e[4mL\e[0moad/\e[4mS\e[0mave: ')" task
}
CallTask() {
case "$task" in
[Ll] ) LoadSession;;
[Ss] ) SaveSession;;
* ) InvalidInput;;
esac
}
LoadSession() {
for ((i=0;i<"${#sessions[*]}";i++)); do
echo -n "[$i] "
echo "$(basename "${sessions[$i]}" .ysess)"
done
}
Debug() {
echo Debug Enabled!
echo Sessions: $default_s_path
echo Total: ${#sessions[*]}
echo Extension: $default_extension
echo Name: $default_name
echo Format: $default_format
echo Action: $default_action
echo Path: $default_path
}
Main() {
Configure
CreateFiles
CreateArray
Debug
UserInput
CallTask
}
Main
Loading…
Cancel
Save