-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·141 lines (124 loc) · 3.54 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·141 lines (124 loc) · 3.54 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
#!/bin/bash
RED="\e[31m"
GREEN="\e[32m"
BLUE="\e[34m"
CYAN="\e[36m"
CLEAR="\e[0m"
INFO="${CYAN}[ INFO ]${CLEAR}"
SUCCESS="${GREEN}[ GOOD ]${CLEAR}"
FAILURE="${RED}[ BAD ]${CLEAR}"
UPDATE="${BLUE}[UPDATE]${CLEAR}"
ECHO="echo -e"
function show_usage() {
echo
echo "Usage:"
echo
echo " install.sh [-u]"
echo
echo "If -u is specified, attempt to upgrade existing files. Otherwise, do nothing."
echo
exit 1
}
PATHOGEN_DEST=~/.vim/autoload/pathogen.vim
function install_pathogen() {
mkdir -p ~/.vim/autoload
cp ./vim-plugins/vim-pathogen/autoload/pathogen.vim ${PATHOGEN_DEST}
if [ -a ${PATHOGEN_DEST} ]; then
${ECHO} "${SUCCESS} Pathogen installed."
else
${ECHO} "${FAILURE} Pathogen install failed."
fi
}
DO_UPDATE=0
if [ "$#" -gt "0" ]; then
if [ "$1" != "-u" ]; then
show_usage;
else
DO_UPDATE=1
${ECHO} "${UPDATE} Update mode selected."
fi
fi
SELFDIR=$(dirname $0)
SRCDIR=$(readlink -m ${SELFDIR})
# Jump to script directory for relative paths to files we need
pushd $(dirname $0) > /dev/null
# First, install pathogen if it hasn't been already
if [ -a ${PATHOGEN_DEST} ]; then
${ECHO} "${INFO} pathogen already installed."
if [ "${DO_UPDATE}" -eq "1" ]; then
${ECHO} "${UPDATE} Updating pathogen anyway"
install_pathogen;
fi
else
install_pathogen;
fi
# Next, install vimrc
if [ -a ~/.vimrc ]; then
${ECHO} "${INFO} A .vimrc already exists. You should manually merge .vimrc files."
else
${ECHO} "${INFO} Installing .vimrc."
cp ${SRCDIR}/vimrc ~/.vimrc
if [ -a ~/.vimrc ]; then
${ECHO} "${SUCCESS} .vimrc installed."
else
${ECHO} "${FAILURE} .vimrc could not be created."
fi
fi
# Next, add link to plugins for .vim
if [ -L ~/.vim/vim-plugins ]; then
${ECHO} "${INFO} vim-plugins already linked."
else
${ECHO} "${INFO} Setting up vim-plugins symlink."
ln -s ${SRCDIR}/vim-plugins ~/.vim/vim-plugins
if [ -L ~/.vim/vim-plugins ]; then
${ECHO} "${SUCCESS} vim-plugins linked."
else
${ECHO} "${FAILURE} vim-plugins could not be linked."
fi
fi
# Next, add link to personal scripts for .vim
if [ -L ~/.vim/vim-scripts ]; then
${ECHO} "${INFO} vim-scripts already linked."
else
${ECHO} "${INFO} Setting up vim-scripts symlink."
ln -s ${SRCDIR}/vim-scripts ~/.vim/vim-scripts
if [ -L ~/.vim/vim-scripts ]; then
${ECHO} "${SUCCESS} vim-scripts linked."
else
${ECHO} "${FAILURE} vim-scripts could not be linked."
fi
fi
# Add screenrc
if [ -a ~/.screenrc ]; then
${ECHO} "${INFO} A .screenrc already exists. You should manually merge .screenrc files."
else
${ECHO} "${INFO} Installing .screenrc."
cp ${SRCDIR}/screenrc ~/.screenrc
if [ -a ~/.screenrc ]; then
${ECHO} "${SUCCESS} .screenrc installed."
else
${ECHO} "${FAILURE} .screenrc could not be created."
fi
fi
# Add gitconfig
if [ -a ~/.gitconfig ]; then
${ECHO} "${INFO} A .gitconfig already exists. You should manually merge .gitconfig files."
else
${ECHO} "${INFO} Installing .gitconfig."
cp ${SRCDIR}/_gitconfig ~/.gitconfig
if [ -a ~/.gitconfig ]; then
${ECHO} "${SUCCESS} .gitconfig installed."
else
${ECHO} "${FAILURE} .gitconfig could not be created."
fi
cp ${SRCDIR}/git-credential-helper-pass /usr/libexec/git-core
fi
# Add prompt instructions
$ECHO "${INFO} Add these lines to bashrc in order to set up color prompt:"
${ECHO} " if [[ \${EUID} == 0 ]] ; then"
${ECHO} " PS1+='\\[\\033[01;31m\\][\\u@\\h\\[\\033[01;34m\\] \\w\\[\\033[01;31m\\]]\\\$\\[\\033[00m\\] '"
${ECHO} " else"
${ECHO} " PS1+='\\[\\033[01;32m\\][\\u@\\h\\[\\033[01;34m\\] \\w\\[\\033[01;32m\\]]\\\$\\[\\033[00m\\] '"
${ECHO} " fi"
# Go back to whereever we were called from
popd > /dev/null