From d981038d02dcaea1342aec0289651ee174b4ca8a Mon Sep 17 00:00:00 2001 From: Ceda EI Date: Thu, 19 Apr 2018 22:51:34 +0530 Subject: [PATCH] Add initial files mark and markrc Added default markrc and auto login on running it --- mark | 17 +++++++++++++++++ markrc | 3 +++ 2 files changed, 20 insertions(+) create mode 100755 mark create mode 100644 markrc diff --git a/mark b/mark new file mode 100755 index 0000000..6a37caa --- /dev/null +++ b/mark @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +source ~/.markrc +today=$(date +%Y-%m-%d\ %H:%M:%S) +file_path=$base_path/$(date +%Y-%m).txt +login_message=$username $today $login_message + +# Login if it is the first message of the day +if [[ -f $file_path ]]; then + last_line=$(tail -n1 $file_path) + last_day=$(echo $last_line | sed 's/[^ ] [^-]*-[^-]*-\([^ ]*i\).*/\1/') + if [[ $last_day != $(date +%d) ]]; then + echo $login_message >> $file_path + fi +else + echo $login_message >> $file_path +fi diff --git a/markrc b/markrc new file mode 100644 index 0000000..730525f --- /dev/null +++ b/markrc @@ -0,0 +1,3 @@ +base_path="$HOME/mark" +username=$(whoami) +login_message="I am in"