├── README.md ├── bash-code.sh ├── bash-end-of-day.sh ├── bash-lunch.sh ├── bash-morning.sh ├── bash-personal.sh ├── bash-tired.sh └── timed-functions.sh /README.md: -------------------------------------------------------------------------------- 1 | # bash-my-day 2 | A set of bash scripts to get me on task and keep me moving. 3 | 4 | Mac OS X only. Relies heavily on the `say` command and `osascript` commands for controlling applications. 5 | 6 | The interesting functions are all in `timed-functions.sh`. Otherwise it is up to personal preference and whatever clever tricks you can come up with to optimize your time. If you want a place to start from I suggest `bash-morning.sh`. That is the script I use the most. 7 | 8 | Personally I find that this sort of scripting gives me a lot less to think about during the morning. My equivalent to Obama's only having one suit so he doesn't need to make a decision. I can also do things like script up links to recent code changes by everyone on my team, or every dashboard that I want to review for performance. I find having that sort of thing in a text file much easier to maintain than putting it into browser bookmarks. 9 | -------------------------------------------------------------------------------- /bash-code.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Goals here are: 4 | # - restart coding 5 | # - catch up on p2s and slack, but spend very little time on them 6 | 7 | source timed-functions.sh 8 | 9 | echo "some code review; 10 min code;" 10 | 11 | timed_confirm "Start code review. Ready to close Slack?" "Close slack and code?" 300 12 | osascript -e 'quit app "Slack"' 13 | 14 | timed_msg "Review code" 30 && 15 | timed_confirm "Done reviewing?" "Done reviewing?" 300 16 | 17 | echo "Coding" 18 | timed_msg "Start ten minutes of coding" 5 && 19 | timed_confirm "Are you really coding?" "Still coding?" 600 20 | -------------------------------------------------------------------------------- /bash-end-of-day.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Goals here are: 4 | # - leave some easy code to start on in the morning 5 | # - close out tabs 6 | # - journal 7 | # - clean up email 8 | # - gtd 9 | 10 | source timed-functions.sh 11 | 12 | echo "gtd; close p2 tabs; prep coding;" 13 | 14 | echo "GTD" 15 | osascript -e 'activate application "emacs"' 16 | timed_msg "Start two minutes of gtd" 2 && 17 | timed_confirm "Ready for closing tabs?" "tabs?" 120 18 | 19 | echo "Close Tabs" 20 | osascript -e 'activate application "Google Chrome"' 21 | timed_msg "Start twenty minutes of closing all tabs." 15 && 22 | timed_msg "Finish closing tabs in five minutes" 5 && 23 | timed_confirm "Ready to prep coding?" "coding?" 60 24 | 25 | echo "Coding Prep" 26 | osascript -e 'activate application "emacs"' 27 | timed_msg "Find a broken test or start broken code to fix tomorrow" 4 && 28 | timed_confirm "Ready to code tomorrow?" "done?" 300 29 | -------------------------------------------------------------------------------- /bash-lunch.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Goals here are: 4 | # - Clean out email 5 | # - close out tabs 6 | 7 | source timed-functions.sh 8 | 9 | echo "email; close p2 tabs; kill tabs" 10 | 11 | echo "Email" 12 | open https://inbox.google.com/u/0/ 13 | osascript -e 'activate application "Google Chrome"' 14 | timed_msg "Start five minutes of emptying email." 4 && 15 | timed_msg "Finish emptying email in three minutes" 1 && 16 | timed_confirm "Ready to p2?" "p2?" 60 17 | 18 | echo "Close Tabs" 19 | timed_msg "Clean out tabs" 15 && 20 | timed_msg "Finish cleaning out tabs" 5 && 21 | timed_confirm "Give up and kill tabs?" "killing tabs?" 300 22 | timed_confirm "All tabs killed?" "All tabs killed?" 30 23 | -------------------------------------------------------------------------------- /bash-morning.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Goals here are: 4 | # - feel like I have caught up on p2s and slack, but don't get consumed 5 | # - set myself up for what to do today by prioritizing first thing 6 | # - turn off slack 7 | # - start coding 8 | 9 | source timed-functions.sh 10 | 11 | if [ -z "$1" ]; then 12 | TYPE="lead" 13 | else 14 | TYPE="$1" 15 | fi 16 | 17 | tabs=`strings ~/Library/Application\ Support/Google/Chrome/Default/Sessions/Tabs_* | sed -nE 's/^([^:]+):\/\/(.*)\/$/\2/p' | grep -v "newtab" | grep -v "new-tab-page" | sort | uniq | wc -l` 18 | 19 | 20 | if [ "$tabs" -gt 50 ]; then 21 | osascript -e 'activate application "Google Chrome"' 22 | echo "Clean tabs" 23 | timed_msg "Yikes! You have about $tabs tabs open." 10 && 24 | timed_confirm "Have you closed some tabs?" "Move on." 600 25 | fi 26 | 27 | case "$TYPE" in 28 | "code") 29 | i_do_say 'OK. Get coding!' 30 | echo "review; code;" 31 | ;; 32 | "lead") 33 | i_do_say 'Time to lead!' 34 | echo "prioritize; fires; lead!" 35 | ;; 36 | "catchup") 37 | i_do_say 'OK. Play catchup.' 38 | echo "slack; p2s; gtd; standup; play catchup;" 39 | ;; 40 | "livechat") 41 | echo "slack; p2s; gtd; standup; prep chat; chat;" 42 | ;; 43 | *) 44 | i_do_say 'Lead or code!' 45 | echo "lead or code?" 46 | exit 47 | ;; 48 | esac 49 | 50 | # Trigger starting 51 | case "$TYPE" in 52 | "code") 53 | echo "Ten Minutes Coding" 54 | osascript -e 'activate application "emacs"' 55 | timed_msg "Start coding now." 5 && 56 | timed_confirm "Are you really coding?" "Start Slack" 600 57 | ;; 58 | "lead") 59 | echo "GTD" 60 | osascript -e 'activate application "emacs"' 61 | timed_msg "Start ten minutes prioritizing GTD." 8 && 62 | timed_msg "Finish gtd in two minutes" 1 && 63 | timed_msg "Finish gtd in one minute" 1 && 64 | timed_confirm "GTD Done?" "Fires?" 60 65 | ;; 66 | *) 67 | ;; 68 | esac 69 | 70 | # Look for Fires 71 | case "$TYPE" in 72 | "code"|"lead"|"catchup") 73 | echo "Slack" 74 | osascript -e 'activate application "Slack"' 75 | timed_msg "Check slack for 7 minutes" 5 && 76 | timed_msg "Finish slack in two minutes" 2 77 | 78 | echo "Alerts" 79 | osascript -e 'tell application "Google Chrome"' -e 'make new window' -e 'activate' -e'end tell' 80 | open https://mail.google.com/mail/u/1/ 81 | timed_msg "look at e-mail fires" 3 82 | 83 | echo "P2 notifications" 84 | open https://elasticsearchp2.wordpress.com/ 85 | osascript -e 'activate application "Google Chrome"' 86 | timed_msg "Open p2 notifications, but do not read!" 3 && 87 | timed_msg "Finish triaging p2s in one minutes" 1 88 | ;; 89 | *) 90 | ;; 91 | esac 92 | 93 | # Real Work 94 | case "$TYPE" in 95 | "lead") 96 | paws_in_air 97 | echo "Close Slack and start some real work." 98 | timed_confirm "Start some real work. Ready to close Slack?" "Close slack and work?" 300 99 | osascript -e 'quit app "Slack"' 100 | 101 | osascript -e 'activate application "Google Chrome"' 102 | timed_msg "Put out fires for 30 minutes." 30 && 103 | timed_confirm "Done with fires?" "Done with fires?" 600 104 | 105 | osascript -e 'activate application "Google Chrome"' 106 | timed_msg "Do top priority." 60 && 107 | timed_confirm "Look at P2s?" "Look at P2s?" 600 108 | 109 | paws_in_air 110 | 111 | echo "P2 Time" 112 | osascript -e 'activate application "Google Chrome"' 113 | timed_msg "Answer P2s." 30 && 114 | timed_msg "Any P2s to write?" 30 && 115 | timed_confirm "Done p2ing?" "Done p2ing?" 600 116 | 117 | osascript -e 'activate application "Slack"' 118 | 119 | timed_msg "Clean out Slack" 10 && 120 | timed_confirm "Slack clean?" "Slack clean?" 600 121 | ;; 122 | "code") 123 | paws_in_air 124 | echo "Code Review. Close Slack?" 125 | timed_confirm "Start code review. Ready to close Slack?" "Close slack and code?" 300 126 | osascript -e 'quit app "Slack"' 127 | 128 | osascript -e 'activate application "Google Chrome"' 129 | timed_msg "Review code" 30 && 130 | timed_confirm "Done reviewing?" "Done reviewing?" 300 131 | 132 | echo "Coding" 133 | osascript -e 'activate application "emacs"' 134 | timed_msg "Start coding now." 5 && 135 | timed_confirm "Are you really coding?" "Still coding?" 600 136 | 137 | timed_msg "Code for an hour." 55 138 | 139 | paws_in_air 140 | timed_confirm "Ready for notifications?" "Notifications?" 600 141 | 142 | osascript -e 'activate application "Slack"' 143 | osascript -e 'activate application "Google Chrome"' 144 | 145 | echo "GTD" 146 | osascript -e 'activate application "emacs"' 147 | timed_msg "Start five minutes of gtd" 3 && 148 | timed_msg "Finish gtd in two minutes" 1 && 149 | timed_msg "Finish gtd in one minute" 1 150 | 151 | echo "Standup" 152 | timed_msg "Write up standup" 2 && 153 | timed_confirm "Standup posted?" "coding?" 180 154 | 155 | if [[ $(date +%u) -eq 5 ]] ; then 156 | i_do_say --rate 250 'It is friday. Review!' 157 | paws_in_air 158 | 159 | echo "GTD" 160 | osascript -e 'activate application "emacs"' 161 | timed_msg "Start ten minutes of gtd. Full review" 8 && 162 | timed_msg "Finish gtd in two minutes" 1 && 163 | timed_msg "Finish gtd in one minute" 1 164 | timed_confirm "GTD Done?" "Start Standup?" 60 165 | 166 | echo "Catchup email" 167 | open https://mail.google.com/mail/u/1/ 168 | osascript -e 'activate application "Google Chrome"' 169 | timed_msg "Catchup on e-mail" 10 && 170 | timed_confirm "Done with e-mail?" "Done with e-mail?" 300 171 | 172 | echo "Catchup p2 and tabs" 173 | osascript -e 'activate application "Google Chrome"' 174 | timed_msg "Catchup on p2 tabs" 30 && 175 | timed_confirm "Done with p2s?" "Save p2s for later?" 300 176 | fi 177 | ;; 178 | "catchup") 179 | paws_in_air 180 | echo "GTD" 181 | osascript -e 'activate application "emacs"' 182 | timed_msg "Start ten minutes of gtd." 8 && 183 | timed_msg "Finish gtd in two minutes" 1 && 184 | timed_msg "Finish gtd in one minute" 1 185 | timed_confirm "GTD Done?" "Start Standup?" 60 186 | 187 | osascript -e 'activate application "Google Chrome"' 188 | timed_msg "Review code" 30 && 189 | timed_confirm "Done reviewing?" "Done reviewing?" 300 190 | 191 | osascript -e 'activate application "Google Chrome"' 192 | timed_msg "Go through old tabs" 60 && 193 | timed_confirm "Done with p2s?" "Done with p2s?" 300 194 | 195 | echo "Catchup email" 196 | open https://mail.google.com/mail/u/1/ 197 | osascript -e 'activate application "Google Chrome"' 198 | timed_msg "Catchup on e-mail" 10 && 199 | timed_confirm "Done with e-mail?" "Done with e-mail?" 300 200 | 201 | echo " Cleanup p2 and tabs" 202 | timed_msg "Catchup on p2 tabs" 30 && 203 | timed_confirm "Done with p2s?" "Save p2s for later?" 300 204 | 205 | ;; 206 | "review") 207 | paws_in_air 208 | echo "GTD" 209 | osascript -e 'activate application "emacs"' 210 | timed_msg "Start ten minutes of gtd. Full review" 8 && 211 | timed_msg "Finish gtd in two minutes" 1 && 212 | timed_msg "Finish gtd in one minute" 1 213 | timed_confirm "GTD Done?" "Start Standup?" 60 214 | 215 | echo "Standup" 216 | timed_msg "Write up standup" 2 && 217 | timed_confirm "Standup posted?" "coding?" 180 218 | 219 | echo "Catchup email" 220 | open https://mail.google.com/mail/u/1/ 221 | osascript -e 'activate application "Google Chrome"' 222 | timed_msg "Catchup on e-mail" 10 && 223 | timed_confirm "Done with e-mail?" "Done with e-mail?" 300 224 | 225 | echo "Catchup swarm" 226 | open "https://mc.a8c.com/mgs/?ms=p2&q=date%3Alast-week&sort=swarm" 227 | open "https://mc.a8c.com/mgs/?ms=p2&q=date%3Alast-week%20author%3Amatt&sort=swarm" 228 | open "https://mc.a8c.com/mgs/?ms=p2&q=date%3Alast-week%20author%3Amartinremy&sort=swarm" 229 | open "https://mc.a8c.com/mgs/?ms=p2&q=date%3Alast-week&sort=score" 230 | open "https://mc.a8c.com/mgs/?ms=p2&q=date%3Alast-month%20site%3Athursdayupdates.wordpress.com&sort=swarm" 231 | open "https://mc.a8c.com/mgs/?ms=p2&q=date%3Alast-week%20jetpack&sort=swarm" 232 | open "https://mc.a8c.com/mgs/?ms=p2&q=date%3Alast-week%20type%3Acomment&sort=swarm" 233 | open "https://mc.a8c.com/mgs/?ms=p2&q=date%3Alast-month%20author%3Acallgrierson&sort=swarm" 234 | 235 | osascript -e 'activate application "Google Chrome"' 236 | timed_msg "Go through Swarm and old tabs" 60 && 237 | timed_confirm "Done with p2s?" "Done with p2s?" 300 238 | 239 | echo "Catchup p2 and tabs" 240 | timed_msg "Catchup on p2 tabs" 30 && 241 | timed_confirm "Done with p2s?" "Save p2s for later?" 300 242 | 243 | ;; 244 | "livechat") 245 | echo "Prep live chat." 246 | timed_confirm "Prep for live chat." "Ready for live chat?" 300 247 | 248 | echo "Live Chat" 249 | timed_msg "Start chatting now." 5 && 250 | timed_confirm "Are you really chatting?" "Still chatting?" 600 251 | 252 | timed_msg "Chat for an hour." 55 253 | 254 | echo "Break from chat." 255 | timed_confirm "Take a break from chatting." "Taking a break?" 300 256 | 257 | echo "Prep live chat." 258 | timed_confirm "Prep for live chat." "Ready for live chat?" 300 259 | 260 | echo "Live Chat" 261 | timed_msg "Start chatting now." 5 && 262 | timed_confirm "Are you really chatting?" "Still chatting?" 600 263 | 264 | timed_msg "Chat for an hour." 55 265 | ;; 266 | *) 267 | ;; 268 | esac 269 | -------------------------------------------------------------------------------- /bash-personal.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Goals here are: 4 | # - feel like I have caught up on p2s and slack, but don't get consumed 5 | # - set myself up for what to do today by prioritizing first thing 6 | # - turn off slack 7 | # - start coding 8 | 9 | source timed-functions.sh 10 | 11 | i_do_say 'Personal get things done.' 12 | echo "play catchup; focus" 13 | 14 | osascript -e 'tell application "Spotify" to play' 15 | paws_in_air 16 | 17 | echo "GTD" 18 | osascript -e 'activate application "emacs"' 19 | timed_msg "Start ten minutes of gtd. Full review" 8 && 20 | timed_msg "Finish gtd in two minutes" 1 && 21 | timed_msg "Finish gtd in one minute" 1 && 22 | timed_confirm "GTD Done?" "GTD Done?" 60 23 | 24 | items=( 25 | "high priority personal" 26 | "rehab review" 27 | "how review" 28 | "desk cleanup" 29 | "delete email" 30 | "phone and messages" 31 | "go through mail" 32 | "email inbox" 33 | "close tabs" 34 | "low priority personal" 35 | ) 36 | for i in "${items[@]}" 37 | do 38 | echo $i 39 | case "$TYPE" in 40 | "rehab review"|"how review") 41 | osascript -e 'activate application "emacs"' 42 | ;; 43 | "close tabs") 44 | osascript -e 'activate application "emacs"' 45 | ;; 46 | "delete email"|"email inbox") 47 | osascript -e 'tell application "Google Chrome"' -e 'make new window' -e 'activate' -e'end tell' 48 | open https://mail.google.com/mail/u/0/ 49 | ;; 50 | *) 51 | ;; 52 | esac 53 | timed_msg "Start ten minutes of $i" 8 && 54 | timed_msg "Finish $i in two minutes" 1 && 55 | timed_msg "Finish $i in one minute" 1 && 56 | timed_confirm "$i Done?" "Done?" 600 57 | done 58 | 59 | paws_in_air 60 | echo "Start" 61 | osascript -e 'activate application "emacs"' 62 | timed_msg "Start on GTD" 8 63 | timed_confirm "Working on GTD?" "Working?" 300 64 | -------------------------------------------------------------------------------- /bash-tired.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Goals here are: 4 | # - feel like I have caught up on p2s and slack, but don't get consumed 5 | # - set myself up for what to do today by prioritizing first thing 6 | # - turn off slack 7 | # - start coding 8 | 9 | source timed-functions.sh 10 | 11 | paws_in_air 12 | 13 | echo "1/10 Code Review" 14 | timed_msg "Start code review?" 5 && 15 | timed_msg "Review code" 60 && 16 | timed_confirm "Done reviewing?" "Still reviewing?" 600 17 | 18 | echo "2/10 Code main project" 19 | timed_msg "Start coding on main project?" 5 && 20 | timed_msg "Code" 60 && 21 | timed_confirm "Done coding?" "Still coding?" 600 22 | 23 | echo "3/10 Code greenfield" 24 | timed_msg "Start coding in a green field?" 5 && 25 | timed_msg "Code" 60 && 26 | timed_confirm "Done coding?" "Still coding?" 600 27 | 28 | echo "4/10 Re-organize Tasks" 29 | timed_msg "Start re-org tasks?" 5 && 30 | timed_msg "Re-org" 30 && 31 | timed_confirm "Done Re-org?" "Still Re-org?" 600 32 | 33 | echo "5/10 GTD and prep" 34 | timed_msg "Start GTD and prep for coding?" 5 && 35 | timed_msg "GTD" 30 && 36 | timed_confirm "Done GTD?" "Still GTD?" 600 37 | 38 | echo "6/10 Catchup tabs" 39 | timed_msg "Start going through tabs?" 5 && 40 | timed_msg "Tabs" 30 && 41 | timed_confirm "Done with tabs?" "Still reviewing tabs?" 600 42 | 43 | echo "7/10 Catchup email" 44 | timed_msg "Start going through email?" 5 && 45 | timed_msg "email" 30 && 46 | timed_confirm "Done with email?" "Still reviewing email?" 600 47 | 48 | echo "8/10 Write strategy" 49 | timed_msg "Start writing strategy p2?" 5 && 50 | timed_msg "strategy" 60 && 51 | timed_confirm "Done with writing?" "Still writing?" 600 52 | 53 | echo "9/10 Catchup p2s" 54 | timed_msg "Start going through p2s?" 5 && 55 | timed_msg "p2s" 60 && 56 | timed_confirm "Done with p2s?" "Still reviewing p2s?" 600 57 | 58 | echo "10/10 Catchup bookmarks" 59 | timed_msg "Start going through bookmarks?" 5 && 60 | timed_msg "Bookmarks" 30 && 61 | timed_confirm "Done with bookmarks?" "Still reviewing bookmarks?" 600 62 | -------------------------------------------------------------------------------- /timed-functions.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # $1 string 4 | function i_do_say() { 5 | osascript -e "display notification \"$*\" with title \"Do It\"" 6 | say --rate 250 $* 7 | } 8 | 9 | function paws_in_air() { 10 | msg="Pause. . Breathe. . Look. . Relax. . Think. . 3. 2. 1." 11 | osascript -e "display notification \"$msg\" with title \"Do It\"" 12 | say --rate 100 $msg 13 | } 14 | 15 | # $1 : Activity string 16 | # $2 : Time 17 | function timed_msg() { 18 | i_do_say $1 19 | re='^[0-9]+$' 20 | read -t "$(($2 * 60))" 21 | if [ $? -ne 0 ]; then 22 | return 0 23 | elif [[ $varkey =~ $re ]]; then 24 | extradelay=$((varkey*10)) 25 | echo 26 | read -n 1 -t $((extradelay*60)) -p "Paused $extradelay minutes" varkey 27 | echo 28 | return 0 29 | else 30 | return 1 31 | fi 32 | } 33 | 34 | # $1 : Next Activity String 35 | # $2 : Reminder String 36 | # $3 : Time in seconds 37 | function timed_confirm() { 38 | i_do_say $1 39 | delay=$3 40 | cnt=0 41 | re='^[0-9]+$' 42 | while true; do 43 | read -n 1 -t $delay -p "$delay seconds: 'd' => +5 min; [1-9] => [10-90] min; any key => end." varkey 44 | if [ $? -ne 0 ]; then 45 | echo 46 | i_do_say $2 47 | cnt=$((cnt+1)) 48 | if [[ "$cnt" -gt 7 ]]; then 49 | cnt=0 50 | delay="$(($delay * 2))" 51 | paws_in_air 52 | fi 53 | elif [ "d" == "$varkey" ]; then 54 | varkey='' 55 | delay="$(($delay + 300))" 56 | echo 57 | echo "Delaying 5 min" 58 | elif [[ $varkey =~ $re ]]; then 59 | extradelay=$((varkey*10)) 60 | echo 61 | read -n 1 -t $((extradelay*60)) -p "Paused $extradelay minutes" varkey 62 | echo 63 | else 64 | echo 65 | break 66 | fi 67 | done 68 | } 69 | 70 | # From the starting date, adjust the number of minutes returned 71 | # based on the other arguments 72 | # This makes for an easy way to get into a new habit. eg meditation for 73 | # one minute a day ramping up to 10 minutes a day over a few weeks 74 | # $1 : Starting Date in Y-m-d format 75 | # $* : The weekly ramp up. 76 | function timed_weekly_ramp() { 77 | d1=$(date -j -f "%Y-%m-%d" "$1" "+%s") 78 | d2=$(date +%s) 79 | diff=$(( (d2 - d1) / 86400 / 7 + 2 )) 80 | 81 | if [ -z "${!diff}" ]; then 82 | echo "${@: -1}" 83 | else 84 | echo "${!diff}" 85 | fi 86 | } 87 | 88 | export -f timed_confirm 89 | export -f timed_msg 90 | export -f timed_weekly_ramp 91 | --------------------------------------------------------------------------------