mirror of
https://github.com/notwa/rc
synced 2024-06-30 10:57:12 -07:00
first pass over sh: improve compatibility, fix stuff
This commit is contained in:
parent
5eaf74401e
commit
04e890db1b
8
sh/arith
8
sh/arith
|
@ -1,8 +1,14 @@
|
||||||
#!/usr/bin/env zsh
|
#!/usr/bin/env zsh
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
# YES_BASH
|
||||||
|
# YES_DASH
|
||||||
|
|
||||||
|
# though technically compatible with other shells,
|
||||||
|
# extra functionality is through zsh's extended arithmetic functions.
|
||||||
|
|
||||||
arith() {
|
arith() {
|
||||||
<<<"$(($@))"
|
# <<<"$(($@))"
|
||||||
|
printf "%s\n" "$(($@))"
|
||||||
}
|
}
|
||||||
|
|
||||||
[ "${SOURCING:-0}" -gt 0 ] || arith "$@"
|
[ "${SOURCING:-0}" -gt 0 ] || arith "$@"
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#!/usr/bin/env false
|
#!/usr/bin/env false
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
# YES_BASH
|
||||||
|
# NO_DASH
|
||||||
|
|
||||||
whoa=(
|
whoa=(
|
||||||
-Wall
|
-Wall
|
||||||
|
|
2
sh/aur
2
sh/aur
|
@ -2,6 +2,8 @@
|
||||||
# http://aur.sh with massive feature creep
|
# http://aur.sh with massive feature creep
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
|
||||||
|
# TODO: check compatibility with bash and dash.
|
||||||
|
|
||||||
aur() {
|
aur() {
|
||||||
trap 'exit 1' SIGINT SIGTERM
|
trap 'exit 1' SIGINT SIGTERM
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
#!/usr/bin/env zsh
|
#!/usr/bin/env zsh
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
# NO_BASH
|
||||||
|
# NO_DASH
|
||||||
|
|
||||||
|
# TODO: portable way of dodging aliases to allow other shell support?
|
||||||
|
|
||||||
autosync() {
|
autosync() {
|
||||||
target="$1"
|
target="$1"
|
||||||
|
|
6
sh/bak
6
sh/bak
|
@ -1,14 +1,16 @@
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
# YES_BASH
|
||||||
|
# YES_DASH
|
||||||
|
|
||||||
bak() {
|
bak() {
|
||||||
[ $# -gt 0 ] || { printf "%s\n" "$0: too few arguments" >&2; return 1; }
|
[ $# -gt 0 ] || { printf "%s\n" "$0: too few arguments" >&2; return 1; }
|
||||||
local ret=0
|
local ret=0
|
||||||
for f; do
|
for f; do
|
||||||
if [ -s "$f.bak" ]; then
|
if [ -e "$f.bak" ]; then
|
||||||
bak "$f.bak" || ret=1
|
bak "$f.bak" || ret=1
|
||||||
fi
|
fi
|
||||||
cp -p "$f" "$f.bak"
|
cp -p "$f" "$f.bak" || ret=1
|
||||||
done
|
done
|
||||||
return $ret
|
return $ret
|
||||||
}
|
}
|
||||||
|
|
5
sh/baks
5
sh/baks
|
@ -1,5 +1,7 @@
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
# YES_BASH
|
||||||
|
# YES_DASH
|
||||||
|
|
||||||
#SOURCING=$((SOURCING+1))
|
#SOURCING=$((SOURCING+1))
|
||||||
#. ~/sh/note # FIXME: don't do this?
|
#. ~/sh/note # FIXME: don't do this?
|
||||||
|
@ -11,7 +13,8 @@ baks() { # backup, timestamped
|
||||||
local now="$(date -u '+%y-%m-%d_%H-%M-%S')"
|
local now="$(date -u '+%y-%m-%d_%H-%M-%S')"
|
||||||
local bak="$fp.$now.bak"
|
local bak="$fp.$now.bak"
|
||||||
if [ -s "$bak" ]; then
|
if [ -s "$bak" ]; then
|
||||||
note "how in the hell?" "$bak" "already exists"
|
#note "how in the hell?" "$bak" "already exists"
|
||||||
|
printf "%s %s %s\n" "how in the hell?" "$bak" "already exists"
|
||||||
ret=1
|
ret=1
|
||||||
fi
|
fi
|
||||||
cp -p "$fp" "$bak" || ret=1
|
cp -p "$fp" "$bak" || ret=1
|
||||||
|
|
4
sh/bin
4
sh/bin
|
@ -1,9 +1,11 @@
|
||||||
#!/usr/bin/env zsh
|
#!/usr/bin/env zsh
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
# YES_BASH
|
||||||
|
# YES_DASH
|
||||||
|
|
||||||
bin() {
|
bin() {
|
||||||
local a="$(($@))"
|
local a="$(($@))"
|
||||||
let 'a=(((((((((((((a + 0x0FFFFF80) & 0x1000007F) + 0x00FFFFC0) & 0x1100003F) + 0x000FFFE0) & 0x1110001F) + 0x0000FFF0) & 0x1111000F) + 0x00000FF8) & 0x11111007) + 0x000000FC) & 0x11111103) + 0x0000000E) & 0x11111111'
|
a="$(((((((((((((((a + 0x0FFFFF80) & 0x1000007F) + 0x00FFFFC0) & 0x1100003F) + 0x000FFFE0) & 0x1110001F) + 0x0000FFF0) & 0x1111000F) + 0x00000FF8) & 0x11111007) + 0x000000FC) & 0x11111103) + 0x0000000E) & 0x11111111))"
|
||||||
printf "%08X\n" "$a"
|
printf "%08X\n" "$a"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
cdbusiest() {
|
cdbusiest() {
|
||||||
dbusiest | read -r c d
|
dbusiest | read -r c d
|
||||||
[ -z $c ] && return 1
|
[ -z $c ] && return 1
|
||||||
<<<"$c $d"
|
printf "%s\n" "$c $d"
|
||||||
cd $d
|
cd $d
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
# YES_BASH
|
||||||
|
# NO_DASH
|
||||||
|
|
||||||
colors() {
|
colors() {
|
||||||
printf "\e[%dm$(printf " \e[%dm mV \e[40m" {4,10}{0..7})\e[0m\n" {3,9}{0..7}
|
printf "\e[%dm$(printf " \e[%dm mV \e[40m" {4,10}{0..7})\e[0m\n" {3,9}{0..7}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/zsh
|
#!/usr/bin/zsh
|
||||||
# YES_ZSH
|
|
||||||
# script to make sense of compand's parameters
|
# script to make sense of compand's parameters
|
||||||
|
# YES_ZSH
|
||||||
|
|
||||||
compandy() {
|
compandy() {
|
||||||
if [ $# -eq 0 ]; then
|
if [ $# -eq 0 ]; then
|
||||||
|
|
87
sh/compile
87
sh/compile
|
@ -1,5 +1,7 @@
|
||||||
#!/usr/bin/env zsh
|
#!/usr/bin/env zsh
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
# NO_BASH
|
||||||
|
# NO_DASH
|
||||||
|
|
||||||
# I'll just leave this here...
|
# I'll just leave this here...
|
||||||
__setup_clang_ubuntu() {
|
__setup_clang_ubuntu() {
|
||||||
|
@ -54,51 +56,54 @@ compile() {
|
||||||
|
|
||||||
local winkit
|
local winkit
|
||||||
printf "%s\n" "/c/Program Files (x86)/Windows Kits/"*(on/N[1]) | read -r winkit
|
printf "%s\n" "/c/Program Files (x86)/Windows Kits/"*(on/N[1]) | read -r winkit
|
||||||
[ -n "$winkit" ] || { echo "failed glob; missing winkit" >&2; return 1 }
|
[ -z "$winkit" ] || printf "%s\n" "$winkit/Lib/"*(On/N[1]) | read -r winkit
|
||||||
printf "%s\n" "$winkit/Lib/"*(On/N[1]) | read -r winkit
|
|
||||||
[ -n "$winkit" ] || { echo "failed glob; missing winkit" >&2; return 1 }
|
|
||||||
|
|
||||||
# detect MSVC.
|
if [ -z "$winkit" ]; then
|
||||||
local clarch
|
#echo "failed glob; missing winkit" >&2
|
||||||
local arch
|
:
|
||||||
local msvc_dig_deep
|
else
|
||||||
[ "$MSYSTEM" = MINGW64 ] && clarch="/amd64" || clarch=""
|
# detect MSVC.
|
||||||
[ "$MSYSTEM" = MINGW64 ] && arch="x64" || arch="x86"
|
local clarch
|
||||||
if [ -d "/c/Program Files (x86)/Microsoft Visual Studio" ]; then # 2017+
|
local arch
|
||||||
printf "%s\n" "/c/Program Files (x86)/Microsoft Visual Studio/20"*(On/N[1]) | read vc
|
local msvc_dig_deep
|
||||||
printf "%s\n" "$vc"/*/VC | read vc
|
[ "$MSYSTEM" = MINGW64 ] && clarch="/amd64" || clarch=""
|
||||||
printf "%s\n" "$vc/Tools/MSVC/"*(On/N[1]) | read vc
|
[ "$MSYSTEM" = MINGW64 ] && arch="x64" || arch="x86"
|
||||||
msvc_dig_deep="yes"
|
if [ -d "/c/Program Files (x86)/Microsoft Visual Studio" ]; then # 2017+
|
||||||
else # older versions
|
printf "%s\n" "/c/Program Files (x86)/Microsoft Visual Studio/20"*(On/N[1]) | read vc
|
||||||
printf "%s\n" "/c/Program Files (x86)/Microsoft Visual Studio "*(On/N[1]) | read vc
|
printf "%s\n" "$vc"/*/VC | read vc
|
||||||
vc="$vc/VC"
|
printf "%s\n" "$vc/Tools/MSVC/"*(On/N[1]) | read vc
|
||||||
fi
|
msvc_dig_deep="yes"
|
||||||
|
else # older versions
|
||||||
|
printf "%s\n" "/c/Program Files (x86)/Microsoft Visual Studio "*(On/N[1]) | read vc
|
||||||
|
vc="$vc/VC"
|
||||||
|
fi
|
||||||
|
|
||||||
# setup MSVC.
|
# setup MSVC.
|
||||||
if [ -n "$msvc_dig_deep" ] && [ -e "$vc/bin/Host$arch/$arch/cl" ]; then
|
if [ -n "$msvc_dig_deep" ] && [ -e "$vc/bin/Host$arch/$arch/cl" ]; then
|
||||||
cl="$vc/bin/Host$arch/$arch/cl"
|
cl="$vc/bin/Host$arch/$arch/cl"
|
||||||
export PATH="$PATH:$vc/bin/Host$arch/$arch"
|
export PATH="$PATH:$vc/bin/Host$arch/$arch"
|
||||||
export LIB="$(cygpath -w "$vc/lib/$arch")"
|
export LIB="$(cygpath -w "$vc/lib/$arch")"
|
||||||
export LIBPATH="$(cygpath -w "$vc/lib/$arch")"
|
export LIBPATH="$(cygpath -w "$vc/lib/$arch")"
|
||||||
elif [ -d "$vc/bin$clarch" ] && [ -e "$vc/bin$clarch/$cl" ]; then
|
elif [ -d "$vc/bin$clarch" ] && [ -e "$vc/bin$clarch/$cl" ]; then
|
||||||
cl="$vc/bin$clarch/cl"
|
cl="$vc/bin$clarch/cl"
|
||||||
export PATH="$PATH:$vc/bin$clarch"
|
export PATH="$PATH:$vc/bin$clarch"
|
||||||
export LIB="$(cygpath -w "$vc/LIB$clarch")"
|
export LIB="$(cygpath -w "$vc/LIB$clarch")"
|
||||||
export LIBPATH="$(cygpath -w "$vc/LIB$clarch")"
|
export LIBPATH="$(cygpath -w "$vc/LIB$clarch")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# finish up.
|
# finish up.
|
||||||
if [ -n "$cl" ]; then
|
if [ -n "$cl" ]; then
|
||||||
export INCLUDE="$(cygpath -w "$vc/INCLUDE")"
|
export INCLUDE="$(cygpath -w "$vc/INCLUDE")"
|
||||||
export INCLUDE="$INCLUDE;$(cygpath -w "${winkit/Lib/Include}/ucrt")"
|
export INCLUDE="$INCLUDE;$(cygpath -w "${winkit/Lib/Include}/ucrt")"
|
||||||
export LIB="$LIB;$(cygpath -w "$winkit/um/$arch")"
|
export LIB="$LIB;$(cygpath -w "$winkit/um/$arch")"
|
||||||
export LIB="$LIB;$(cygpath -w "$winkit/ucrt/$arch")"
|
export LIB="$LIB;$(cygpath -w "$winkit/ucrt/$arch")"
|
||||||
|
|
||||||
for d in "${(@s/;/)INCLUDE}"; do
|
for d in "${(@s/;/)INCLUDE}"; do
|
||||||
clang_flags+=(-I"$d")
|
clang_flags+=(-I"$d")
|
||||||
done
|
done
|
||||||
# ignore MSVC's non-standard deprecation warnings.
|
# ignore MSVC's non-standard deprecation warnings.
|
||||||
clang_flags+=(-D_CRT_SECURE_NO_WARNINGS)
|
clang_flags+=(-D_CRT_SECURE_NO_WARNINGS)
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
# YES_BASH
|
||||||
|
# NO_DASH
|
||||||
|
|
||||||
if [ -n "${ZSH_VERSION:-}" ]; then
|
if [ -n "${ZSH_VERSION:-}" ]; then
|
||||||
confirm() {
|
confirm() {
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
# YES_BASH
|
||||||
|
# YES_DASH
|
||||||
|
|
||||||
countdiff() {
|
countdiff() {
|
||||||
|
[ $# -gt 1 ] || { printf "%s\n" "$0: too few arguments" >&2; return 1; }
|
||||||
[ $# -le 2 ] || { printf "%s\n" "$0: too many arguments" >&2; return 1; }
|
[ $# -le 2 ] || { printf "%s\n" "$0: too many arguments" >&2; return 1; }
|
||||||
git --no-pager diff --stat --no-color --no-index "$1" "$2" \
|
git --no-pager diff --stat --no-color --no-index "$1" "$2" \
|
||||||
| awk '/changed/{print $4+$6;a=1}END{if(!a)print 0}'
|
| awk '/changed/{print $4+$6;a=1}END{if(!a)print 0}'
|
||||||
|
|
2
sh/cutv
2
sh/cutv
|
@ -1,5 +1,7 @@
|
||||||
#!/usr/bin/env zsh
|
#!/usr/bin/env zsh
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
# NO_BASH
|
||||||
|
# NO_DASH
|
||||||
|
|
||||||
cutv() {
|
cutv() {
|
||||||
[ $# -le 4 ] || { printf "%s\n" "$0: too many arguments" >&2; return 1; }
|
[ $# -le 4 ] || { printf "%s\n" "$0: too many arguments" >&2; return 1; }
|
||||||
|
|
4
sh/days
4
sh/days
|
@ -1,5 +1,7 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env sh
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
# YES_BASH
|
||||||
|
# YES_DASH
|
||||||
|
|
||||||
days() {
|
days() {
|
||||||
[ $# -le 1 ] || { printf "%s\n" "$0: too many arguments" >&2; return 1; }
|
[ $# -le 1 ] || { printf "%s\n" "$0: too many arguments" >&2; return 1; }
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#!/usr/bin/env zsh
|
#!/usr/bin/env zsh
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
# NO_BASH
|
||||||
|
# NO_DASH
|
||||||
|
|
||||||
dbusiest() {
|
dbusiest() {
|
||||||
[ $# -le 0 ] || { printf "%s\n" "$0: too many arguments" >&2; return 1; }
|
[ $# -le 0 ] || { printf "%s\n" "$0: too many arguments" >&2; return 1; }
|
||||||
|
|
2
sh/dfu
2
sh/dfu
|
@ -1,5 +1,7 @@
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
# YES_BASH
|
||||||
|
# YES_DASH
|
||||||
|
|
||||||
dfu() {
|
dfu() {
|
||||||
[ $# -le 0 ] || { printf "%s\n" "$0: too many arguments" >&2; return 1; }
|
[ $# -le 0 ] || { printf "%s\n" "$0: too many arguments" >&2; return 1; }
|
||||||
|
|
6
sh/disf
6
sh/disf
|
@ -1,6 +1,10 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env sh
|
||||||
# disassembles a function given its symbolic name.
|
# disassembles a function given its symbolic name.
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
# YES_BASH
|
||||||
|
# YES_DASH
|
||||||
|
|
||||||
|
# TODO: actually test that this works with dash.
|
||||||
|
|
||||||
function disf() {
|
function disf() {
|
||||||
[ $# -le 2 ] || { printf "%s\n" "$0: too many arguments" >&2; return 1; }
|
[ $# -le 2 ] || { printf "%s\n" "$0: too many arguments" >&2; return 1; }
|
||||||
|
|
2
sh/e
2
sh/e
|
@ -1,5 +1,7 @@
|
||||||
#!/usr/bin/env zsh
|
#!/usr/bin/env zsh
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
# NO_BASH
|
||||||
|
# NO_DASH
|
||||||
|
|
||||||
e() {
|
e() {
|
||||||
local editor=(${=EDITOR})
|
local editor=(${=EDITOR})
|
||||||
|
|
4
sh/ea
4
sh/ea
|
@ -1,6 +1,8 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env false
|
||||||
# remote file access (http file-sharing shenanigans)
|
# remote file access (http file-sharing shenanigans)
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
# YES_BASH
|
||||||
|
# YES_DASH
|
||||||
|
|
||||||
_REMOTE_DOMAIN="https://eaguru.guru"
|
_REMOTE_DOMAIN="https://eaguru.guru"
|
||||||
_REMOTE_DIR="t"
|
_REMOTE_DIR="t"
|
||||||
|
|
2
sh/echo2
2
sh/echo2
|
@ -1,5 +1,7 @@
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
# YES_BASH
|
||||||
|
# YES_DASH
|
||||||
|
|
||||||
echo2() {
|
echo2() {
|
||||||
local IFS=" "
|
local IFS=" "
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
# YES_BASH
|
||||||
|
# YES_DASH
|
||||||
|
|
||||||
explore() {
|
explore() {
|
||||||
|
[ -n "$MSYSTEM" ] || { printf "%s\n" "$0: only for MSYS2" >&2; return 1; }
|
||||||
[ $# -le 1 ] || { printf "%s\n" "$0: too many arguments" >&2; return 1; }
|
[ $# -le 1 ] || { printf "%s\n" "$0: too many arguments" >&2; return 1; }
|
||||||
explorer "$(cygpath -w "${1:-.}")"
|
explorer "$(cygpath -w "${1:-.}")"
|
||||||
}
|
}
|
||||||
|
|
2
sh/ff
2
sh/ff
|
@ -1,5 +1,7 @@
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
# YES_BASH
|
||||||
|
# YES_DASH
|
||||||
|
|
||||||
ff() {
|
ff() {
|
||||||
[ $# -le 1 ] || { printf "%s\n" "$0: too many arguments" >&2; return 1; }
|
[ $# -le 1 ] || { printf "%s\n" "$0: too many arguments" >&2; return 1; }
|
||||||
|
|
2
sh/has
2
sh/has
|
@ -1,5 +1,7 @@
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
# YES_BASH
|
||||||
|
# YES_DASH
|
||||||
|
|
||||||
has() {
|
has() {
|
||||||
if [ -n "$ZSH_VERSION" ]; then
|
if [ -n "$ZSH_VERSION" ]; then
|
||||||
|
|
5
sh/hex
5
sh/hex
|
@ -1,5 +1,10 @@
|
||||||
#!/usr/bin/env zsh
|
#!/usr/bin/env zsh
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
# YES_BASH
|
||||||
|
# YES_DASH
|
||||||
|
|
||||||
|
# though technically compatible with other shells,
|
||||||
|
# extra functionality is through zsh's extended arithmetic functions.
|
||||||
|
|
||||||
hex() {
|
hex() {
|
||||||
printf "%08X\n" "$(($@))"
|
printf "%08X\n" "$(($@))"
|
||||||
|
|
2
sh/ify
2
sh/ify
|
@ -1,5 +1,7 @@
|
||||||
#!/usr/bin/sh
|
#!/usr/bin/sh
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
# YES_BASH
|
||||||
|
# YES_DASH
|
||||||
|
|
||||||
ify() {
|
ify() {
|
||||||
[ $# -ge 2 ] || { printf "%s\n" "$0: too few arguments" >&2; return 1; }
|
[ $# -ge 2 ] || { printf "%s\n" "$0: too few arguments" >&2; return 1; }
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
# YES_BASH
|
||||||
|
# NO_DASH
|
||||||
|
|
||||||
is_empty() {
|
is_empty() {
|
||||||
while read -r; do
|
while read -r f; do
|
||||||
[ ! -d "$REPLY" ] && [ -s "$REPLY" ] && return 1
|
[ ! -d "$f" ] && [ -s "$f" ] && return 1
|
||||||
done < <(find ${1:-.})
|
done < <(find ${1:-.})
|
||||||
# TODO: done < <(find ${1:-.} -type f -print -quit)
|
# TODO: done < <(find ${1:-.} -type f -print -quit)
|
||||||
# this needs to skip empty files as well.
|
# this needs to skip empty files as well.
|
||||||
|
|
4
sh/isup
4
sh/isup
|
@ -1,5 +1,9 @@
|
||||||
#!/usr/bin/zsh
|
#!/usr/bin/zsh
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
# NO_BASH
|
||||||
|
# NO_DASH
|
||||||
|
|
||||||
|
# TODO: damned substrings. rewrite to be semi-portable.
|
||||||
|
|
||||||
isup() {
|
isup() {
|
||||||
local c
|
local c
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
# YES_BASH
|
||||||
|
# YES_DASH
|
||||||
|
|
||||||
maybesudo_() {
|
maybesudo_() {
|
||||||
local name
|
local name
|
||||||
local env_cleanup=0
|
local env_cleanup=0
|
||||||
while getopts ':AEHKPSVbhiklnsvC:U:g:p:r:t:u:' name; do
|
while getopts :AEHKPSVbhiklnsvC:U:g:p:r:t:u: name; do
|
||||||
case $name in
|
case $name in
|
||||||
K|V|k)
|
K|V|k)
|
||||||
# K: sure kill
|
# K: sure kill
|
||||||
|
@ -122,6 +124,8 @@ maybesudo_() {
|
||||||
|
|
||||||
else
|
else
|
||||||
# run it in a subshell so it won't affect ours.
|
# run it in a subshell so it won't affect ours.
|
||||||
|
# TODO: run through env anyway for consistency.
|
||||||
|
# (`maybesudo export` should fail)
|
||||||
( "$@"; )
|
( "$@"; )
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,19 @@
|
||||||
#!/usr/bin/env zsh
|
#!/usr/bin/env dash
|
||||||
# crontab usage:
|
# crontab usage:
|
||||||
#* * * * * minutemaid 9 cd repo && git pull # runs every nine minutes
|
#* * * * * minutemaid 9 ~/work/do_my_bidding # runs every nine minutes
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
# YES_BASH
|
||||||
|
# YES_DASH
|
||||||
|
|
||||||
minutemaid() {
|
minutemaid() {
|
||||||
local offset=0 opt=
|
local offset=0 name
|
||||||
while getopts 'o:h' opt; do
|
while getopts 'o:h' name; do
|
||||||
case $opt in
|
case $name in
|
||||||
o) offset="$OPTARG";;
|
o) offset="$OPTARG";;
|
||||||
?) local fd=0
|
?) local fd=0
|
||||||
[ $opt = h ] && fd=0 || fd=2
|
[ $name = h ] && fd=1 || fd=2
|
||||||
echo -E "usage: $0 [-o offset] {interval} [{command} [{args...}]]" >&$fd
|
printf "%s\n" "usage: $0 [-o offset] {interval} [{command} [{args...}]]" >&$fd
|
||||||
[ $opt = h ] && return 0 || return 1;;
|
[ $name = h ] && return 0 || return 1;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
shift $((OPTIND-1))
|
shift $((OPTIND-1))
|
||||||
|
@ -20,13 +22,10 @@ minutemaid() {
|
||||||
shift
|
shift
|
||||||
|
|
||||||
local sec="$(date +%s)"
|
local sec="$(date +%s)"
|
||||||
let min=sec/60+offset
|
local min="$((sec/60+offset))"
|
||||||
let mod=min%interval
|
local mod="$((min%interval))"
|
||||||
if [ $# -gt 0 ]; then
|
if [ $# -gt 0 ]; then
|
||||||
local cmd="${1}"
|
[ $mod -ne 0 ] || "$@"
|
||||||
shift
|
|
||||||
|
|
||||||
[ $mod -eq 0 ] && "$cmd" "$@"
|
|
||||||
else
|
else
|
||||||
[ $mod -eq 0 ] && return 0 || return 1
|
[ $mod -eq 0 ] && return 0 || return 1
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -2,6 +2,10 @@
|
||||||
# the first expression is taken from this FAQ:
|
# the first expression is taken from this FAQ:
|
||||||
# https://perldoc.perl.org/perlfaq6.html#How-do-I-use-a-regular-expression-to-strip-C-style-comments-from-a-file%3f
|
# https://perldoc.perl.org/perlfaq6.html#How-do-I-use-a-regular-expression-to-strip-C-style-comments-from-a-file%3f
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
# YES_BASH
|
||||||
|
# YES_DASH
|
||||||
|
|
||||||
|
# TODO: what's the minimum version of perl required for this?
|
||||||
|
|
||||||
noccom() {
|
noccom() {
|
||||||
[ -s ~/opt/local/bin/noccom ] || cat > ~/opt/local/bin/noccom <<EOF
|
[ -s ~/opt/local/bin/noccom ] || cat > ~/opt/local/bin/noccom <<EOF
|
||||||
|
|
2
sh/note
2
sh/note
|
@ -1,5 +1,7 @@
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
# YES_BASH
|
||||||
|
# YES_DASH
|
||||||
|
|
||||||
note() {
|
note() {
|
||||||
local IFS=" "
|
local IFS=" "
|
||||||
|
|
10
sh/now
10
sh/now
|
@ -1,5 +1,9 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env sh
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
# YES_BASH
|
||||||
|
# YES_DASH
|
||||||
|
|
||||||
|
# dash compatibility is not fully tested, but it's probably okay.
|
||||||
|
|
||||||
now() {
|
now() {
|
||||||
[ $# -le 1 ] || { printf "%s\n" "$0: too many arguments" >&2; return 1; }
|
[ $# -le 1 ] || { printf "%s\n" "$0: too many arguments" >&2; return 1; }
|
||||||
|
@ -32,8 +36,8 @@ now() {
|
||||||
M=${M#0*}
|
M=${M#0*}
|
||||||
S=${S#0*}
|
S=${S#0*}
|
||||||
|
|
||||||
local ms=
|
local ms
|
||||||
let 'ms=(H*60*60+M*60+S)*1000+N/1000000'
|
ms=$(((H*60*60+M*60+S)*1000+N/1000000))
|
||||||
ms=$(printf '%08i' $ms)
|
ms=$(printf '%08i' $ms)
|
||||||
echo "${F}_${ms}"
|
echo "${F}_${ms}"
|
||||||
}
|
}
|
||||||
|
|
2
sh/pacbm
2
sh/pacbm
|
@ -1,5 +1,7 @@
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
# YES_BASH
|
||||||
|
# YES_DASH
|
||||||
|
|
||||||
pacbm() {
|
pacbm() {
|
||||||
expac -s '%m %n' | awk '
|
expac -s '%m %n' | awk '
|
||||||
|
|
8
sh/pause
8
sh/pause
|
@ -1,11 +1,13 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
# YES_BASH
|
||||||
|
# NO_DASH
|
||||||
|
|
||||||
pause() {
|
pause() {
|
||||||
[ -n "${ZSH_VERSION:-}" ] \
|
[ -n "${ZSH_VERSION:-}" ] \
|
||||||
&& read -sk '?Press any key to continue
|
&& read -sk '?Press any key to continue
|
||||||
' || read -n1 -u 1 -sp 'Press any key to continue
|
' || read -n1 -u 1 -sp 'Press any key to continue
|
||||||
'
|
'
|
||||||
}
|
}
|
||||||
|
|
||||||
[ "${SOURCING:-0}" -gt 0 ] || pause "$@"
|
[ "${SOURCING:-0}" -gt 0 ] || pause "$@"
|
||||||
|
|
4
sh/pegg
4
sh/pegg
|
@ -1,5 +1,9 @@
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
# YES_BASH
|
||||||
|
# YES_DASH
|
||||||
|
|
||||||
|
# TODO: source pippy here? this may affect dash compatibility.
|
||||||
|
|
||||||
pegg() {
|
pegg() {
|
||||||
[ $# -ge 2 ] || { printf "%s\n" "$0: too few arguments" >&2; return 1; }
|
[ $# -ge 2 ] || { printf "%s\n" "$0: too few arguments" >&2; return 1; }
|
||||||
|
|
2
sh/pippy
2
sh/pippy
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env
|
#!/usr/bin/env sh
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
|
||||||
#. ~/sh/maybesudo
|
#. ~/sh/maybesudo
|
||||||
|
|
4
sh/pre
4
sh/pre
|
@ -1,5 +1,7 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env sh
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
# YES_BASH
|
||||||
|
# YES_DASH
|
||||||
|
|
||||||
pre() {
|
pre() {
|
||||||
if [ -n "${ZSH_VERSION:-}" ]; then
|
if [ -n "${ZSH_VERSION:-}" ]; then
|
||||||
|
|
3
sh/psbm
3
sh/psbm
|
@ -1,7 +1,10 @@
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
# YES_BASH
|
||||||
|
# YES_DASH
|
||||||
|
|
||||||
psbm() {
|
psbm() {
|
||||||
|
[ -z "$MSYSTEM" ] || { printf "%s\n" "$0: unsupported on MSYS2" >&2; return 1; }
|
||||||
ps axco rss,pid,command | awk '
|
ps axco rss,pid,command | awk '
|
||||||
NR>1&&$1>0{t+=$1;printf("%8.2fM %7d %s\n",$1/1024,$2,$3)}
|
NR>1&&$1>0{t+=$1;printf("%8.2fM %7d %s\n",$1/1024,$2,$3)}
|
||||||
END{printf("%8.2fM\n",t/1024)}
|
END{printf("%8.2fM\n",t/1024)}
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
# YES_BASH
|
||||||
|
# YES_DASH
|
||||||
|
|
||||||
randir() {
|
randir() {
|
||||||
find -maxdepth 1 -type d \( -path '/root' -prune -o -print \) | tail -n+2 | shuf | head -1
|
find -maxdepth 1 -type d \( -path '/root' -prune -o -print \) | tail -n+2 | shuf | head -n1
|
||||||
}
|
}
|
||||||
|
|
||||||
[ "${SOURCING:-0}" -gt 0 ] || randir "$@"
|
[ "${SOURCING:-0}" -gt 0 ] || randir "$@"
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
# YES_BASH
|
||||||
|
# YES_DASH
|
||||||
|
|
||||||
refresh() {
|
refresh() {
|
||||||
hash -r
|
hash -r
|
||||||
|
|
6
sh/sc
6
sh/sc
|
@ -1,6 +1,8 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
. ~/.ea # FIXME: don't do this? somehow?
|
SOURCING=$((SOURCING+1))
|
||||||
|
. ~/sh/ea # FIXME: don't do this? somehow?
|
||||||
|
SOURCING=$((SOURCING-1))
|
||||||
|
|
||||||
sc_shorten() {
|
sc_shorten() {
|
||||||
REPLY="${1:2:2}${1:5:2}${1:8:2}${1:11:12}"
|
REPLY="${1:2:2}${1:5:2}${1:8:2}${1:11:12}"
|
||||||
|
@ -59,4 +61,4 @@ sc() {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
sc "$@"
|
[ "${SOURCING:-0}" -gt 0 ] || sc "$@"
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env sh
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
# YES_BASH
|
||||||
|
# YES_DASH
|
||||||
|
|
||||||
scramble() {
|
scramble() {
|
||||||
|
[ $# -eq 0 ] || { printf "%s\n" "$0: does not take arguments" >&2; return 1; }
|
||||||
local eggs='s/@\(\w\)\(\w\)\(\w\)/@\3\1@\2/g'
|
local eggs='s/@\(\w\)\(\w\)\(\w\)/@\3\1@\2/g'
|
||||||
sed \
|
sed \
|
||||||
-e 's/\b\w/&@/g' \
|
-e 's/\b\w/&@/g' \
|
||||||
|
|
10
sh/scropt
10
sh/scropt
|
@ -1,12 +1,16 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
|
||||||
|
#SOURCING=$((SOURCING+1))
|
||||||
|
#. ~/sh/now # FIXME: don't do this?
|
||||||
|
#SOURCING=$((SOURCING-1))
|
||||||
|
|
||||||
scropt() {
|
scropt() {
|
||||||
local now=
|
local now=$(now)
|
||||||
which ~/sh/now 2>/dev/null >/dev/null && now=$(~/sh/now) || now=$(date +%F_%T)
|
[ $? -eq 0 ] || return $?
|
||||||
local fn="$HOME/play/$now.png"
|
local fn="$HOME/play/$now.png"
|
||||||
scrot "$fn" -e "optipng -quiet \$f" "$@"
|
scrot "$fn" -e "optipng -quiet \$f" "$@"
|
||||||
echo "$fn"
|
[ $? -eq 0 ] && echo "$fn" || return $?
|
||||||
}
|
}
|
||||||
|
|
||||||
[ "${SOURCING:-0}" -gt 0 ] || scropt "$@"
|
[ "${SOURCING:-0}" -gt 0 ] || scropt "$@"
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
# YES_BASH
|
||||||
|
# YES_DASH
|
||||||
|
|
||||||
similar() {
|
similar() {
|
||||||
|
[ $# -eq 0 ] || { printf "%s\n" "$0: does not take arguments" >&2; return 1; }
|
||||||
awk '
|
awk '
|
||||||
{
|
{
|
||||||
i=0
|
i=0
|
||||||
|
|
11
sh/slit
11
sh/slit
|
@ -1,9 +1,14 @@
|
||||||
#!/usr/bin/env zsh
|
#!/usr/bin/env dash
|
||||||
# from https://github.com/sorin-ionescu/prezto/
|
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
# YES_BASH
|
||||||
|
# YES_DASH
|
||||||
|
|
||||||
slit() {
|
slit() {
|
||||||
awk "{ print ${(j:,:):-\$${^@}} }"
|
[ $# -gt 0 ] || { printf "%s\n" "$0: too few arguments" >&2; return 1; }
|
||||||
|
awk "{ print $(printf ',$%s' $@ | cut -b2-) }"
|
||||||
|
|
||||||
|
# via: https://github.com/sorin-ionescu/prezto/
|
||||||
|
#awk "{ print ${(j:,:):-\$${^@}} }"
|
||||||
}
|
}
|
||||||
|
|
||||||
[ "${SOURCING:-0}" -gt 0 ] || slit "$@"
|
[ "${SOURCING:-0}" -gt 0 ] || slit "$@"
|
||||||
|
|
15
sh/slitt
15
sh/slitt
|
@ -1,10 +1,17 @@
|
||||||
#!/usr/bin/env zsh
|
#!/usr/bin/env dash
|
||||||
# via: https://github.com/sorin-ionescu/prezto/
|
# this version of slit uses tabs for input/output field separators.
|
||||||
# this version uses tabs for input/output field separators.
|
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
# YES_BASH
|
||||||
|
# YES_DASH
|
||||||
|
|
||||||
slitt() {
|
slitt() {
|
||||||
awk "BEGIN { FS=\"\\t\"; OFS=\"\\t\" } { print ${(j:,:):-\$${^@}} }"
|
[ $# -gt 0 ] || { printf "%s\n" "$0: too few arguments" >&2; return 1; }
|
||||||
|
#echo "$@" | awk '{for(i=1;i<NF;i++)printf"$%s,",$(i);print"$"$NF}'
|
||||||
|
local fields="$(printf ',$%s' $@ | cut -b2-)"
|
||||||
|
awk "BEGIN { FS=\"\\t\"; OFS=\"\\t\" } { print $fields }"
|
||||||
|
|
||||||
|
# via: https://github.com/sorin-ionescu/prezto/
|
||||||
|
#awk "BEGIN { FS=\"\\t\"; OFS=\"\\t\" } { print ${(j:,:):-\$${^@}} }"
|
||||||
}
|
}
|
||||||
|
|
||||||
[ "${SOURCING:-0}" -gt 0 ] || slitt "$@"
|
[ "${SOURCING:-0}" -gt 0 ] || slitt "$@"
|
||||||
|
|
2
sh/sum
2
sh/sum
|
@ -1,5 +1,7 @@
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
# YES_BASH
|
||||||
|
# YES_DASH
|
||||||
|
|
||||||
sum() {
|
sum() {
|
||||||
local sum=0
|
local sum=0
|
||||||
|
|
5
sh/sv
5
sh/sv
|
@ -1,7 +1,10 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env sh
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
# YES_BASH
|
||||||
|
# YES_DASH
|
||||||
|
|
||||||
sv() {
|
sv() {
|
||||||
|
[ $# -le 1 ] || { printf "%s\n" "$0: too many arguments" >&2; return 1; }
|
||||||
awk "-F${1:- }" '
|
awk "-F${1:- }" '
|
||||||
NF>1{f[$1]=substr($0,length($1)+1+length(FS))}END{for(k in f)print k FS f[k]}
|
NF>1{f[$1]=substr($0,length($1)+1+length(FS))}END{for(k in f)print k FS f[k]}
|
||||||
'
|
'
|
||||||
|
|
9
sh/tpad
9
sh/tpad
|
@ -1,10 +1,11 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env sh
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
# YES_BASH
|
||||||
|
# YES_DASH
|
||||||
|
|
||||||
tpad() {
|
tpad() {
|
||||||
while [ $# -gt 0 ]; do
|
for f; do
|
||||||
gm convert -bordercolor "#000000FF" -border 1x1 "$1" "${1/.png/}.tt.png";
|
gm convert -bordercolor "#000000FF" -border 1x1 "$f" "${f%.png}.tt.png"
|
||||||
shift
|
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
sh/trash
2
sh/trash
|
@ -1,5 +1,7 @@
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
# YES_BASH
|
||||||
|
# YES_DASH
|
||||||
|
|
||||||
trash() {
|
trash() {
|
||||||
[ $# -le 1 ] || { printf "%s\n" "$0: too many arguments" >&2; return 1; }
|
[ $# -le 1 ] || { printf "%s\n" "$0: too many arguments" >&2; return 1; }
|
||||||
|
|
5
sh/trunc
5
sh/trunc
|
@ -1,7 +1,10 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env sh
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
# YES_BASH
|
||||||
|
# YES_DASH
|
||||||
|
|
||||||
trunc() {
|
trunc() {
|
||||||
|
[ $# -le 1 ] || { printf "%s\n" "$0: too many arguments" >&2; return 1; }
|
||||||
COLUMNS=${COLUMNS:-$(tput cols)}
|
COLUMNS=${COLUMNS:-$(tput cols)}
|
||||||
awk -vL=${1:-$COLUMNS} '{e=length>L?"…":"";print substr($0,0,L-(e?1:0)) e}'
|
awk -vL=${1:-$COLUMNS} '{e=length>L?"…":"";print substr($0,0,L-(e?1:0)) e}'
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#!/usr/bin/env zsh
|
#!/usr/bin/env zsh
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
# NO_BASH
|
||||||
|
# NO_DASH
|
||||||
|
|
||||||
unscreen() {
|
unscreen() {
|
||||||
local pids="$(screen -ls | fgrep "$1" | cut -d. -f1)"
|
local pids="$(screen -ls | fgrep "$1" | cut -d. -f1)"
|
||||||
|
|
2
sh/wat
2
sh/wat
|
@ -1,5 +1,7 @@
|
||||||
#!/usr/bin/env zsh
|
#!/usr/bin/env zsh
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
# NO_BASH
|
||||||
|
# NO_DASH
|
||||||
|
|
||||||
# wat - a better and recursive which/whence
|
# wat - a better and recursive which/whence
|
||||||
# via: https://leahneukirchen.org/dotfiles/tools.html
|
# via: https://leahneukirchen.org/dotfiles/tools.html
|
||||||
|
|
14
sh/wipe
14
sh/wipe
|
@ -1,14 +1,20 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env sh
|
||||||
# YES_ZSH
|
# YES_ZSH
|
||||||
|
# YES_BASH
|
||||||
|
# YES_DASH
|
||||||
|
|
||||||
wipe() {
|
wipe() {
|
||||||
# TODO: rename because wipe(1) already exists.
|
# TODO: rename because wipe(1) already exists.
|
||||||
[ $# -le 0 ] || { printf "%s\n" "$0: too many arguments" >&2; return 1; }
|
[ $# -le 0 ] || { printf "%s\n" "$0: too many arguments" >&2; return 1; }
|
||||||
clear
|
clear
|
||||||
clear # twice because mintty is weird
|
clear # twice because mintty is weird
|
||||||
echo "\033[30m\033[107m"
|
echo $'\033[30m\033[107m' | tr -d '$'
|
||||||
printf "*%.0s" {1..$COLUMNS}
|
if [ -n "${ZSH_VERSION:-}" ]; then
|
||||||
echo "\033[0m\n"
|
printf '*%.0s' {1..$COLUMNS}
|
||||||
|
else
|
||||||
|
tput cols | awk '{for(i=0;i<$0;i++)printf "*"}'
|
||||||
|
fi
|
||||||
|
echo $'\033[0m\n' | tr -d '$'
|
||||||
}
|
}
|
||||||
|
|
||||||
[ "${SOURCING:-0}" -gt 0 ] || wipe "$@"
|
[ "${SOURCING:-0}" -gt 0 ] || wipe "$@"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user