-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsetup.sh
executable file
·109 lines (72 loc) · 4 KB
/
setup.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/bin/bash
# ===> Colors ======================================================================================
GREEN="\033[32m"
YELLOW="\033[33m"
ERROR="\033[31m"
NC="\033[0m"
# ==================================================================================================
# ===> Arugments ===================================================================================
for i in "$@"; do
case $i in
--setup-iterm2)
SETUP_ITERM2=true
shift
;;
--setup-alacritty)
SETUP_ALACRITTY=true
shift
;;
*) ;;
esac
done
# ==================================================================================================
TERMINAL_SETUP_LOCAL_DIR="$HOME/.local/terminal-setup/"
TERMINAL_SETUP_LOCAL_BIN_DIR="$TERMINAL_SETUP_LOCAL_DIR/bin"
TERMINAL_SETUP_REPO_BIN_DIR="$(pwd)/bin"
ZPROFILE_SOURCE_REL="dotfiles/.zprofile"
ZPROFILE_SOURCE="$(pwd)/$ZPROFILE_SOURCE_REL"
ZSHRC_SOURCE_REL="dotfiles/.zshrc"
ZSHRC_SOURCE="$(pwd)/$ZSHRC_SOURCE_REL"
ZPREZTORC_SOURCE_REL="dotfiles/.zpreztorc"
ZPREZTORC_SOURCE="$(pwd)/$ZPREZTORC_SOURCE_REL"
P10K_SOURCE_REL="dotfiles/.p10k.zsh"
P10K_SOURCE="$(pwd)/$P10K_SOURCE_REL"
[ ! -d "$TERMINAL_SETUP_REPO_BIN_DIR" ] && echo -e "${ERROR}Directory not found: \"$TERMINAL_SETUP_REPO_BIN_DIR\". You may be in the wrong directory >>> Exit 1${NC}" && exit 1
[ ! -e "$ZPROFILE_SOURCE" ] && echo -e "${ERROR}File not found: \"./$ZPROFILE_SOURCE_REL\". You may be in the wrong directory >>> Exit 1${NC}" && exit 1
[ ! -e "$ZSHRC_SOURCE" ] && echo -e "${ERROR}File not found: \"./$ZSHRC_SOURCE_REL\". You may be in the wrong directory >>> Exit ${NC}" && exit 1
[ ! -e "$ZPREZTORC_SOURCE" ] && echo -e "${ERROR}File not found: \"./$ZPREZTORC_SOURCE_REL\". You may be in the wrong directory >>> Exit 1${NC}" && exit 1
[ ! -e "$P10K_SOURCE" ] && echo -e "${ERROR}File not found: \"./$P10K_SOURCE_REL\". You may be in the wrong directory >>> Exit 1${NC}" && exit 1
chmod 600 "$ZPROFILE_SOURCE"
chmod 600 "$ZSHRC_SOURCE"
chmod 600 "$ZPREZTORC_SOURCE"
chmod 600 "$P10K_SOURCE"
ZPROFILE_FILE="$HOME/.zprofile"
ZSHRC_FILE="$HOME/.zshrc"
ZPRESTORC_FILE="$HOME/.zpreztorc"
P10KZSH_FILE="$HOME/.p10k.zsh"
echo "Check and remove original files and directories..."
echo
[ -e "$ZPROFILE_FILE" ] && rm "$ZPROFILE_FILE" 2>/dev/null && echo -e "${GREEN}Removed original .zprofile${NC}"
[ -e "$ZSHRC_FILE" ] && rm "$ZSHRC_FILE" 2>/dev/null && echo -e "${GREEN}Removed original .zshrc${NC}"
[ -e "$ZPRESTORC_FILE" ] && rm "$ZPRESTORC_FILE" 2>/dev/null && echo -e "${GREEN}Removed original .zpreztorc${NC}"
[ -e "$P10KZSH_FILE" ] && rm "$P10KZSH_FILE" 2>/dev/null && echo -e "${GREEN}Removed original .p10k.zsh${NC}"
[ -d "$TERMINAL_SETUP_LOCAL_BIN_DIR" ] && rm -rf "$TERMINAL_SETUP_LOCAL_BIN_DIR" 2>/dev/null && echo -e "${GREEN}Removed original directory: $TERMINAL_SETUP_LOCAL_BIN_DIR${NC}"
echo
echo "Check and create new symbolic links..."
echo
[ ! -d "$TERMINAL_SETUP_LOCAL_DIR" ] && mkdir -p "$TERMINAL_SETUP_LOCAL_DIR" && echo -e "${GREEN}Created new directory: $TERMINAL_SETUP_LOCAL_DIR${NC}"
ln -s "$TERMINAL_SETUP_REPO_BIN_DIR" "$TERMINAL_SETUP_LOCAL_BIN_DIR" && echo -e "${GREEN}Created a new symbolic link from $TERMINAL_SETUP_LOCAL_BIN_DIR to $TERMINAL_SETUP_REPO_BIN_DIR${NC}"
ln -s "$ZPROFILE_SOURCE" "$ZPROFILE_FILE" && echo -e "${GREEN}Created a new symbolic link from $ZPROFILE_FILE to $ZPROFILE_SOURCE${NC}"
ln -s "$ZSHRC_SOURCE" "$ZSHRC_FILE" && echo -e "${GREEN}Created a new symbolic link from $ZSHRC_FILE to $ZSHRC_SOURCE${NC}"
ln -s "$ZPREZTORC_SOURCE" "$ZPRESTORC_FILE" && echo -e "${GREEN}Created a new symbolic link from $ZPRESTORC_FILE to $ZPREZTORC_SOURCE${NC}"
ln -s "$P10K_SOURCE" "$P10KZSH_FILE" && echo -e "${GREEN}Created a new symbolic link from $P10KZSH_FILE to $P10K_SOURCE${NC}"
if [ "$SETUP_ALACRITTY" = true ]; then
./scripts/setup-alacritty.sh
fi
if [ "$SETUP_ITERM2" = true ]; then
./scripts/setup-iterm2.sh
fi
echo
echo "Setup completed!"
echo
echo -e "${YELLOW}Please restart your terminal or run \`source \$HOME/.zshrc\` to reload .zshrc${NC}"