-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy path_install
executable file
·52 lines (43 loc) · 1.28 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
#!/bin/bash
# This Opens the commands.txt, reads the commands into a single variable (lines) and returns it.
readFile () {
dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
old_IFS=$IFS
IFS=$'\n'
lines=($(cat $dir/'commands.txt'))
IFS=$old_IFS
addCommands
}
# This writes/updates commands to bash_profile.
addCommands () {
echo "🕛 Adding commands..."
# Printing Commands to ~/.bash_profile
echo ' '>>~/.bash_profile
echo "#Lazy_Git_Commands" >>~/.bash_profile
echo ${lines[@]} >>~/.bash_profile
echo ' '>>~/.bash_profile
# Updating ~/.bash_profile
echo "#Ends_here" >>~/.bash_profile
echo "✅ Commands inserted"
source ~/.bash_profile
echo "✅ Bash profile Updated"
# to Open bash profile type 'open ~/.bash_profile'
echo "🙌 Thanks for using lazyGit"
}
# Installation invoker function
beginInstallation () {
echo "🕛 Checking for .bash_profile..."
# Checks for the existance of .bash_profile file
if ! [ -a ~/.bash_profile ];then
touch .bash_profile
echo "✅ File created."
readFile
else
echo "✅ File already exists"
echo "🕛 Removing old commands..."
sed -i '' -e '1h;2,$H;$!d;g' -e 's/#Lazy_Git_Commands.*#Ends_here//g' ~/.bash_profile
readFile
fi
}
#Running Installation
beginInstallation