-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathinstall
executable file
·67 lines (50 loc) · 1.72 KB
/
install
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
#!/usr/bin/env bash
usrDir=${usrDir:-/usr/local/bin}
if [[ ! $(which npm 2>/dev/null) ]]; then
printf "npm is required and not found. Download it then retry" | chalk red
fi
#Terminal coloring library
if [[ ! $(which chalk 2>/dev/null) ]]; then
printf "\nDownloading chalk (Terminal coloring library)...\n"
npm install --global chalk-cli
fi
printf "\n"
#If root's vimrc does not exist
if [[ ! $(ls -A $HOME/.vimrc 2>/dev/null) ]]; then
printf "We could not find a .vimrc for you so we made one up!\n"
touch $HOME/.vimrc
printf "\"Swim example vimrc file
set number" > $HOME/.vimrc
else
printf "Looks like you already have a vimrc. Let's alias that to main\n\n" | chalk yellow
fi
#If swim directory does not exist
if [ ! -d "$HOME/.swim" ]; then
#Download the primary swim script
curl -o $usrDir/swim -s https://raw.githubusercontent.com/dawsonbotsford/swim/master/swim
#Add swim to path
chmod +x $usrDir/swim
mkdir -p $HOME/.swim
cp $HOME/.vimrc $HOME/.swim/main.vim
printf "calling \"swim add $HOME/.vimrc main\"\n"
swim add $HOME/.vimrc main
printf "\nInstall complete!\n\n" | chalk green
swim version
else
printf "Swim already downloaded!\n\n" | chalk green
swim update
printf "\nYou have the following swim aliases: \n"
printf "%s\n" "--------------------------" | chalk white
for file in $HOME/.swim/*
do
alias=$(echo $file | cut -d / -f 5 | cut -d . -f 1)
#chalk active with green, default otherwise
if [[ $(readlink ~/.vimrc | cut -d / -f 5 | cut -d . -f 1) == $alias ]]; then
printf "> "$alias" (active)\n" | chalk green
else
printf $alias"\n"
fi
done
printf "%s\n" "--------------------------" | chalk white
fi
printf "try \"swim ls\"" | chalk yellow