-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·74 lines (65 loc) · 1.86 KB
/
setup.sh
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
#!/bin/bash
set_git_config() {
local gitconfig=$1
local key=$2
local prompt=$3
git config -f $gitconfig --get $key >/dev/null
if [[ $? -ne 0 ]]; then
read -p $prompt VAL
git config -f $gitconfig --add $key "$VAL"
fi
}
# go home
pushd $HOME
# homedir files
home_files=(.bash_aliases .bash_exports .bash_functions .bash_profile .bashrc \
.bash_settings .inputrc .vimrc .xmobarrc .xmobarrc-laptop .Xresources \
.zsh_aliases .zsh_exports .zsh_functions .zsh_plugins .zshrc .zsh_settings \
git-prompt.sh .gitconfig .ripgreprc)
for f in "${home_files[@]}"
do
if [[ -e $f ]]; then
diff $f dots/$f > /dev/null
if [[ $? != 0 ]]; then
cp $f $f.old
fi
fi
ln -sf dots/$f
done
# Set up local gitconfig if it doesn't exist already
LOCAL_GITCONFIG=$HOME/.gitconfig_local
set_git_config $LOCAL_GITCONFIG user.name "Name: "
set_git_config $LOCAL_GITCONFIG user.email "Email: "
mkdir -p .zsh
ln -sf $HOME/dots/.zsh/completion .zsh/
ln -sf $HOME/dots/.zsh/functions .zsh/
ln -sf $HOME/dots/.zsh/plugins .zsh/
# xmonad files
if [[ -e .xmonad/xmonad.hs ]]; then
diff .xmonad/xmonad.hs dots/.xmonad/xmonad.hs > /dev/null
if [[ $? != 0 ]]; then
cp .xmonad/xmonad.hs .xmonad/xmonad.hs.old
fi
fi
mkdir -p .xmonad
ln -sf $HOME/dots/.xmonad/xmonad.hs .xmonad/xmonad.hs
# vim files
vim_files=(colors ftdetect ftplugin functions mappings settings syntax)
mkdir -p .vim
for f in "${vim_files[@]}"
do
if [[ -d .vim/$f ]]; then
mv .vim/$f .vim/$f.old
fi
if [[ -e .vim/$f ]]; then
diff .vim/$f dots/.vim/$f > /dev/null
if [[ $? != 0 ]]; then
cp .vim/$f .vim/$f.old
fi
fi
ln -sf $HOME/dots/.vim/$f .vim/$f
done
mkdir -p .vim/autoload
ln -sf $HOME/dots/vim-pathogen/autoload/pathogen.vim .vim/autoload
ln -sf $HOME/dots/.vim/bundle .vim/
popd