-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup
executable file
·62 lines (50 loc) · 2.13 KB
/
setup
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
#!/bin/bash
USAGE="Installs necessary tools, add some configuration to .bash_profile and sets up github team id which is needed for all operations.\n"
USAGE+="Usage: ./$(basename "$0") \"github team name\"\n"
USAGE+="Example: ./$(basename "$0") \"ConMon\""
[[ "$1" == "help" ]] && { echo -e "$USAGE"; exit 0; }
[[ $# != 1 ]] && { echo -e "$USAGE"; exit 1; } # Show usage when argument count is wrong
brew install gnu-sed
brew install httpie
brew install jq
MY_DIR="$( cd "$(dirname "$0")" ; pwd -P )"
"$MY_DIR/set-team" "$1"
INPUT_VALID=false
until [ "$INPUT_VALID" = true ]
do
read -p "Please enter the directory where you keep your github repos (common cases are ~/git or ~/github or ~/dev):"
eval INPUT=$REPLY # We do this to replace special characters like '~'
if [[ "$INPUT" != "" ]] && [ -d $INPUT ]; then
echo "$INPUT" > "$MY_DIR/root-dir.albert.txt"
INPUT_VALID=true
fi
[ "$INPUT_VALID" = false ] && echo "Given path is invalid. Please try again."
done
# TODO: Refactor the duplications below to a util function
grep -q "alias albert" "$HOME/.bash_profile" 2> /dev/null
if [ $? -ne 0 ]; then
printf "\nsource $MY_DIR/bash_completion\n" >> "$HOME/.bash_profile"
printf "alias albert=\"$MY_DIR/albert\"\n" >> "$HOME/.bash_profile"
echo "Added albert alias/conf to .bash_profile"
else
echo "Skipping .bash_profile because albert alias already exists there"
fi
grep -q "alias albert" ~/.zshrc 2> /dev/null
if [ $? -ne 0 ]; then
printf "\nautoload bashcompinit\n" >> "$HOME/.zshrc"
printf "bashcompinit\n" >> "$HOME/.zshrc"
printf "source $MY_DIR/bash_completion\n" >> "$HOME/.zshrc"
printf "alias albert=\"$MY_DIR/albert\"\n" >> "$HOME/.zshrc"
echo "Added albert alias/conf to .zshrc"
else
echo "Skipping .zshrc because albert alias already exists there"
fi
grep -q "alias albert" ~/.bashrc 2> /dev/null
if [ $? -ne 0 ]; then
printf "\nsource $MY_DIR/bash_completion\n" >> "$HOME/.bashrc"
printf "alias albert=\"$MY_DIR/albert\"\n" >> "$HOME/.bashrc"
echo "Added albert alias/conf to .bashrc"
else
echo "Skipping .bashrc because albert alias already exists there"
fi
exit 0