Restructuring the repo
This commit is contained in:
parent
21e3cf65e6
commit
3d67598c27
45 changed files with 368 additions and 77 deletions
49
install.zsh
Executable file
49
install.zsh
Executable file
|
@ -0,0 +1,49 @@
|
|||
#!/bin/zsh
|
||||
|
||||
source ${$(realpath "$0"):h}/lib/common.zsh
|
||||
|
||||
typeset -A interpreter_checked
|
||||
have_interpreter() {
|
||||
if [[ ! $interpreter_checked[$1] ]]; then
|
||||
check "Checking for $1… "
|
||||
if which ruby &> /dev/null; then
|
||||
succeed
|
||||
interpreter_checked[$1]=1
|
||||
return 0
|
||||
else
|
||||
fail "not found in path"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
uses_interpreter() {
|
||||
head -n 1 $2 | grep -q $1
|
||||
}
|
||||
|
||||
if [[ -z $1 ]]; then
|
||||
<<-HELP
|
||||
Usage: $0 [-p PATH] <program_names>
|
||||
HELP
|
||||
exit 1
|
||||
fi
|
||||
|
||||
zparseopts -D -E p:=install_path -path:=install_path f=force -force=force
|
||||
|
||||
if [[ ! $install_path ]]; then
|
||||
install_path=$HOME/.local/bin
|
||||
fi
|
||||
|
||||
for prog in $@; do
|
||||
for lang in zsh ruby python; do
|
||||
if uses_interpreter $lang $prog; then
|
||||
have_interpreter $lang || exit 1
|
||||
fi
|
||||
done
|
||||
if [[ -e $install_path/${prog:t} && ! $force ]]; then
|
||||
error "$prog already exists at $install_path. Skipping."
|
||||
else
|
||||
ln -fsr $prog $install_path
|
||||
fi
|
||||
done
|
Loading…
Add table
Add a link
Reference in a new issue