From 1c562ad0f929decc002213c5e4c681206ab5d586 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Thu, 29 Jul 2021 07:26:45 -0700 Subject: [PATCH] automatically source compatible scripts in bash --- home/-shrc | 10 +++++----- home/bashrc | 25 ++++++++++++++----------- sh/streamcrap | 1 + 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/home/-shrc b/home/-shrc index 4e0a566..16876f3 100644 --- a/home/-shrc +++ b/home/-shrc @@ -4,11 +4,11 @@ # {{{1 utilities -#SOURCING=$((SOURCING+1)) -#. ~/sh/ify -#. ~/sh/has -#. ~/sh/maybesudo -#SOURCING=$((SOURCING-1)) +if [ -z "$ZSH_VERSION" ]; then + has() { # hardcode this function from ~/sh/has for convenience + which "$1" >/dev/null 2>&1 && which "$1" + } +fi # not available in busybox: #exports() { diff --git a/home/bashrc b/home/bashrc index 4a49c8b..fb1c38a 100644 --- a/home/bashrc +++ b/home/bashrc @@ -38,25 +38,28 @@ ret_fail="$_title${Cfail}$_line1\n${Cfail}$_line2" PROMPT_COMMAND='[ $? = 0 ] && PS1=${ret_succ} || PS1=${ret_fail}' -SOURCING=$((SOURCING+1)) -. ~/sh/echo2 -. ~/sh/note -. ~/sh/stfu -. ~/sh/has -SOURCING=$((SOURCING-1)) - echo START.-shrc . ~/.-shrc echo FINISH.-shrc -SOURCING=$((SOURCING+1)) -. ~/sh/arrays -. ~/sh/streamcrap -SOURCING=$((SOURCING-1)) +alias pl="printf '%s\n'" # this doesn't work for all scripts at the moment, but ADDPATH "$HOME/sh" +echo START.MERGING +( + cd ~/sh \ + && printf "%s\n" '#!/usr/bin/env false' '[ "${SOURCING:-0}" -gt 0 ] || exit 1' '' \ + | cat - $(grep -lF 'YES_BASH' $(find ~/sh -maxdepth 1 -type f)) \ + > ~/.sh-bash +) +echo FINISH.MERGING + +SOURCING=$((SOURCING+1)) +. ~/.sh-bash +SOURCING=$((SOURCING-1)) + # TODO: respect initctl like in .zshrc. alias reload='cd; exec bash' echo FINISH.bashrc diff --git a/sh/streamcrap b/sh/streamcrap index c9f6aaf..00ead0b 100644 --- a/sh/streamcrap +++ b/sh/streamcrap @@ -1,6 +1,7 @@ #!/usr/bin/env false # awful things # YES_ZSH +# YES_BASH MPV_STREAM_FLAGS="--quiet --autofit=1280x720 --loop-playlist=no --no-resume-playback --no-sub \ --no-initial-audio-sync --mc=0.02 --autosync=30"