forked from CodelyTV/dotly
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathzsh
executable file
·95 lines (83 loc) · 2.77 KB
/
zsh
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
#!/usr/bin/env bash
#shellcheck disable=SC1091
. "${SLOTH_PATH:-${DOTLY_PATH:-}}/scripts/core/src/_main.sh"
##? ZSH helpers
##?
##? Usage:
##? zsh optimize
##? zsh test_performance
##? zsh reload_completions
##? zsh clean_cache
##? zsh fix_permissions
##?
##? Arguments:
##? optimize
##? test_performance Check how much time is the loading of zsh shell
##? reload_completions
##? clean_cache
##? fix_permissions Fix error: "zsh compinit: insecure directories"
##?
#? v2.2.0
if [[ "${1:-}" == "-h" || "${1:-}" == "--help" || "${1:-}" == "-v" || "${1:-}" == "--version" ]] || package::is_installed docopts; then
docs::parse "$@"
fi
case "${1:-}" in
"optimize")
compaudit 2> /dev/null | xargs -I _ chmod -R go-w _
output::header "Cleaning stuff"
zsh "${ZIM_HOME}/zimfw.zsh" clean-compiled
zsh "${ZIM_HOME}/zimfw.zsh" compile
output::empty_line
output::header "Loading zlogin"
/bin/zsh -c ". \"${ZDOTDIR:-${HOME}}/.zlogin\""
output::empty_line
output::header "Reloading zsh completions"
"${SLOTH_PATH:-${DOTLY_PATH:-}}/bin/dot" shell zsh reload_completions
output::empty_line
output::header "ASL only storing critical files"
if sudo -v -B; then
asl_conf=$(sed 's/notice] store/critical] store/g' /etc/asl.conf)
sudo sh -c "echo '$asl_conf' > /etc/asl.conf"
output::empty_line
else
output::error "This final step require elevation with sudo"
fi
output::solution "Done! Restart your terminal"
;;
"test_performance")
PATH="${HOME}/.cargo/bin:${PATH}"
script::depends_on hyperfine
if platform::command_exists brew; then
HOMBREW_PREFIX="${HOMBREW_PREFIX:-$(brew --prefix)}"
fi
if [[ -n "${HOMEBREW_PREFIX:-}" && -x "${HOMBREW_PREFIX}/bin/zsh" ]]; then
hyperfine '/bin/zsh -i -c exit' "${HOMBREW_PREFIX}/bin/zsh -i -c exit" --warmup 1
else
hyperfine '/bin/zsh -i -c exit' --warmup 1
fi
output::empty_line
output::write "ZSH INFO:"
output::write " 💻 System ZSH 📂 /bin/zsh - $(/bin/zsh --version)"
if [[ -n "${HOMEBREW_PREFIX:-}" && -x "${HOMBREW_PREFIX}/bin/zsh" ]]; then
output::write " 🍺 Brew ZSH 📂 ${HOMBREW_PREFIX}/bin/zsh - $("${HOMBREW_PREFIX}/bin/zsh" --version)"
fi
output::empty_line
output::write "✨ Currently using $(command -v zsh) ✨"
;;
"clean_cache")
find "${HOME}" -name '*.zwc' -delete
;;
"reload_completions")
compaudit 2> /dev/null | xargs -I _ chmod -R go-w _
rm -f "${HOME}/.zcompdump"
zsh -i -c "autoload -U compaudit && autoload -Uz compinit && compinit"
output::empty_line
output::answer 'Now restart your terminal'
;;
"fix_permissions")
compaudit 2> /dev/null | xargs -I _ chmod -R go-w _
;;
*)
exit 1
;;
esac