This repository has been archived by the owner on Dec 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.sh
executable file
·66 lines (55 loc) · 2.78 KB
/
install.sh
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
65
#!/bin/bash
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 foldmethod=marker
# ----------------------------------------------------------------------------
# Author: Mubarak Alrashidi (DeaDSouL)
# Package: dsBash
# Info: Setting up your bash environment
# License: GNU/GPL v3
# URL: https://gitlab.com/DeaDSouL/dsBash
# ----------------------------------------------------------------------------
# .bash_profile --> This is the first file to be checked in MacOS.
# .profile -------> This is the first file to be checked in Linux.
# .bashrc --------> This is the configuration file for bash.
# .bash_profile <- .profile <- .bashrc <- dsBash/bashrc
# ---------------------------------------------------------------------
echo 'Installing dsBash,...'
# ---------------------------------------------------------------------
# getting the real script's directory
# source: http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
TARGET="$(readlink "$SOURCE")"
if [[ $TARGET == /* ]]; then
#echo "SOURCE '$SOURCE' is an absolute symlink to '$TARGET'"
SOURCE="$TARGET"
else
DSBASHDIR="$( dirname "$SOURCE" )"
#echo "SOURCE '$SOURCE' is a relative symlink to '$TARGET' (relative to '$DSBASHDIR')"
SOURCE="$DSBASHDIR/$TARGET" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
fi
done
#echo "SOURCE is '$SOURCE'"
#RDIR="$( dirname "$SOURCE" )"
DSBASHDIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
#if [ "$DSBASHDIR" != "$RDIR" ]; then
# echo "DIR '$RDIR' resolves to '$DSBASHDIR'"
#fi
#echo "DIR is '$DSBASHDIR'"
# ---------------------------------------------------------------------
_BASH_PROFILE_CMD='[[ -f ~/.profile ]] && source ~/.profile;'
_PROFILE_CMD='[[ -f ~/.bashrc ]] && source ~/.bashrc;'
_DSBASHRC_CMD="[[ -f '${DSBASHDIR}/bashrc' ]] && source '${DSBASHDIR}/bashrc';"
# ---------------------------------------------------------------------
grep -l "$_BASH_PROFILE_CMD" ~/.bash_profile > /dev/null 2>&1 || echo "$_BASH_PROFILE_CMD" >> ~/.bash_profile
grep -l "$_PROFILE_CMD" ~/.profile > /dev/null 2>&1 || echo "$_PROFILE_CMD" >> ~/.profile
grep -l "$_DSBASHRC_CMD" ~/.bashrc > /dev/null 2>&1 || echo "$_DSBASHRC_CMD" >> ~/.bashrc
# ---------------------------------------------------------------------
# @TODO: fixing the requirement of logout and login of user!!
source ~/.bash_profile
echo -e "${BBLUE}dsBash${NC} ${FG}was installed successfullyi !"
echo ''
echo -e "${FG}The current loaded aliases:"
ds.alias_loaded
echo ''
echo -e "${FG}To see the available aliases, try:${NC} ${BLUE}ds.alias_all"
echo -e "${FG}Enjoy${NC} ${YELLOW}:)"