-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.bash_profile
65 lines (54 loc) · 1.85 KB
/
.bash_profile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# shellcheck shell=bash
#
# ~/.bash_profile (macOS)
#
# Bash startup file for interactive login shells.
# So basically I gather that you ought to use this startup
# script to hold extra commands that you'd want only login
# shells specifically to run in addition to everything in
# .bashrc (by sourcing ~/.bashrc from here also).
#
# Neel Yadav
# 06.29.2021
# Most of this stuff is basically just potential examples or
# placeholders for legit usage and/or personal referrence in
# the future. No reason (currently) to use on personal macbook.
# This is cute but pointless
localtime=$(( 10#$(date +%-H%M) ))
greetings="Welcome back"
if [[ ! $(logname) == $(id -u -n) ]]; then
_user="\e[1;34m$(id -u -n) \e[0;3;2m($(logname))\e[0m"
else
_user="\e[1;34m$(id -u -n)\e[0m"
fi
if [[ $localtime -lt 430 ]]; then
greetings="🛌 Getting awfully late"
message="You humans ought not sacrafice sleep"
elif [[ $localtime -le 800 ]]; then
greetings="🐓 You're up early"
elif [[ $localtime -lt 1230 ]]; then
greetings="🌞 Good morning"
elif [[ $localtime -lt 1700 ]]; then
greetings="👁 👁 Good afternoon"
else
greetings="🌜 Good evening"
fi
echo -e "\e[1m$greetings, $_user"
[[ -n $message ]] && echo -e "$message"
# Remote logins via SSH display user's source IP address
if [[ -n $SSH_CLIENT ]]; then
remote_login="$(echo $SSH_CLIENT | sed -n -E 's/^(.*) [0-9]+ [0-9]+/\1/p')"
echo -e "Logging in remotely from ${remote_login}"
fi
# You have mail
if [[ -n $(cat /var/mail/$(logname) 2> /dev/null) ]]; then
printf " ✉️ \e[3mYou've got mail\e[0m "
if [[ $(grep --count "Subject:" /var/mail/$(logname)) -gt 1 ]]; then
printf "[$(grep --count "Subject:" /var/mail/$(logname))]\n"
else
printf "\n"
fi
fi
echo ""
# Source non-login startup commands as well
[ -r ~/.bashrc ] && . ~/.bashrc