Restructuring the repo

This commit is contained in:
Alexander Gehrke 2020-04-02 10:38:36 +02:00
parent 21e3cf65e6
commit 3d67598c27
45 changed files with 368 additions and 77 deletions

41
lib/common.zsh Normal file
View file

@ -0,0 +1,41 @@
autoload -Uz colors && colors
local c_fail="${fg_bold[red]}$reset_color"
local c_success="${fg_bold[green]}$reset_color"
check() {
echo -n " ? $*"
}
result() {
echo -n "\e[s"
echo -n "\e[1G $1"
echo -n "\e[u"
shift
echo " $*"
}
fail() { result $c_fail $@ }
succeed() { result $c_success $@ }
error() { echo -n " "; fail $@ }
depend() {
local missing
local i
for i in "$@"; do
type "$i" &>/dev/null || {
echo >&2 " $c_fail Missing dependency: $i. Please install it"
missing=1
}
done
[[ -n "$missing" ]] && exit 1
}
urlencode() {
setopt extendedglob
input=$(</dev/stdin)
# by jkramer, source: http://stackoverflow.com/a/187853/928769
echo "${${(j: :)input}//(#b)(?)/%$[[##16]##${match[1]}]}"
}