-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinstall
More file actions
executable file
·97 lines (79 loc) · 2.24 KB
/
install
File metadata and controls
executable file
·97 lines (79 loc) · 2.24 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
93
94
95
96
#!/bin/sh
### Insert newline
e_newline() { printf "\n"; }
### Normal style of writing
e_header() { printf "\033[1m%s\033[0m\n" "$*"; }
### Success
e_success() { printf " \033[1;32m✔ \033[0m %s\n" "$*"; }
### Failure
e_error() { printf " \033[1;31m✗ \033[0m %s\n" "$*" 1>&2; }
### Result
e_arrow() { printf " \033[1;34m→ \033[0m %s\n" "$*"; }
is_exists() {
local i
for i in "$@";do
if which "$i" >/dev/null 2>&1; then
return 0
fi
done
return 1
}
dotfiles_install() {
### 1. Download the repository
### ==> downloading
###
### Priority: git > curl > wget
dotfiles_download &&
### 2. Deploy dotfiles to your home directory
### ==> deploying
dotfiles_deploy &&
### 3. Execute all sh files within etc/init/
### ==> initializing
dotfiles_initialize "$@"
}
### Environment valuable
DOTFILES=~/.dotfiles; export DOTFILES
GITHUB_DOTFILES="https://github.com/kegamin/dotfiles.git"; export GITHUB_DOTFILES
dotfiles_download() {
e_header "Downloading dotfiles..."
[ "$DEBUG" = 1 ] && return 0
local tarball="https://github.com/kegamin/dotfiles/archive/master.tar.gz"
### Check if $DOTFILES exists
if [ -d $DOTFILES ]; then
cd
e_newline
e_arrow "$DOTFILES: already exists, removing..."
mv -f "$DOTFILES" "${DOTFILES}.$(date "+%Y%m%d%S")"
fi
e_newline
if is_exists "git"; then
### --recursive equals to ...
### git submodule init
### git submodule update
git clone --recursive "$GITHUB_DOTFILES" "$DOTFILES"
elif is_exists "curl" "wget"; then
### curl or wget
if is_exists "curl"; then
curl -L "$tarball"
elif is_exists "wget"; then
wget -O - "$tarball"
fi | tar xv -
mv -f dotfiles-master "$DOTFILES"
else
### requirement
interrupt "Require git, curl or wget!"
fi
e_newline
}
e_newline
dotfiles_install "$@"
if [ -t 0 ]; then
### Restart shell if specified "bash -c $(curl -L {URL})"
### not restart:
### curl -L {URL} | bash
e_arrow "Restarting your shell..."
exec "${SHELL:-/bin/zsh}"
else
e_arrow "Restart your shell, manually"
fi
e_success "All done. Success!"