-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·121 lines (93 loc) · 3 KB
/
setup.sh
File metadata and controls
executable file
·121 lines (93 loc) · 3 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
#!/usr/bin/env bash
# Set CONFIGDIR to directory of this script
export CONFIGDIR=$(realpath $(dirname $0))
echo "Detected CONFIGDIR=$CONFIGDIR"
echo
# Create zshrc
if [[ -f ~/.zshrc ]]; then
echo "Found existing ~/.zshrc"
echo 'Make sure the CONFIGDIR environment variable is defined and' \
'exported, and $CONFIGDIR/zsh/zshrc is sourced'
# rm ~/.zshrc
# echo "Deleted existing ~/.zshrc"
else
echo "~/.zshrc does not exist"
echo "export CONFIGDIR=$CONFIGDIR" >> ~/.zshrc
echo 'source $CONFIGDIR/zsh/zshrc' >> ~/.zshrc
echo "Created default ~/.zshrc with CONFIGDIR=$CONFIGDIR"
fi
echo
# Create vanilla vimrc
if [[ -f ~/.vimrc ]]; then
rm ~/.vimrc
echo "Deleted existing ~/.vimrc"
fi
echo 'let &rtp = $CONFIGDIR . "/vim" . "," . &rtp . "," . $CONFIGDIR . "/vim/after"' >> ~/.vimrc
echo 'source $CONFIGDIR/vim/vimrc' >> ~/.vimrc
echo "Created ~/.vimrc"
echo
# Create neovim vimrc
if [[ -f ~/.config/nvim/init.vim ]]; then
rm ~/.config/nvim/init.vim
echo "Deleted existing ~/.config/nvim/init.vim"
fi
if [[ ! -d ~/.config/nvim ]]; then
mkdir -p ~/.config/nvim
fi
echo 'let &rtp = $CONFIGDIR . "/vim" . "," . &rtp . "," . $CONFIGDIR . "/vim/after"' >> ~/.config/nvim/init.vim
echo 'source $CONFIGDIR/vim/vimrc' >> ~/.config/nvim/init.vim
echo "Created ~/.config/nvim/init.vim"
echo
# Symlink .tmux.conf
if [[ -e ~/.tmux.conf ]] || [[ -L ~/.tmux.conf ]]; then
rm ~/.tmux.conf
echo "Deleted existing ~/.tmux.conf"
fi
/usr/bin/env ln -s $CONFIGDIR/tmux/tmux.conf ~/.tmux.conf
echo "Created symlink ~/.tmux.conf -> $CONFIGDIR/tmux/tmux.conf"
echo "You still need to manually fire up tmux and type <Ctrl-A>-I to download plug-ins"
echo
# Download fzf if not already downloaded
if [[ -f $CONFIGDIR/fzf/bin/fzf ]]; then
echo "fzf installation already exists at $CONFIGDIR/fzf"
else
rm -rf $CONFIGDIR/fzf 2> /dev/null
echo "Downloading fzf to $CONFIGDIR/fzf"
git clone --depth 1 https://github.com/junegunn/fzf.git $CONFIGDIR/fzf
echo
echo "Installing fzf binary"
$CONFIGDIR/fzf/install --bin
fi
echo
# Download zplug if not already downloaded
ZPLUG_HOME=$CONFIGDIR/zsh/zplug
if [[ ! -f $ZPLUG_HOME/init.zsh ]]; then
echo "Downloading zplug to $ZPLUG_HOME"
git clone https://github.com/zplug/zplug $CONFIGDIR/zsh/zplug
echo "Downloaded zplug"
else
echo "Detected zplug installation at $ZPLUG_HOME"
fi
echo
# Install zsh plugins
echo "Installing zsh plugins"
source $CONFIGDIR/zsh/zshplugins.sh
zplug install
echo
# Download vim-plug if not already downloaded
VIMPLUG_FILE=$CONFIGDIR/vim/autoload/plug.vim
if [[ ! -f $VIMPLUG_FILE ]]; then
echo "Downloading vimplug to $VIMPLUG_FILE"
curl -fLo $VIMPLUG_FILE --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
echo "Downloaded vimplug"
else
echo "Detected vimplug installation at $VIMPLUG_FILE"
fi
echo
# Run :PlugInstall within vim
echo "Installing vim plugins"
/usr/bin/env vim +PlugInstall +qa!
echo
# Finally, load zshrc
source ~/.zshrc