-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·92 lines (73 loc) · 1.29 KB
/
install.sh
File metadata and controls
executable file
·92 lines (73 loc) · 1.29 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
#! /usr/bin/env bash
set -o errexit -o errtrace -o pipefail -o nounset
function abspath() {
if [[ ! -d "$1" ]]; then
DIRNAME=$(dirname "$1")
else
DIRNAME="$1"
fi
echo $(cd $DIRNAME; pwd)
}
SRCDIR=`abspath $0`
DESTDIR="$HOME"
OPTIONS="-s $@"
declare -a FILES=(
"$SRCDIR/.bash_profile"
"$SRCDIR/.bashrc"
"$SRCDIR/.zshrc"
"$SRCDIR/.zsh"
"$SRCDIR/.sh"
"$SRCDIR/.tmux.conf"
"$SRCDIR/.desk"
"$SRCDIR/.gdbinit"
"$SRCDIR/.gitconfig"
"$SRCDIR/.gitignore_global"
"$SRCDIR/.gvimrc"
"$SRCDIR/.vimrc"
"$SRCDIR/.vim"
"$SRCDIR/.pythonrc"
"$SRCDIR/.editrc"
"$SRCDIR/.psqlrc"
"$SRCDIR/.xprofile"
)
declare -a DIRS=(
"$DESTDIR"/.config
)
function main() {
for opt in "$@"; do
case "$opt" in
"-h"|"--help")
usage
exit 0
;;
esac
done
set +o errexit
for dir in ${DIRS[@]}; do
exec_cmd "mkdir $dir"
done
for file in ${FILES[@]}; do
exec_cmd "ln $OPTIONS $file $DESTDIR"
done
set -o errexit
}
function exec_cmd() {
cmd="$1"
echo -n "$cmd ..."
ERR=$($cmd 2>&1 >/dev/null)
if [ $? -eq 0 ]; then
echo " ok"
else
echo "$ERR" | awk -F':' '{ print $NF }'
fi
}
usage() {
cat <<EOF
USAGE:
./setup_simlinks.sh [options]
[options]:
The same options as from "man ln".
Do not include -s, it is automatically added
EOF
}
main