Repository navigation
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·152 lines (121 loc) · 3.85 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·152 lines (121 loc) · 3.85 KB
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
147
148
149
150
151
152
#!/bin/bash
# A script to setup my development environment which consists of zsh, neovim, gitconfig, and tmux. Feel free to use it.
# Install Dependencies.
# On Debian based OSs.
if [ -x "$(command -v apt-get)" ]; then
# Installing dependencies for Debian based OS.
sudo apt-get install -y fzf tmux neovim python3-neovim git ctags ripgrep
fi
# On Arch Linux based OSs.
if [ -x "$(command -v pacman)" ]; then
# Installing dependencies for Arch based OS.
sudo pacman -S --noconfirm fzf tmux neovim python-pynvim git ctags ripgrep powerline go-task
fi
# On Mac
if [ -x "$(command -v brew)" ]; then
# Installing dependencies for Mac.
brew install fzf tmux neovim git ctags ripgrep go-task
fi
if ! [ -x "$(command -v fzf)" ]; then
echo "Error: fzf is not installed." >&2
exit 1
fi
if ! [ -x "$(command -v tmux)" ]; then
echo "Error: tmux is not installed." >&2
exit 1
fi
if ! [ -x "$(command -v nvim)" ]; then
echo "Error: neovim is not installed." >&2
exit 1
fi
if ! [ -x "$(command -v git)" ]; then
echo "Error: git is not installed." >&2
exit 1
fi
if ! [ -x "$(command -v ctags)" ]; then
echo "Error: ctags is not installed." >&2
exit 1
fi
if [[ "$SHELL" != */zsh ]]; then
echo "You have to be using zsh before running this command"
exit 1
fi
dir="${1:-$(cd "$(dirname "$0")/.." && pwd)}"
if [ ! -d "$dir" ]
then
echo "Directory $dir does not exist." >&2
exit 1
fi
# Setup zsh.
cd "$dir" || exit 1
if [ ! -d "oh-my-zsh" ]; then
git clone https://github.com/vim345/oh-my-zsh.git
fi
mkdir -p "$dir/oh-my-zsh/custom/plugins" "$dir/oh-my-zsh/custom/themes"
cd "$dir/oh-my-zsh/custom" || exit 1
if [ ! -d "themes/.git" ] && [ ! -f "themes/mhmd.zsh-theme" ]; then
git clone https://github.com/vim345/themes.git
fi
cd "$dir/oh-my-zsh/custom/plugins" || exit 1
if [ ! -d "mhmdzsh" ]; then
git clone https://github.com/vim345/mhmdzsh.git
fi
if [ ! -d "zsh-autosuggestions" ]; then
git clone https://github.com/zsh-users/zsh-autosuggestions.git
fi
if [ ! -d "zsh-syntax-highlighting" ]; then
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
fi
if [ -f "$HOME/.zshrc" ] && grep -q "export ZSH=$dir/oh-my-zsh" "$HOME/.zshrc" 2>/dev/null; then
echo "Not setting zsh env variables anymore."
else
echo "export ZSH=$dir/oh-my-zsh" >> "$HOME/.zshrc"
echo "source \$ZSH/base.sh" >> "$HOME/.zshrc"
fi
mkdir -p "$HOME/.cache/zsh/"
# Setup nvim environment now.
if command -v python3 &>/dev/null; then
python3 -m pip install --user pynvim neovim 2>/dev/null || true
elif command -v pip3 &>/dev/null; then
pip3 install --user pynvim neovim 2>/dev/null || true
elif command -v pip &>/dev/null; then
pip install --user pynvim neovim 2>/dev/null || true
fi
config_dir="$HOME/.config"
if [[ ! -e "$config_dir" ]]; then
mkdir -p "$config_dir"
fi
if [ ! -d "$config_dir/nvim" ]; then
git clone https://github.com/vim345/nvim.git "$config_dir/nvim"
fi
nvim --headless "+Lazy! sync" +qa
# Setup tmux
cd "$dir" || exit 1
if [ ! -d "tmux" ]; then
git clone https://github.com/vim345/tmux.git
fi
if [ ! -d "tmux/plugins/tpm" ]; then
git clone https://github.com/tmux-plugins/tpm.git "tmux/plugins/tpm"
fi
mkdir -p "$HOME/.tmux/plugins"
if [ ! -e "$HOME/.tmux/plugins/tpm" ]; then
ln -sf "$dir/tmux/plugins/tpm" "$HOME/.tmux/plugins/tpm"
fi
TMUX_FILE="$HOME/.tmux.conf"
if test -f "$TMUX_FILE"; then
if grep -q "source $dir/tmux/tmux.conf" "$TMUX_FILE" 2>/dev/null; then
echo "Not setting tmux config anymore."
else
echo "source $dir/tmux/tmux.conf" >> "$TMUX_FILE"
fi
else
echo "source $dir/tmux/tmux.conf" > "$TMUX_FILE"
fi
TMUX_PLUGIN_MANAGER_PATH="$HOME/.tmux/plugins/" "$dir/tmux/plugins/tpm/bin/install_plugins" 2>/dev/null || true
# Setup gitconfig
cd "$dir" || exit 1
if [ ! -d "gitconfig" ]; then
git clone https://github.com/vim345/gitconfig.git
fi
ln -sf "$dir/gitconfig/.gitconfig" "$HOME/.gitconfig"
echo "Environment setup complete!"