mirror of
https://github.com/notwa/rc
synced 2024-05-04 04:33:24 -07:00
parent
90038bf996
commit
eaa94d66b9
3
sh/aur
3
sh/aur
|
@ -50,7 +50,7 @@ aur() { ### @-
|
||||||
|
|
||||||
# TODO: option to auto install dependencies
|
# TODO: option to auto install dependencies
|
||||||
|
|
||||||
local built=
|
local built= p=
|
||||||
for p in "$@"; do
|
for p in "$@"; do
|
||||||
cd "$bd"
|
cd "$bd"
|
||||||
local download_fail=0
|
local download_fail=0
|
||||||
|
@ -115,6 +115,7 @@ aur() { ### @-
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
local recent=
|
||||||
cd "$bd"
|
cd "$bd"
|
||||||
if [ -n "$built" ] && [ $o_install -eq 1 ]; then
|
if [ -n "$built" ] && [ $o_install -eq 1 ]; then
|
||||||
if [ $o_all_at_once -eq 1 ]; then
|
if [ $o_all_at_once -eq 1 ]; then
|
||||||
|
|
3
sh/bak
3
sh/bak
|
@ -20,8 +20,7 @@ bak() { ### @-
|
||||||
### -rw-r--r-- 1 notwa None 0 Dec 25 2001 butts.bak.bak
|
### -rw-r--r-- 1 notwa None 0 Dec 25 2001 butts.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 f=
|
||||||
local f=
|
|
||||||
for f; do
|
for f; do
|
||||||
if [ -e "$f.bak" ]; then
|
if [ -e "$f.bak" ]; then
|
||||||
bak "$f.bak" || { ret=1; continue; }
|
bak "$f.bak" || { ret=1; continue; }
|
||||||
|
|
|
@ -16,7 +16,7 @@ baknow() { ### @- backup files by appending their timestamps given by [`now`.](#
|
||||||
### -rw-r--r-- 1 notwa None 0 Dec 25 2001 butts.2001-12-26_01800000.bak
|
### -rw-r--r-- 1 notwa None 0 Dec 25 2001 butts.2001-12-26_01800000.bak
|
||||||
### ```
|
### ```
|
||||||
argc $# -ge 1 "$0" || return
|
argc $# -ge 1 "$0" || return
|
||||||
local ret=0
|
local ret=0 f=
|
||||||
for f; do
|
for f; do
|
||||||
cp -ip "$f" "$f.$(now "$f").bak" || ret=1
|
cp -ip "$f" "$f.$(now "$f").bak" || ret=1
|
||||||
done
|
done
|
||||||
|
|
2
sh/baks
2
sh/baks
|
@ -19,7 +19,7 @@ baks() { ### @-
|
||||||
### -rw-r--r-- 1 notwa None 0 Dec 25 2001 butts.21-08-01_14-54-07.bak
|
### -rw-r--r-- 1 notwa None 0 Dec 25 2001 butts.21-08-01_14-54-07.bak
|
||||||
### -rw-r--r-- 1 notwa None 0 Dec 25 2001 butts.21-08-01_14-54-09.bak
|
### -rw-r--r-- 1 notwa None 0 Dec 25 2001 butts.21-08-01_14-54-09.bak
|
||||||
### ```
|
### ```
|
||||||
local ret=0
|
local ret=0 fp=
|
||||||
for fp; do
|
for fp; do
|
||||||
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"
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
colors2() {
|
colors2() {
|
||||||
[ $# -eq 0 ] || { printf "%s\n" "$0: does not take arguments" >&2; return 1; }
|
[ $# -eq 0 ] || { printf "%s\n" "$0: does not take arguments" >&2; return 1; }
|
||||||
|
local a= b= i= j=
|
||||||
for a in 0 60; do
|
for a in 0 60; do
|
||||||
for j in 40 41 43 42 46 44 45 47; do
|
for j in 40 41 43 42 46 44 45 47; do
|
||||||
printf ' \033[%s;%sm %03d \033[m' '48;5;16' $((a+j-10)) $((a+j))
|
printf ' \033[%s;%sm %03d \033[m' '48;5;16' $((a+j-10)) $((a+j))
|
||||||
|
|
|
@ -90,6 +90,8 @@ compile() { ### @-
|
||||||
local clang="$(whence -p clang 2>/dev/null)"
|
local clang="$(whence -p clang 2>/dev/null)"
|
||||||
local clang_flags=() # currently just for clang-msvc
|
local clang_flags=() # currently just for clang-msvc
|
||||||
|
|
||||||
|
local flag= d= # iterator variables
|
||||||
|
|
||||||
local cl= vc=
|
local cl= vc=
|
||||||
if [ -n "$MSYSTEM" ]; then # using msys2?
|
if [ -n "$MSYSTEM" ]; then # using msys2?
|
||||||
if [ -z "$clang" ]; then # don't have native clang?
|
if [ -z "$clang" ]; then # don't have native clang?
|
||||||
|
|
|
@ -125,6 +125,7 @@ document1() {
|
||||||
|
|
||||||
# first section:
|
# first section:
|
||||||
printf '\n## %s\n' 'shell functions' >> "$out" || return 5
|
printf '\n## %s\n' 'shell functions' >> "$out" || return 5
|
||||||
|
local f=
|
||||||
for f in sh/*; do
|
for f in sh/*; do
|
||||||
[ -e "$f" ] || continue # make sure glob went through
|
[ -e "$f" ] || continue # make sure glob went through
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
# probably not compatible with busybox ps because its column 2 isn't PID.
|
# probably not compatible with busybox ps because its column 2 isn't PID.
|
||||||
|
|
||||||
running() { ### @- WIP
|
running() { ### @- WIP
|
||||||
local cmd=0 pid=0
|
local cmd=0 pid=0 col=
|
||||||
local usage='usage: running {cmd|pid} ...'
|
local usage='usage: running {cmd|pid} ...'
|
||||||
[ $# -gt 0 ] || { printf '%s\n' "$usage" >&2; return 2; }
|
[ $# -gt 0 ] || { printf '%s\n' "$usage" >&2; return 2; }
|
||||||
for col; do
|
for col; do
|
||||||
|
|
2
sh/sc
2
sh/sc
|
@ -53,7 +53,7 @@ sc() { ### @-
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
local clipboard=""
|
local clipboard="" f=
|
||||||
for f; do
|
for f; do
|
||||||
f="$(readlink -f "$f")"
|
f="$(readlink -f "$f")"
|
||||||
if [ ! -e "$f" ]; then
|
if [ ! -e "$f" ]; then
|
||||||
|
|
1
sh/slit
1
sh/slit
|
@ -10,6 +10,7 @@ slit() { ### @-
|
||||||
### view specific columns of text.
|
### view specific columns of text.
|
||||||
[ $# -gt 0 ] \
|
[ $# -gt 0 ] \
|
||||||
|| { printf '%s: too few arguments\n' "$0" >&2; return 1; }
|
|| { printf '%s: too few arguments\n' "$0" >&2; return 1; }
|
||||||
|
local arg=
|
||||||
for arg; do
|
for arg; do
|
||||||
[ "$arg" -ge 0 ] 2>/dev/null \
|
[ "$arg" -ge 0 ] 2>/dev/null \
|
||||||
|| { printf '%s: not a nonnegative integer: %s\n' "$0" "$arg"; return 1; };
|
|| { printf '%s: not a nonnegative integer: %s\n' "$0" "$arg"; return 1; };
|
||||||
|
|
1
sh/slitt
1
sh/slitt
|
@ -11,6 +11,7 @@ slitt() { ### @-
|
||||||
### this version of `slit` uses tabs for its field separators.
|
### this version of `slit` uses tabs for its field separators.
|
||||||
[ $# -gt 0 ] \
|
[ $# -gt 0 ] \
|
||||||
|| { printf '%s: too few arguments\n' "$0" >&2; return 1; }
|
|| { printf '%s: too few arguments\n' "$0" >&2; return 1; }
|
||||||
|
local arg=
|
||||||
for arg; do
|
for arg; do
|
||||||
[ "$arg" -ge 0 ] 2>/dev/null \
|
[ "$arg" -ge 0 ] 2>/dev/null \
|
||||||
|| { printf '%s: not a nonnegative integer: %s\n' "$0" "$arg"; return 1; };
|
|| { printf '%s: not a nonnegative integer: %s\n' "$0" "$arg"; return 1; };
|
||||||
|
|
2
sh/sum
2
sh/sum
|
@ -14,7 +14,7 @@ sum() { ### @-
|
||||||
### ```
|
### ```
|
||||||
###
|
###
|
||||||
### **TODO:** consider renaming because sum(1) already exists.
|
### **TODO:** consider renaming because sum(1) already exists.
|
||||||
local sum=0
|
local sum=0 i=
|
||||||
for i; do
|
for i; do
|
||||||
i="${i%,}"
|
i="${i%,}"
|
||||||
: $((sum+=i))
|
: $((sum+=i))
|
||||||
|
|
1
sh/wat
1
sh/wat
|
@ -11,6 +11,7 @@ wat() { ### @-
|
||||||
###
|
###
|
||||||
### written by [leah2.](https://leahneukirchen.org/)
|
### written by [leah2.](https://leahneukirchen.org/)
|
||||||
( # constrain unalias
|
( # constrain unalias
|
||||||
|
local cmd=
|
||||||
for cmd; do
|
for cmd; do
|
||||||
if (( $+aliases[$cmd] )); then
|
if (( $+aliases[$cmd] )); then
|
||||||
printf '%s: aliased to %s\n' $cmd $aliases[$cmd]
|
printf '%s: aliased to %s\n' $cmd $aliases[$cmd]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user