-
Notifications
You must be signed in to change notification settings - Fork 23
/
install
executable file
·33 lines (28 loc) · 875 Bytes
/
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
#!/bin/bash
tag="###chen3feng-devenv###"
this_dir="$(cd $(dirname $0) && pwd)"
install() {
local command="$1"
local from="$this_dir/$2"
local to="$3"
local comment="$4 $tag"
local stmt="$command $from"
if [ -e $to ] && grep "$comment" "$to" > /dev/null; then
# Find the tag line
local lineno=$(grep -n -m1 "$comment" "$to" | cut -f1 -d:)
let lineno++
sed -i "${lineno}s|.*|$stmt|g" $to # Replace next line of tag line
else
echo "$comment" >> $to
echo "$stmt" >> $to
fi
echo "$to is updated."
}
install source _bashrc ~/.bashrc "#"
install source _zshrc ~/.zshrc "#"
install source _vimrc ~/.vimrc '"'
install "\$include" _inputrc ~/.inputrc "#"
$this_dir/git/install
# Install the `vim-plug` plug manager
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim