Use binary to install zsh libraries
This commit is contained in:
committed by
T. R. Bernstein
parent
2e5dca950e
commit
ff374e3dcc
33
bin/azw
Executable file
33
bin/azw
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env zsh
|
||||
# vi: set ft=zsh tw=80 ts=2
|
||||
autoload -w zshlib
|
||||
|
||||
function dispatchToExtern() {
|
||||
local cmdName="$1"
|
||||
whence azw-$cmdName &> /dev/null || {
|
||||
lop -- -e "Unknown command $cmdName."
|
||||
exit 10
|
||||
}
|
||||
azw-$cmdName "$@"
|
||||
}
|
||||
|
||||
function dispatchCommand() {
|
||||
local cmdName="$1"
|
||||
case $cmdName in
|
||||
*)
|
||||
dispatchToExtern $cmdName
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
function main() {
|
||||
local cmdName="$1"
|
||||
[[ $# -gt 1 ]] && shift
|
||||
|
||||
dispatchCommand $cmdName
|
||||
}
|
||||
|
||||
if [[ "${ZSH_EVAL_CONTEXT}" == toplevel || "${ZSH_EVAL_CONTEXT}" == cmdarg ]]; then
|
||||
_DIR="${0:A:h}"
|
||||
main "$@"
|
||||
fi
|
||||
34
bin/azw-update-zsh-libraries
Executable file
34
bin/azw-update-zsh-libraries
Executable file
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env zsh
|
||||
# vi: set ft=zsh tw=80 ts=2
|
||||
|
||||
function ensureLocalBinFolder() {
|
||||
local folder="/usr/local/bin"
|
||||
if [[ ! -d "${folder}" ]]; then
|
||||
mkdir -p "${folder}" 2> /dev/null || return 10
|
||||
chown root:admin "${folder}"
|
||||
chmod ug=rwx,o=rx "${folder}"
|
||||
fi
|
||||
}
|
||||
|
||||
function installZshlib() {
|
||||
/bin/zsh -c "$(curl -fsSL https://raw.githubusercontent.com/astzweig/zshlib/main/bootstrap.sh)"
|
||||
[[ -f '/usr/local/share/zsh/site-functions/zshlib.zwc' ]]
|
||||
}
|
||||
|
||||
function installMacOSSystemLibrary() {
|
||||
local destPath=/usr/local/bin/macos-system-lib.sh
|
||||
curl --output $destPath -fsSL https://raw.githubusercontent.com/astzweig/macos-system/main/modules/lib.sh
|
||||
chown root:admin $destPath
|
||||
chmod ugo=r $destPath
|
||||
}
|
||||
|
||||
function main() {
|
||||
installZshlib
|
||||
ensureLocalBinFolder || return $?
|
||||
installMacOSSystemLibrary
|
||||
}
|
||||
|
||||
if [[ "${ZSH_EVAL_CONTEXT}" == toplevel || "${ZSH_EVAL_CONTEXT}" == cmdarg ]]; then
|
||||
_DIR="${0:A:h}"
|
||||
main "$@"
|
||||
fi
|
||||
Reference in New Issue
Block a user