-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall
56 lines (48 loc) · 2.05 KB
/
install
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
#!/bin/bash
## Bash Timer
## https://github.com/hopeseekr/bash-timer/
## https://github.com/hopeseekr/BashScripts/
##
## Copyright © 2020-2024 Theodore R. Smith <[email protected]>
# Pull down our file from GitHub and write it to our home directory as a hidden file.
curl https://raw.githubusercontent.com/hopeseekr/bash-timer/v1.5.0/bash-timer.sh -o $HOME/.bash-timer.sh
if [ $(builtin type -P "sha256sum" 2>&1) ]; then
echo "c9cf58a86712eb7360e08a072d03e53548e5e362944ab651aa71ee2a7846d22f $HOME/.bash-timer.sh" | sha256sum -c -
if [ $? -ne 0 ]; then
rm -v ~/.bash-timer.sh
echo ERROR!! Invalid shasum for .bash-timer.sh !!
echo ERROR!! It has been deleted. Please grab from https://github.com/hopeseekr/bash-timer/
exit 1
fi
fi
if [ ! -f ~/.bash-preexec.sh ]; then
curl https://raw.githubusercontent.com/hopeseekr/bash-timer/v1.5.0/assets/bash-preexec.sh -o $HOME/.bash-preexec.sh
if [ $(builtin type -P "sha256sum" 2>&1) ]; then
echo "d512aa6043d69d636f0db711aab1675cc7c49b39da9ae58afcfb916dca8c4464 $HOME/.bash-preexec.sh" | sha256sum -c -
if [ $? -ne 0 ]; then
rm -v ~/.bash-preexec.sh
echo ERROR!! Invalid shasum for .bash-preexec.sh !!
echo ERROR!! It has been deleted. Please grab from https://github.com/hopeseekr/bash-timer/
exit 2
fi
fi
fi
if [ ! -f "${HOME}/.bashrc" ]; then
echo "ERROR: Could not find ~/.bashrc. You need to do a manual installation."
echo "See https://github.com/hopeseekr/bash-timer"
exit 3
fi
# Heredoc concatenation: https://stackoverflow.com/a/2954835/430062
cat << EOF >> "${HOME}/.bashrc"
# Bash Timer
# See https://github.com/hopeseekr/bash-timer
[[ -f ~/.bash-timer.sh ]] && source ~/.bash-timer.sh
# See https://github.com/rcaloras/bash-preexec
# **WARNING:** This must be the last line of your .bashrc.
# Source our file at the end of our bash profile (e.g. ~/.bashrc, ~/.profile, or ~/.bash_profile)
[[ -f ~/.bash-preexec.sh ]] && source ~/.bash-preexec.sh
EOF
echo "Install succeeded!"
echo
echo "Now run"
echo " source ~/.bashrc"