-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·82 lines (67 loc) · 1.83 KB
/
setup.sh
File metadata and controls
executable file
·82 lines (67 loc) · 1.83 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
#!/bin/bash
usage () {
cat <<- EOF
echo $PROGNAME [1]
if '1' is passed as argument, then the original vimrc and
zshrc (with plugins) will be copied.
it requires the following:
- fzf
- oh-my-zsh
- oh-my-zsh/custom/zsh-syntax-highlighting
- vundle
EOF
}
backup_if_exists () {
if [ -f $1 ];
then
mv $1 $BACKUPDIR
fi
if [ -d $1 ];
then
mv $1 $BACKUPDIR
fi
}
COMPLETE=0
while [[ -n "$1" ]]; do
case "$1" in
1) COMPLETE=1
;;
-h | --help) usage
exit
;;
esac
shift
done
SCRIPT_DIR=$(dirname $(readlink -f $0)) # returns the absolute path of this script
BACKUPDIR=dotfile.backup
mkdir $BACKUPDIR
backup_if_exists ~/.bashrc
backup_if_exists ~/.gitconfig
backup_if_exists ~/.inputrc
backup_if_exists ~/.vimrc
backup_if_exists ~/.zshrc
mkdir -p ~/.vim/undodir
mkdir -p ~/.vim/backup
files=(bashrc gitconfig inputrc)
if [[ $COMPLETE == 1 ]]; then
files+=(vimrc zshrc)
else
files+=(vimrc-min zshrc-min)
fi
for f in ${files[@]}; do
ln -s ${SCRIPT_DIR}/${f} ~/.${f}
echo "creating symlink for ${f}"
done
if [[ $COMPLETE != 1 ]]; then
mv ~/.vimrc-min ~/.vimrc
mv ~/.zshrc-min ~/.zshrc
fi
gpg ${SCRIPT_DIR}/ssh.config.gpg # decrypt the ssh config file
[[ ! -d "$HOME/.ssh" ]] && mkdir ~/.ssh # create the .ssh directory if it does not exist
ln -s ${SCRIPT_DIR}/ssh.config ~/.ssh/config
# Remove backup folder if empty
rmdir $BACKUPDIR 2> /dev/null
echo "Done"
################################### Acknowledgement ######################################
# This script was adapted from https://github.com/JJGO/dotfiles/blob/master/setup_all.sh #
##########################################################################################