Created
August 4, 2014 18:03
-
-
Save kohlhofer/4a981586474368605558 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# !/bin/bash | |
# mapped to lw (as in log work) this script simply appends any parameters as a new line in worklog.txt in ~/ | |
# no parameters will print the last 10 messages | |
# -o opens the worklog in VIM and immediately jumps to the last line. | |
# -l gets the tux to tell you the last message. | |
# -u deletes the last message (u as in undo). | |
# -uv also posts the message to idone this. | |
worklog='worklog.txt' | |
if [ $# -eq 0 ]; then | |
# if no arguments are supplied just print the last 10 lines of the log | |
tail $HOME/$worklog | |
exit | |
else | |
# Iterate over arguments and set flags for subsequent actions to be carried out in a specific order | |
for i; do | |
if [[ $i == '-o' ]]; then | |
open_work_log=true | |
elif [[ $i == '-l' ]]; then | |
show_last_line=true | |
elif [[ $i == '-u' ]]; then | |
delete_last_line=true | |
elif [[ $i == '-uv' ]]; then | |
idonethis_uv=true | |
else | |
# everything else is considered the message | |
message+=$i' ' | |
fi | |
done | |
if [[ $delete_last_line = true ]]; then | |
printf "DELETED: " | |
tail -1 $HOME/$worklog | |
sed '$d' < $HOME/$worklog > $HOME/tempworklog.txt; mv $HOME/tempworklog.txt $HOME/$worklog | |
fi | |
if [[ $show_last_line = true ]]; then | |
if hash cowsay 2>/dev/null; then | |
tail -1 $HOME/$worklog | cowsay -f tux | |
else | |
tail -1 $HOME/$worklog | |
fi | |
fi | |
if [[ ! -z $message ]]; then | |
if [[ $idonethis_uv = true ]]; then | |
curl -s -X POST -H "Authorization: Token [token goes here]" -H "Content-Type: application/json" -d '{"team":"https://idonethis.com/api/v0.0/teams/uservoice-VntF/","raw_text":"'"$message"'"}' https://idonethis.com/api/v0.0/dones/ >/dev/null 2>&1 | |
message+='#uservoice' | |
fi | |
now=$(date +"%m-%d-%Y %A %H:%M ") | |
echo $now "|" $message >> $HOME/$worklog | |
if hash cowsay 2>/dev/null; then | |
cowsay $message logged to $HOME/$worklog | |
else | |
echo $message logged to $HOME/$worklog | |
fi | |
fi | |
if [[ $open_work_log = true ]]; then | |
vim + $HOME/$worklog | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment