-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexport.sh
executable file
·100 lines (88 loc) · 1.63 KB
/
export.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
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
#!/bin/bash
if [ "$EUID" -eq 0 ]; then
echo "Please do NOT run as root" >&2
exit 1
fi
SCRIPTPATH="$(
cd -- "$(dirname "$0")" >/dev/null 2>&1
pwd -P
)"
out="$SCRIPTPATH/conf/"
mkdir -p "$out" && cd "$out"
# App settings
pack() {
cd "$1" &&
tar cJf "$out$2.tar.xz" ${3:-.} &&
cd "$out"
}
term=false
code=false
office=false
soft=false
# Terminal
export_terminal() {
if [ $term = false ]; then
cp -v ~/.zshrc .
cp -v /etc/vim/vimrc .
dconf dump /org/gnome/terminal/legacy/profiles:/ >gnome-terminal-profiles.dconf
term=true
fi
}
# VSCode
export_vscode() {
if [ $code = false ]; then
pack ~/.config/Code/User/ vscode "*.json"
sed -E 's/\/home\/([a-z0-9_.]+)/\/home\/user1000/g' ~/.vscode/extensions/extensions.json > vscode.extensions.json
code=true
fi
}
# LibreOffice
export_office() {
if [ $office = false ]; then
pack ~/.config/libreoffice/4/user libreoffice
pack /usr/local/share/fonts fonts
office=true
fi
}
# Other software
export_others() {
if [ $soft = false ]; then
cp -v /opt/whatsdesk.desktop .
soft=true
fi
}
PARSED=$(getopt --options="tacos" --longoptions="term,all,code,office,soft" --name "$0" -- "$@") || exit 2
# read getopt’s output this way to handle the quoting right
eval set -- "$PARSED"
# now enjoy the options in order and nicely split until we see --
while true; do
case "$1" in
-a | --all)
export_terminal
export_vscode
export_office
export_others
exit 0
;;
-t | --term)
export_terminal
;;
-c | --code)
export_vscode
;;
-o | --office)
export_office
;;
-s | --soft)
export_others
;;
--)
break
;;
*)
echo "Programming error"
exit 3
;;
esac
shift
done