updated stuff

This commit is contained in:
Nikolas Weger 2018-10-05 16:20:39 +02:00
parent c0c570fcd9
commit 00fec9b61b
13 changed files with 1484 additions and 345 deletions

1457
bin/ansi

File diff suppressed because it is too large Load diff

View file

@ -287,7 +287,7 @@ get_running_shell() {
else
# Strip leading dash for login shells.
# If the parent process is a login shell, guess bash.
local CMDLINE_SHELL=$(ps -o args -p $PPID | tail -1 | sed -e 's/login/bash/' -e 's/^-//')
local CMDLINE_SHELL=$(ps -o comm= -p $PPID | tail -1 | sed -e 's/login/bash/' -e 's/^-//')
fi
if [ ! -z "$CMDLINE_SHELL" ]; then
@ -331,4 +331,3 @@ case "$1" in
*) cmd_current "$@" ;;
esac
exit 0

23
bin/mo
View file

@ -141,15 +141,16 @@ mo() (
#
# Returns nothing.
moCallFunction() {
local moCommand
local moArgs
moArgs=()
# shellcheck disable=SC2031
if [[ -n "$MO_ALLOW_FUNCTION_ARGUMENTS" ]]; then
printf -v moCommand "%q %q %s" "$1" "$2" "$3"
eval "$moCommand"
else
"$1" "$2"
if [[ -n "${MO_ALLOW_FUNCTION_ARGUMENTS-}" ]]; then
moArgs=$3
fi
echo -n "$2" | eval "$1" "$moArgs"
}
@ -834,15 +835,15 @@ moShow() {
moSplit moNameParts "$1" "."
if [[ -z "${moNameParts[1]}" ]]; then
if [[ -z "${moNameParts[1]-}" ]]; then
if moIsArray "$1"; then
eval moJoin moJoined "," "\${$1[@]}"
echo -n "$moJoined"
else
# shellcheck disable=SC2031
if [[ -z "$MO_FAIL_ON_UNSET" ]] || moTestVarSet "$1"; then
if moTestVarSet "$1"; then
echo -n "${!1}"
else
elif [[ -n "${MO_FAIL_ON_UNSET-}" ]]; then
echo "Env variable not set: $1" >&2
exit 1
fi
@ -1029,15 +1030,17 @@ moTrimWhitespace() {
# Returns nothing.
moUsage() {
grep '^#/' "${MO_ORIGINAL_COMMAND}" | cut -c 4-
echo ""
set | grep ^MO_VERSION=
}
# Save the original command's path for usage later
MO_ORIGINAL_COMMAND="$(cd "${BASH_SOURCE[0]%/*}" || exit 1; pwd)/${BASH_SOURCE[0]##*/}"
MO_VERSION="2.0.4"
# If sourced, load all functions.
# If executed, perform the actions as expected.
if [[ "$0" == "${BASH_SOURCE[0]}" ]] || [[ -z "${BASH_SOURCE[0]}" ]]; then
mo "$@"
fi

11
bin/nma
View file

@ -1,11 +0,0 @@
#!/bin/bash
out=$(mktemp /tmp/nma.XXXXXXXX)
curl -s -d "apikey=1e9cfe3bddab21f271b742eb04f9918a76ad0ef0333be7d3" -d "application=Server" -d "event=megumi.eeleater.org" --data-urlencode "description=$1" -d "priority=0" "https://www.notifymyandroid.com/publicapi/notify" -o "$out"
if test $(xml sel -t -m "nma/success" -v "@code" "$out") == "200"; then
echo "Sent"
exit 0
fi
echo "Not sent: $(xml sel -t -m "nma/error" -v "." "$out")"
exit 1

View file

@ -265,7 +265,7 @@ function _revolver_demo() {
# Handle command input
###
function _revolver() {
# Get the context from the first parameter
# Get the context from the first parameter
local help version style ctx="$1"
# Parse CLI options

314
bin/shml
View file

@ -3,13 +3,129 @@
#SHML:START
#************************************************#
# SHML - Shell Markup Language Framework
# v1.0.3
# v1.1.0
# (MIT)
# by Justin Dorfman - @jdorfman
# && Joshua Mervine - @mervinej
#
# https://maxcdn.github.io/shml/
# http://shml.xyz
#************************************************#
SHML_VERSION="1.1.0"
# Progress Bar
##
# options:
# SHML_PROGRESS_CHAR - width of progress bar, default '#'
# SHML_PROGRESS_WIDTH - width of progress bar, default 60
# SHML_PROGRESS_MAX - maximum progress value, default 100
# SHML_PROGRESS_BREAK - put a new line at the end of the output, default 'true'
# SHML_PROGRESS_CLEAR - clear line at the end of the output, default 'false'
# SHML_PGOGRESS_NOCURSOR - hide the cursor, default 'true'
progress() {
[[ -z $SHML_PROGRESS_WIDTH ]] && SHML_PROGRESS_WIDTH=60
[[ -z $SHML_PROGRESS_BREAK ]] && SHML_PROGRESS_BREAK=true
[[ -z $SHML_PROGRESS_CLEAR ]] && SHML_PROGRESS_CLEAR=false
[[ -z $SHML_PROGRESS_NOCURSOR ]] && SHML_PROGRESS_NOCURSOR=true
# defaults
local __title="Progress"
local __steps=10
local __char="#"
# arg parser
[[ ! -z $1 ]] && __title=$1
[[ ! -z $2 ]] && __steps=$2
[[ ! -z $3 ]] && __char="$3"
local __width=${SHML_PROGRESS_WIDTH}
local __break=${SHML_PROGRESS_BREAK}
local __clear=${SHML_PROGRESS_CLEAR}
local __ncursor=${SHML_PROGRESS_NOCURSOR}
local __pct=0
local __num=0
local __len=0
local __bar=''
local __line=''
# ensure terminal
[[ -t 1 ]] || return 1
# ensure tput
if test "$(which tput)"; then
if $__ncursor; then
# hide cursor
tput civis
trap 'tput cnorm; exit 1' SIGINT
fi
fi
while read __value; do
# compute pct
__pct=$(( __value * 100 / __steps ))
# compute number of blocks to display
__num=$(( __value * __width / __steps ))
# create bar string
if [ $__num -gt 0 ]; then
__bar=$(printf "%0.s${__char}" $(seq 1 $__num))
fi
__line=$(printf "%s [%-${__witdth}s] (%d%%)" "$__title" "$__bar" "$__pct")
# print bar
echo -en "${__line}\r"
done
# clear line if requested
if $__clear; then
__len=$(echo -en "$__line" | wc -c)
printf "%$((__len + 1))s\r" " "
fi
# new line if requested
$__break && echo
# show cursor again
test "$(which tput)" && $__ncursor && tput cnorm
}
# Confirm / Dialog
##
__default_confirm_success_input="y Y yes Yes YES ok OK Ok okay Okay OKAY k K continue Continue CONTINUE proceed Proceed PROCEED success Success SUCCESS successful Successful SUCCESSFUL good Good GOOD"
confirm() {
[[ -z $1 ]] && return 127
[[ -z $SHML_CONFIRM_SUCCESS ]] && SHML_CONFIRM_SUCCESS=$__default_confirm_success_input
echo -ne "$1 "
local found=false
while read __input; do
for str in $(echo $SHML_CONFIRM_SUCCESS); do
[[ "$str" == "$__input" ]] && found=true
done
break
done
if $found; then
[[ ! -z $2 ]] && eval $2
return 0
else
[[ ! -z $3 ]] && eval $3
return 1
fi
}
dialog() {
[[ -z $1 ]] && return 127
[[ -z $2 ]] && return 127
echo -en "$1 "
while read __input; do
eval "$2 $__input"
break
done
}
# Foreground (Text)
##
@ -18,7 +134,7 @@ fgcolor() {
local __color=$__end # end by default
case "$1" in
end|off|reset) __color=$__end;;
black|000000) __color='\033[30m';;
black|000000|000) __color='\033[30m';;
red|F00BAF) __color='\033[31m';;
green|00CD00) __color='\033[32m';;
yellow|CDCD00) __color='\033[33m';;
@ -32,7 +148,7 @@ fgcolor() {
lightblue|3a80b5) __color='\033[94m';;
lightmagenta|fe00fe) __color='\033[95m';;
lightcyan|00fefe) __color='\033[96m';;
white|ffffff) __color='\033[97m';;
white|ffffff|fff) __color='\033[97m';;
esac
if test "$2"; then
echo -en "$__color$2$__end"
@ -62,7 +178,7 @@ bgcolor() {
local __color=$__end # end by default
case "$1" in
end|off|reset) __color=$__end;;
black|000000) __color='\033[40m';;
black|000000|000) __color='\033[40m';;
red|F00BAF) __color='\033[41m';;
green|00CD00) __color='\033[42m';;
yellow|CDCD00) __color='\033[43m';;
@ -77,7 +193,7 @@ bgcolor() {
lightblue|3a80b5) __color='\033[104m';;
lightmagenta|fe00fe) __color='\033[105m';;
lightcyan|00fefe) __color='\033[106m';;
white|fffff) __color='\033[107m';;
white|fffff|fff) __color='\033[107m';;
esac
if test "$2"; then
@ -158,8 +274,9 @@ tab() {
indent() {
local __len=4
local __int='^[0-9]+$'
if test "$1"; then
if [[ $1 =~ $re ]] ; then
if [[ $1 =~ $__int ]] ; then
__len=$1
fi
fi
@ -168,6 +285,7 @@ indent() {
__len=$(( $__len - 1 ))
done
}
i() {
indent "$@"
}
@ -175,9 +293,9 @@ i() {
hr() {
local __len=60
local __char='-'
local __int='^[0-9]+$'
if ! test "$2"; then
re='^[0-9]+$'
if [[ $1 =~ $re ]] ; then
if [[ $1 =~ $__int ]] ; then
__len=$1
elif test "$1"; then
__char=$1
@ -194,7 +312,6 @@ hr() {
# Icons
##
icon() {
local i='';
case "$1" in
@ -214,59 +331,56 @@ icon() {
apple) i='\xEF\xA3\xBF';;
skull|bones) i='\xE2\x98\xA0';;
':-)'|':)'|smile|face) i='\xE2\x98\xBA';;
*)
entity $1; return 0;;
esac
echo -ne "$i";
}
# Emojis
##
emoji() {
local i=""
case "$1" in
1F603|smiley|'=)'|':-)'|':)') i='😃';;
1F607|innocent|halo) i='😇';;
1F602|joy|lol|laughing) i='😂';;
1F61B|tongue|'=p'|'=P') i='😛';;
1F60A|blush|'^^'|blushing) i='😊';;
1F61F|worried|sadface|sad) i='😟';;
1F622|cry|crying|tear) i='😢';;
1F621|rage|redface) i='😡';;
1F44B|wave|hello|goodbye) i='👋';;
1F44C|ok_hand|perfect|okay|nice) i='👌';;
1F44D|thumbsup|+1|like) i='👍';;
1F44E|thumbsdown|-1|no|dislike) i='👎';;
1F63A|smiley_cat|happycat) i='😺';;
1F431|cat|kitten|:3|kitty) i='🐱';;
1F436|dog|puppy) i='🐶';;
1F41D|bee|honeybee|bumblebee) i='🐝';;
1F437|pig|pighead) i='🐷';;
1F435|monkey_face|monkey) i='🐵';;
1F42E|cow|happycow) i='🐮';;
1F43C|panda_face|panda|shpanda) i='🐼';;
1F363|sushi|raw|sashimi) i='🍣';;
1F3E0|home|house) i='🏠';;
1F453|eyeglasses|bifocals) i='👓';;
1F6AC|smoking|smoke|cigarette) i='🚬';;
1F525|fire|flame|hot|snapstreak) i='🔥';;
1F4A9|hankey|poop|shit) i='💩';;
1F37A|beer|homebrew|brew) i='🍺';;
1F36A|cookie|biscuit|chocolate) i='🍪';;
1F512|lock|padlock|secure) i='🔒';;
1F513|unlock|openpadlock) i='🔓';;
2B50|star|yellowstar) i='⭐';;
1F0CF|black_joker|joker|wild) i='🃏';;
2705|white_check_mark|check) i='✅';;
274C|x|cross|xmark) i='❌';;
1F6BD|toilet|restroom|loo) i='🚽';;
1F514|bell|ringer|ring) i='🔔';;
1F50E|mag_right|search|magnify) i='🔎';;
1F3AF|dart|bullseye|darts) i='🎯';;
1F4B5|dollar|cash|cream) i='💵';;
1F4AD|thought_balloon|thinking) i='💭';;
1F340|four_leaf_clover|luck) i='🍀';;
*)
#entity $1; return 0;;
1F603|smiley|'=)'|':-)'|':)') i='😃';;
1F607|innocent|halo) i='😇';;
1F602|joy|lol|laughing) i='😂';;
1F61B|tongue|'=p'|'=P') i='😛';;
1F60A|blush|'^^'|blushing) i='😊';;
1F61F|worried|sadface|sad) i='😟';;
1F622|cry|crying|tear) i='😢';;
1F621|rage|redface) i='😡';;
1F44B|wave|hello|goodbye) i='👋';;
1F44C|ok_hand|perfect|okay|nice|ok) i='👌';;
1F44D|thumbsup|+1|like) i='👍';;
1F44E|thumbsdown|-1|no|dislike) i='👎';;
1F63A|smiley_cat|happycat) i='😺';;
1F431|cat|kitten|:3|kitty) i='🐱';;
1F436|dog|puppy) i='🐶';;
1F41D|bee|honeybee|bumblebee) i='🐝';;
1F437|pig|pighead) i='🐷';;
1F435|monkey_face|monkey) i='🐵';;
1F42E|cow|happycow) i='🐮';;
1F43C|panda_face|panda|shpanda) i='🐼';;
1F363|sushi|raw|sashimi) i='🍣';;
1F3E0|home|house) i='🏠';;
1F453|eyeglasses|bifocals) i='👓';;
1F6AC|smoking|smoke|cigarette) i='🚬';;
1F525|fire|flame|hot|snapstreak) i='🔥';;
1F4A9|hankey|poop|poo|shit) i='💩';;
1F37A|beer|homebrew|brew) i='🍺';;
1F36A|cookie|biscuit|chocolate) i='🍪';;
1F512|lock|padlock|secure) i='🔒';;
1F513|unlock|openpadlock) i='🔓';;
2B50|star|yellowstar) i='⭐';;
1F0CF|black_joker|joker|wild) i='🃏';;
2705|white_check_mark|check) i='✅';;
274C|x|cross|xmark) i='❌';;
1F6BD|toilet|restroom|loo) i='🚽';;
1F514|bell|ringer|ring) i='🔔';;
1F50E|mag_right|search|magnify) i='🔎';;
1F3AF|dart|bullseye|darts) i='🎯';;
1F4B5|dollar|cash|cream) i='💵';;
1F4AD|thought_balloon|thinking) i='💭';;
1F340|four_leaf_clover|luck) i='🍀';;
esac
echo -ne "$i"
}
@ -280,9 +394,26 @@ function e {
# Usage / Examples
##
if [[ "$(basename -- "$0")" = "shml.sh" ]]; then
if [ "$0" = "$BASH_SOURCE" ]; then
if [[ $@ =~ .*-v.* ]]; then
echo "shml version ${SHML_VERSION}"
exit 0
fi
I=2
echo -e "
$(color "lightblue")
#$(hr "*" 48)#
# SHML - Shell Markup Language Framework
# v${SHML_VERSION}
# (MIT)
# by Justin Dorfman - @jdorfman
# && Joshua Mervine - @mervinej
#
# https://maxcdn.github.io/shml/
#$(hr "*" 48)#
$(color "end")
$(a bold 'SHML Usage / Help')
$(hr '=')
@ -484,6 +615,73 @@ $(i $I)
$(i $I)\$(bar black yellow black yellow black yellow)
$(i $I)$(bar black yellow black yellow black yellow)
$(a bold "Section 8: $(color red "[EXPERIMENTAL]") Progress Bar")
$(hr '-')
$(i $I)Usage: progress [TITLE] [STEPS] [CHAR]
$(i $I) - 'title' defines the progress bar title
$(i $I) - 'steps' defines the number of steps for the progress bar to act upon
$(i $I) - 'char' defines the character to be displayed in the progress bar
$(i $I)Example:
$(i $I)echo "\$\(color green\)"
$(i $I)for i in \$(seq 0 10); do echo \$i; sleep .25; done | progress
$(i $I)echo "\$\(color end\)"
$(color green "$(i $I)Example [#################### ] (50%)")
$(i $I)'progress' supports overriding default values by setting the following variables:
$(i $I) - SHML_PROGRESS_WIDTH - width of progress bar, default 60
$(i $I) - SHML_PROGRESS_BREAK - put a new line at the end of the output, default 'true'
$(i $I) - SHML_PROGRESS_CLEAR - clear line at the end of the output, default 'false'
$(i $I) - SHML_PGOGRESS_NOCURSOR - hide the cursor, default 'true'
$(i $I)NOTE: These variables $(a bold 'must') be defined before sourcing 'shml'!
$(a bold "Section 9: $(color red "[EXPERIMENTAL]") Confirm")
$(hr '-')
$(i $I)Ask a yes or no question and handle results.
$(i $I)Usage: confirm QUESTION [SUCCESS_FUNCTION] [FAILURE_FUNCTION]
$(i $I)Supports the following as affirmitive responses by default:
$(for r in `echo "$__default_confirm_success_input"`; do echo "$(i $I) - '$r'"; done)
$(i $I)Default affirmtive responses can be overwritten by setting 'SHML_CONFIRM_SUCCESS'.
$(i $I)Example:
$(i $I)function on_success() {
$(i $I) echo \"yay\"
$(i $I)}
$(i $I)function on_failure() {
$(i $I) echo \"boo\"
$(i $I)}
$(i $I)confirm \"CREAM?\" \"on_success\" \"on_failure\"
$(a bold "Section 9: $(color red "[EXPERIMENTAL]") Dialog")
$(hr '-')
$(i $I)Asks a question and passes the answer to a response handler function.
$(i $I)Usage: dialog QUESTION [RESPONSE_FUNCTION]
$(i $I)Example:
$(i $I)function on_response() {
$(i $I) echo \"hello $1\"
$(i $I)}
$(i $I)dialog \"What is your name?\" \"on_response\"
" | less -r
fi

View file

@ -3,6 +3,6 @@ Host web
HostName megumi.eeleater.org
User eeleater
Host git
HostName git.eeleater.org
Host ipa
HostName 192.168.122.15
User eeleater

View file

@ -41,8 +41,12 @@ fpath+=(${brewpr}/share/zsh/site-functions)
fpath+=(${dotlib}/local)
fpath+=(${BASHER_ROOT}/cellar/completions/zsh)
# IPFS
IPFS_PATH=/var/lib/ipfs/repo
VAULT_ADDR=http://127.0.0.1:8200
# Actually export
export dotlib dotcfg brewpr gembin PATH MANPATH INFOPATH EDITOR XDG_DATA_DIRS PTOOLSPATH
export dotlib dotcfg brewpr gembin PATH MANPATH INFOPATH EDITOR XDG_DATA_DIRS PTOOLSPATH IPFSPATH VAULT_ADDR
# Reload all Prompts
autoload -U promptinit && promptinit

View file

@ -1,3 +1,4 @@
export ZSH="${dotlib}/ohmyzsh"
DISABLE_AUTO_UPDATE="true"
ZSH_DISABLE_COMPFIX="true"
source ${ZSH}/oh-my-zsh.sh

@ -1 +1 @@
Subproject commit df7e44c685c9a60d83a3760aa373d3864779aeeb
Subproject commit 09ab969e206b4c8984cacd588b18676f7f5109aa

@ -1 +1 @@
Subproject commit 318f8fc99146275e0828737ac2898930c6d8342f
Subproject commit 72190ee30bd1e2ccc233222341435adacb7a6500

@ -1 +1 @@
Subproject commit 5443d4cb9e03d8d97fa0be19a4718958bf23fca4
Subproject commit 75ccc961718cf51be95644258f97f4c99fdd29e6

@ -1 +1 @@
Subproject commit 652356b9b99b26317478a8756893f896abbed6cd
Subproject commit 08f2fc12143175d011d69189679b0ed4c834b5c7