-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhelpers.sh
More file actions
40 lines (35 loc) · 985 Bytes
/
helpers.sh
File metadata and controls
40 lines (35 loc) · 985 Bytes
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
#!/usr/bin/env bash
function confirm_sudo()
{
if [[ ! $EUID -eq 0 ]]
then
echo "Please run as sudo.\n" >&2
exit 1
fi
}
function get_os()
{
local uname=$(uname)
if [[ $uname == "Linux" ]]; then
os=$(lsb_release -i -s)
elif [[ $uname == "Darwin" ]]; then
os=$uname
else
echo "Unidentified operating system: $uname"
os=NULL
fi
}
function clean_rc_files()
{
string="source $DOTFILES_PATH/setup.sh"
if [ -f $HOME/.bashrc ]; then
grep -v "DOTFILES_PATH=$DOTFILES_PATH" $HOME/.bashrc > bashrc && mv bashrc $HOME/.bashrc
grep -v "source $DOTFILES_PATH/setup.sh" $HOME/.bashrc > bashrc && mv bashrc $HOME/.bashrc
rm bashrc
fi
if [ -f $HOME/.zshrc ]; then
grep -v "DOTFILES_PATH=$DOTFILES_PATH" $HOME/.zshrc > zshrc && mv zshrc $HOME/.zshrc
grep -v "source $DOTFILES_PATH/setup.sh" $HOME/.zshrc > zshrc && mv zshrc $HOME/.zshrc
rm zshrc
fi
}