X-Git-Url: https://git.xandkar.net/?a=blobdiff_plain;f=home%2Flib%2Flogin_functions.sh;h=4e99f7f3060d1c317d387e164b571b8456bb18c2;hb=273a0073f3fed3d7ae62283f885f6814df03b68f;hp=3a2120911e0310d689130a052a6866e278d72706;hpb=71c4bf5f878967ad99f34f1559ddc8426e2394a2;p=khome.git diff --git a/home/lib/login_functions.sh b/home/lib/login_functions.sh index 3a21209..4e99f7f 100644 --- a/home/lib/login_functions.sh +++ b/home/lib/login_functions.sh @@ -1,5 +1,31 @@ # +## open : string -> unit +## +## Fork xdg-open so we don't block current terminal session when opening +## things like pdf files. For example: +## +## open book.pdf +## +open() { + (xdg-open "$1" &) & +} + +## notify_done : unit -> unit +notify_done() { + local -r _status_code="$?" + local -r _program="$1" + local _timestamp + _timestamp="$(timestamp)" + local -r _msg="$_timestamp [$_program] done " + if [[ "$_status_code" -eq 0 ]] + then + notify-send -u normal "$_msg OK: $_status_code" + else + notify-send -u critical "$_msg ERROR: $_status_code" + fi +} + ## p : string -> unit p() { awk \ @@ -399,6 +425,59 @@ gh_clone_repo() { git clone "$1" } +bar() { + local -r len="${1:-79}" # 1st arg or 79. + local -r char="${2:--}" # 2nd arg or a dash. + for _ in {1.."$len"}; do + printf '%c' "$char"; + done +} + +daily_todo_file_template() { +cat << EOF +=============================================================================== +$(date '+%F %A') +=============================================================================== + +------------------------------------------------------------------------------- +TO FINISH TODAY +------------------------------------------------------------------------------- + + +------------------------------------------------------------------------------- +CURRENTLY IMPORTANT +------------------------------------------------------------------------------- + + +------------------------------------------------------------------------------- +BLOCKED +------------------------------------------------------------------------------- + + +------------------------------------------------------------------------------- +BACKLOG +------------------------------------------------------------------------------- +EOF +} + +today() { + local date + date="$(date +%F)" + local -r dir="$DIR_TODO/daily" + local -r file="$dir/$date.txt" + + mkdir -p "$dir" + if [ ! -f "$file" ] + then + daily_todo_file_template > "$file" + fi + cd "$DIR_TODO" && "$EDITOR" "$file" +} + +todo() { + cd "$DIR_TODO" && "$EDITOR" TODO +} + work_log_template() { cat << EOF $(date '+%F %A')