alias / functions for managing my time off

This commit is contained in:
MorganGeek 2020-07-06 20:03:34 +02:00
parent 7d707dad27
commit d6ea09d5a5
2 changed files with 35 additions and 2 deletions

View File

@ -14,6 +14,7 @@ alias goto='git go'
alias master='goto master'
alias develop='goto develop'
alias gg='git config -l | grep -i' # search git config for ...
alias ucommit='PRE_COMMIT_ALLOW_NO_CONFIG=1 git commit'
# Docker
alias lzd='lazydocker'
@ -40,7 +41,6 @@ alias me='mb'
alias j='jira issue open'
alias trello='3llo'
alias work='moro'
alias endofday='moro status 2>&1 | \grep -Eo "Working until ([0-9:]+) will make.*" | uniq | \grep -Eo "([0-9]+:[0-9]+)"'
# News
alias hack='hacker'
@ -115,6 +115,7 @@ alias h='cd $HOME'
alias cp='cp -i' # confirmation before overwrite #
alias del='rm -rf'
alias mv='mv -i' # confirmation before overwrite
alias mkcd='take'
alias rm='gomi'
alias df='df -H'
alias diff='colordiff --side-by-side --ignore-space-change --width=200 --suppress-common-lines --recursive'
@ -168,6 +169,7 @@ alias p='ps -ef | grep -i ' # Show matching processes. Usage : p <proces
alias root='sudo -i'
alias ':q'='exit'
alias current_hour='date +"%H:%M"'
alias current_time='current_hour'
# Linters
alias checken="aspell check -d en"

View File

@ -381,3 +381,34 @@ function backupgithub {
function take {
mkdir -p $@ && cd ${@:$#}
}
function endofday {
local planned_end=$(moro status 2>&1 | \grep -Eo "Working until ([0-9:]+) will make.*" | uniq | \grep -Eo "([0-9]+:[0-9]+)")
local max_hour="$planned_end"
local min_hour=`current_time`
if [ -z "$planned_end" ]; then
local clockout=$(moro report 2>&1 | \grep -Eo "Clock out.*([0-9:]+)" | \grep -Eo "([0-9]+:[0-9]+)")
max_hour="$clockout"
fi
if is_earlier "$min_hour" "$max_hour"; then
arrow "you should keep working, it's only $min_hour while you should work until $max_hour"
moro status
else
warning "you should stop working now because it's later than $max_hour"
moro report
fi
}
function convtimetodate {
date -j -f '%H:%M' "$1" +'%Y/%m/%d %H:%M'
}
function convtimetotimestamp {
date -j -f '%H:%M' "$1" +'%s'
}
function is_earlier {
local first=$(convtimetotimestamp "$1")
local second=$(convtimetotimestamp "$2")
if [ "$second" -gt "$first" ]; then
true
else
false
fi
}