Skip to content

Instantly share code, notes, and snippets.

@firedynasty
Created September 4, 2022 04:07
Show Gist options
  • Save firedynasty/bbaf38d7676c98aea5b5aca2935dbcdd to your computer and use it in GitHub Desktop.
Save firedynasty/bbaf38d7676c98aea5b5aca2935dbcdd to your computer and use it in GitHub Desktop.
Tracking Time Worked with Bash
# use website copy and paste start and stop work in succession to get the calculated time
# at https://cdpn.io/pen/debug/xxjxyZa
function timelist() {
cat /Users/desktop/macbook_pro_scripts/echo_files/timelist.txt
echo '->deletetimelist'
echo '->opentimelist'
}
function deletetimelist() {
combined_date_space_=$(date +'%c')
echo $combined_date_space_ > /Users/desktop/macbook_pro_scripts/echo_files/timelist.txt
}
function opentimelist() {
open /Users/desktop/macbook_pro_scripts/echo_files/timelist.txt
}
function timeon() {
if [[ $# -eq 0 ]]; then
cat /Users/desktop/macbook_pro_scripts/echo_files/timelist.txt
echo 'add date? y for yes'
read varname
date_now=$(date +"%I:%M %p")
end_string_=" - START WORK"
echo $date_now$end_string_
echo $date_now$end_string_ |pbcopy
combined_date_space_=$(date +'%c')
if [[ "$varname" == "y" ]]; then
echo 'yes'
echo $(date +'%c') >> /Users/desktop/macbook_pro_scripts/echo_files/timelist.txt
echo $date_now$end_string_ >> /Users/desktop/macbook_pro_scripts/echo_files/timelist.txt
cat /Users/desktop/macbook_pro_scripts/echo_files/timelist.txt
else
echo $date_now$end_string_ >> /Users/desktop/macbook_pro_scripts/echo_files/timelist.txt
cat /Users/desktop/macbook_pro_scripts/echo_files/timelist.txt
fi
else
cat /Users/desktop/macbook_pro_scripts/echo_files/timelist.txt
echo 'add date? y for yes'
read varname
date_now=$(date +"%I:%M %p")
end_string_=" - START WORK "
echo $date_now$end_string_
echo $date_now$end_string_ |pbcopy
combined_date_space_=$(date +'%c')
if [[ "$varname" == "y" ]]; then
echo 'yes'
echo $(date +'%c') >> /Users/desktop/macbook_pro_scripts/echo_files/timelist.txt
echo $date_now$end_string_$@ >> /Users/desktop/macbook_pro_scripts/echo_files/timelist.txt
cat /Users/desktop/macbook_pro_scripts/echo_files/timelist.txt
else
echo $date_now$end_string_$@ >> /Users/desktop/macbook_pro_scripts/echo_files/timelist.txt
cat /Users/desktop/macbook_pro_scripts/echo_files/timelist.txt
fi
fi
}
function timeoff() {
if [[ $# -eq 0 ]]; then
cat /Users/desktop/macbook_pro_scripts/echo_files/timelist.txt
date_now=$(date +"%I:%M %p")
end_string_=" - STOP WORK"
echo $date_now$end_string_
echo $date_now$end_string_ |pbcopy
combined_date_space_=$(date +'%c')
echo $date_now$end_string_ >> /Users/desktop/macbook_pro_scripts/echo_files/timelist.txt
cat /Users/desktop/macbook_pro_scripts/echo_files/timelist.txt
else
cat /Users/desktop/macbook_pro_scripts/echo_files/timelist.txt
date_now=$(date +"%I:%M %p")
end_string_=" - STOP WORK "
echo $date_now$end_string_
echo $date_now$end_string_ |pbcopy
combined_date_space_=$(date +'%c')
echo $date_now$end_string_$@ >> /Users/desktop/macbook_pro_scripts/echo_files/timelist.txt
cat /Users/desktop/macbook_pro_scripts/echo_files/timelist.txt
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment