-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.sh
executable file
·91 lines (77 loc) · 2.25 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/usr/bin/env bash
# shellcheck disable=SC2164,SC2016
WORKSPACE="$HOME/.development-tools"
mkdir -p "$WORKSPACE"
KIT_PATH="$WORKSPACE/development-kit"
DEPENDENCIES="$WORKSPACE/.dependencies"
mkdir -p "$DEPENDENCIES"
SHELL_DEPENDENCIES="$DEPENDENCIES/shell"
mkdir -p "$SHELL_DEPENDENCIES"
# Main Shell script resources
MAIN="$SHELL_DEPENDENCIES/main"
# PATH variables
SHELL_PATHS="$SHELL_DEPENDENCIES/paths"
# ALIASES
ALIASES="$SHELL_DEPENDENCIES/aliases"
# env
ENV_PATH="$SHELL_DEPENDENCIES/env"
cd "$WORKSPACE"
SHELL_RC="$HOME/.bashrc"
if [[ -f "$HOME/.zshrc" ]]; then
SHELL_RC="$HOME/.zshrc"
elif [[ -f "$HOME/.profile" ]]; then
SHELL_RC="$HOME/.profile"
elif [[ -f "$HOME/.bash_profile" ]]; then
SHELL_RC="$HOME/.bash_profile"
fi
if [[ -d "$KIT_PATH" ]]; then
cd "$KIT_PATH"
git checkout .
git checkout main
git pull
echo "Please run the following command
source $SHELL_RC"
else
git clone https://github.com/FirzenYogesh/development-kit.git
# Setup
# Main
{
echo "source $ENV_PATH
source $SHELL_PATHS
source $ALIASES"
} >> "$MAIN"
# Setup Paths
{
echo 'export PATH="$PATH":"$DEVELOPMENT_KIT_HOME/development-kit"'
echo 'export PATH="$PATH":"$DEVELOPMENT_KIT_EXECUTABLES"'
} >> "$SHELL_PATHS"
# Setup Aliases
{
echo 'alias cl="clear"'
echo 'alias gs="git status"'
echo 'alias gd="git diff"'
echo 'alias gc="git checkout"'
echo 'alias gpoh="git push origin HEAD"'
} >> "$ALIASES"
# Setup env
{
echo "export DEVELOPMENT_KIT_HOME=$WORKSPACE
export DEVELOPMENT_KIT_SDK_HOME=$WORKSPACE/sdk
export DEVELOPMENT_KIT_DB_HOME=$WORKSPACE/db
export DEVELOPMENT_KIT_EXECUTABLES=$WORKSPACE/executables
export DEVELOPMENT_KIT_ALIASES=$ALIASES
export DEVELOPMENT_KIT_ENV=$ENV_PATH
export DEVELOPMENT_KIT_PATHS=$SHELL_PATHS
export DEVELOPMENT_KIT_MAIN=$MAIN"
} >> "$ENV_PATH"
# Add to the shell
echo "# Setup by development-kit
# Check https://github.com/FirzenYogesh/development-kit to know more
source $MAIN
# End of development-kit Setup" >> "$SHELL_RC"
echo "Please run the following command
source $SHELL_RC"
fi
# auto reload current shell
# shellcheck disable=SC2086,SC2015
[[ -n "$SHELL" ]] && exec ${SHELL#-} || exec zsh