-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·146 lines (121 loc) · 3.75 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/bin/sh
# Check .config folder exists
# If not, create it
if [ ! -d ~/.config ]; then
mkdir ~/.config
fi
echo "Linking Configuration File"
ln -sf $PWD/.config/nvim ~/.config/nvim
ln -sf $PWD/.config/starship.toml ~/.config/starship.toml
# Link Tmux Configuration
# If .tmux.conf exists, remove it
ln -sf $PWD/.config/tmux/tmux.conf ~/.tmux.conf
if [ ! -d ~/.tmux/plugins/tpm ]; then
mkdir -p ~/.tmux/plugins
fi
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
LAZYGIT_VERSION=$(curl -s "https://api.github.com/repos/jesseduffield/lazygit/releases/latest" | grep -Po '"tag_name": "v\K[^"]*')
echo "Fetching the host system architecture..."
_oss="$(uname -s)"
_cpu="$(uname -m)"
case "$_oss" in
Linux) _oss=Linux ;;
Darwin) _oss=Darwin ;;
MINGW* | MSYS* | CYGWIN*) _oss=Windows ;;
*) err "Error: unsupported operating system: $_oss" ;;
esac
case "$_cpu" in
arm64 | aarch64) _cpu=arm64 ;;
x86_64 | x86-64 | x64 | amd64) _cpu=x86_64 ;;
i686 | i386) _cpu=32-bit ;;
*) err "Error: unsupported CPU architecture: $_cpu" ;;
esac
ARCH="${_oss}_${_cpu}"
echo "Downloading LazyGit"
curl -Lo lazygit.tar.gz "https://github.com/jesseduffield/lazygit/releases/latest/download/lazygit_${LAZYGIT_VERSION}_${ARCH}.tar.gz"
tar xf lazygit.tar.gz lazygit
echo "Installing LazyGit"
if [ $(id -u) -ne 0 ]; then
sudo install lazygit /usr/local/bin
else
install lazygit /usr/local/bin
fi
echo "Remove the redundant lazygit.tar.gz and lazygit"
rm lazygit.tar.gz lazygit
NVIM_ZIP="nvim.tar.gz"
shell_name="$(basename "$SHELL")"
case "$_oss" in
Linux)
case "$_cpu" in
x86_64)
echo "Downlaoding Neovim"
curl -Lo $NVIM_ZIP https://github.com/neovim/neovim/releases/latest/download/nvim-linux64.tar.gz
sudo rm -rf /opt/nvim
sudo tar -C /opt -xzf $NVIM_ZIP
;;
*)
echo "Install Neovim using make"
git clone https://github.com/neovim/neovim
git checkout stable
cd neovim && make CMAKE_BUILD_TYPE=RelWithDebInfo
sudo make install
;;
esac
;;
Darwin)
case "$_cpu" in
arm64)
echo "Downlaoding Neovim"
curl -Lo $NVIM_ZIP https://github.com/neovim/neovim/releases/latest/download/nvim-macos-arm64.tar.gz
sudo rm -rf /opt/nvim
sudo tar -C /opt -xzf $NVIM_ZIP
;;
x86_64)
echo "Downlaoding Neovim"
curl -Lo $NVIM_ZIP https://github.com/neovim/neovim/releases/latest/download/nvim-macos-x86_64.tar.gz
sudo rm -rf /opt/nvim
sudo tar -C /opt -xzf $NVIM_ZIP
;;
*)
echo "Install Neovim using make"
git clone https://github.com/neovim/neovim
git checkout stable
cd neovim && make CMAKE_BUILD_TYPE=RelWithDebInfo
sudo make install
;;
esac
;;
Windows)
echo "Install Neovim using make"
git clone https://github.com/neovim/neovim
git checkout stable
cd neovim && make CMAKE_BUILD_TYPE=RelWithDebInfo
sudo make install
;;
*) err "Error: unsupport OS or CPU architecture for nvim" ;;
esac
rm $NVIM_ZIP
case "$shell_name" in
bash)
config_file=".bashrc"
;;
zsh)
config_file=".zshrc"
;;
*)
echo "Unsupported shell: $shell_name"
exit 1
;;
esac
# Export the current path to the configuration file
echo "export PATH=\"\$PATH:/opt/nvim-linux64/bin\"" >>~/"$config_file"
# Source the configuration file to apply the changes immediately
source ~/"$config_file"
curl -sS https://starship.rs/install.sh | sh
echo "Install Homebrew"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
#echo "Download and Install GCM"
#curl -L https://aka.ms/gcm/linux-install-source.sh | sh
#git-credential-manager configure
#git config --global credential.credentialStore gpg
#rm -rf git-credential-manager