-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenv_setup.sh
More file actions
executable file
·139 lines (124 loc) · 3.54 KB
/
env_setup.sh
File metadata and controls
executable file
·139 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
#!/bin/bash
unameOut="$(uname -s)"
case "${unameOut}" in
Linux*) machine=Linux;;
Darwin*) machine=Mac;;
CYGWIN*) machine=Cygwin;;
MINGW*) machine=MinGw;;
*) machine="UNKNOWN:${unameOut}"
esac
echo "machine: $machine"
# exit
if [ ! -x /usr/bin/git ] ; then
echo "Error: Git not installed.\nPlease install git and run again.";
exit 1;
fi
while getops ":d:b:f:" opt; do
case $opt in
:)
echo "option -$OPTARG requires arg" >&2
;;
d)
echo "DOTFILES being set to '$DOTFILES'"
DOTFILES=$OPTARG
;;
b)
echo "BACKUP being set to '$OPTARG'"
BACKUP=$OPTARG
;;
i)
echo "ignore filenames being set from file '$OPTARG'"
filenames=$(cat $OPTARG)
echo "filenames set to '$filenames'"
;;
h)
echo "home being set to '$OPTARG'"
HOMEdir=$OPTARG
;;
/?)
echo "Invalid Flag '-$OPTARG'"
exit 1
;;
esac
done
# TODO option here to set home
HOMEdir=$HOME
DOTFILES="$HOMEdir/dot_files/"
# TODO option here to set backup dir
BACKUP="$HOMEdir/Dot_file_backup_$(date +%Y-%m-%d_%H:%M:%S)/";
# mkdir $BACKUP;
# TODO option here to set ignore files
echo "DOTFILES: $DOTFILES"
echo "BACKUP: $BACKUP"
echo "HOMENAME: $HOMENAME"
echo "FILENAMES: $FILENAMES"
# ---- Main Copy ----
# git clone https://github.com/Richard-Lynch/dot_files.git
# FILENAMES="$(cd ; cd dot_files/ ; \ls -AI .git)" # linux
FILENAMES="$(cd ; cd dot_files/ ; \ls -A | grep -v '.git')" # mac
echo $FILENAMES
mkdir $BACKUP;
for file in $FILENAMES; do
newFile="$DOTFILES$file"
oldFile="$HOME/$file"
if [ -w "$oldFile" ] ; then # || [ -d "$oldFile" ] ; then
echo "Making backup of \"$oldFile\" in \"$newFile\""
mv $oldFile $BACKUP
else
echo "file \"$oldFile\" doesnt exist"
fi
echo "Copying \"$newFile\" to \"$oldFile\""
# TODO should probably be git mv so that the files are still tracked?
cp -r $newFile $oldFile
done
# ---- Vim ----
echo "doing vim"
ln -s ~/.vim/vimrc ./.vimrc
mkdir -p ~/.vim/.backups ;
mkdir -p ~/.vim/.swaps ;
mkdir -p ~/.vim/.undo ;
cd .vim ;
# clone vundle
mkdir ./bundle
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim ;
vim +PluginInstall +qall ;
#edit showMarks
showMarksFile="$HOME/.vim/bundle/ShowMarks/plugin/showmarks.vim" ;
if [ -f $showMarksFile ] ; then
orig="exe 'sign place '.id.' name=ShowMark'.nm.' line='.ln.' buffer='.winbufnr(0)"
newl="\
\" changed by Richard Lynch edits file \n\
if ln > 0 \n\
exe 'sign place '.id.' name=ShowMark'.nm.' line='.ln.' buffer='.winbufnr(0)\n\
endif\n\
\" end of change by Richard Lynch\
"
sed -e "s/$orig/$newl/" $showMarksFile > ./tempChangeLineFile ;
cp $showMarksFile $showMarksFile.bac_$(date +%Y-%m-%d_%H:%M:%S) ;
mv ./tempChangeLineFile $showMarksFile ;
else
echo "ShowMarks file not found!"
echo $showMarksFile
fi
# youcompleteme
case "${unameOut}" in
Linux*)
machine=Linux
sudo apt-get install build-essential cmake
sudo apt-get install python-dev python3-dev
;;
Darwin*)
machine=Mac
brew install python
brew install python3
brew install cmake
;;
*)
echo "unknown machine, not compiling ycm"
exit
;;
esac
cd ~/.vim/bundle/YouCompleteMe
./install.py --clang-completer
mv $DOTFILES/.git $HOMEdir/
# git add $FILENAMES