-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall_dotzsh.sh
executable file
·102 lines (95 loc) · 3.26 KB
/
install_dotzsh.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
101
102
#!/bin/sh
#
########################################################################
# Install dot_zsh
# $1 = path
# $2 = nosudo
#
# Maintainer: id774 <[email protected]>
#
# v0.5 1/19,2014
# Change shebang to sh.
# v0.4 6/13,2013
# If target exist, delete it.
# v0.3 2/11,2012
# Change default install target to /usr/local/etc/zsh.
# v0.2 5/23,2011
# Install zsh plugins to /etc/zsh/plugins.
# v0.1 5/20,2011
# First.
########################################################################
setup_environment() {
test -n "$1" && export TARGET=$1
test -n "$1" || export TARGET=/usr/local/etc/zsh
#test -n "$1" || export TARGET=/etc/zsh
#test -n "$1" || export TARGET=$HOME/.zsh
test -n "$2" || SUDO=sudo
test -n "$2" && SUDO=
case $OSTYPE in
*darwin*)
OPTIONS=-Rv
OWNER=root:wheel
;;
*)
OPTIONS=-Rvd
OWNER=root:root
;;
esac
}
set_permission() {
$SUDO chown -R $OWNER $TARGET
}
zsh_compile() {
zsh -c 'zcompile $SOURCE/dot_zsh/lib/load.zsh'
zsh -c 'zcompile $SOURCE/dot_zsh/lib/base.zsh'
zsh -c 'zcompile $SOURCE/dot_zsh/lib/screen.zsh'
zsh -c 'zcompile $SOURCE/dot_zsh/plugins/R.zsh'
zsh -c 'zcompile $SOURCE/dot_zsh/plugins/alias.zsh'
zsh -c 'zcompile $SOURCE/dot_zsh/plugins/apps.zsh'
zsh -c 'zcompile $SOURCE/dot_zsh/plugins/amazonaws.zsh'
zsh -c 'zcompile $SOURCE/dot_zsh/plugins/cryptfs.zsh'
zsh -c 'zcompile $SOURCE/dot_zsh/plugins/ldlib.zsh'
zsh -c 'zcompile $SOURCE/dot_zsh/plugins/pager.zsh'
zsh -c 'zcompile $SOURCE/dot_zsh/plugins/pip.zsh'
zsh -c 'zcompile $SOURCE/dot_zsh/plugins/prompt.zsh'
zsh -c 'zcompile $SOURCE/dot_zsh/plugins/proxy.zsh'
zsh -c 'zcompile $SOURCE/dot_zsh/plugins/python.zsh'
zsh -c 'zcompile $SOURCE/dot_zsh/plugins/java.zsh'
zsh -c 'zcompile $SOURCE/dot_zsh/plugins/title.zsh'
zsh -c 'zcompile $SOURCE/dot_zsh/plugins/mysql.zsh'
zsh -c 'zcompile $SOURCE/dot_zsh/plugins/hadoop.zsh'
zsh -c 'zcompile $SOURCE/dot_zsh/plugins/vcs_info.zsh'
}
zwc_cleanup() {
rm -f $SOURCE/dot_zsh/lib/load.zsh.zwc
rm -f $SOURCE/dot_zsh/lib/base.zsh.zwc
rm -f $SOURCE/dot_zsh/lib/screen.zsh.zwc
rm -f $SOURCE/dot_zsh/plugins/R.zsh.zwc
rm -f $SOURCE/dot_zsh/plugins/alias.zsh.zwc
rm -f $SOURCE/dot_zsh/plugins/apps.zsh.zwc
rm -f $SOURCE/dot_zsh/plugins/amazonaws.zsh.zwc
rm -f $SOURCE/dot_zsh/plugins/cryptfs.zsh.zwc
rm -f $SOURCE/dot_zsh/plugins/ldlib.zsh.zwc
rm -f $SOURCE/dot_zsh/plugins/pager.zsh.zwc
rm -f $SOURCE/dot_zsh/plugins/pip.zsh.zwc
rm -f $SOURCE/dot_zsh/plugins/prompt.zsh.zwc
rm -f $SOURCE/dot_zsh/plugins/proxy.zsh.zwc
rm -f $SOURCE/dot_zsh/plugins/python.zsh.zwc
rm -f $SOURCE/dot_zsh/plugins/java.zsh.zwc
rm -f $SOURCE/dot_zsh/plugins/title.zsh.zwc
rm -f $SOURCE/dot_zsh/plugins/mysql.zsh.zwc
rm -f $SOURCE/dot_zsh/plugins/hadoop.zsh.zwc
rm -f $SOURCE/dot_zsh/plugins/vcs_info.zsh.zwc
}
install_dotzsh() {
setup_environment $*
test -d $TARGET && $SUDO rm -rf $TARGET
$SUDO mkdir -p $TARGET
zsh_compile
$SUDO cp $OPTIONS $SOURCE/dot_zsh/* $TARGET/
zwc_cleanup
test -n "$2" || set_permission
}
export SOURCE=$HOME/dot_zsh
test -d $SOURCE/dot_zsh/plugins || exit 1
install_dotzsh $*