mirror of
https://github.com/notwa/rc
synced 2024-12-21 21:49:40 -08:00
add compatibility flags for a bunch of scripts (part 4)
This commit is contained in:
parent
7c9482c02c
commit
6bff3980fb
13 changed files with 17 additions and 17 deletions
|
@ -1,8 +1,8 @@
|
|||
#!/usr/bin/sh
|
||||
# compat: +ash +bash +dash +zsh
|
||||
# compat: +ash +bash +dash +hush +ksh +mksh +oksh +osh +posh +yash +zsh
|
||||
|
||||
sortip() { ### @- sort lines numerically by IPv4 segments.
|
||||
sort -t . -k 1,1n -k 2,2n -k 3,3n -k 4,4n "$@"
|
||||
LC_ALL=C sort -t . -k 1,1n -k 2,2n -k 3,3n -k 4,4n "$@"
|
||||
}
|
||||
|
||||
[ -n "${preload+-}" ] || sortip "$@"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env sh
|
||||
# compat: +ash +bash +dash +zsh
|
||||
# compat: +ash +bash +dash +hush -ksh +mksh -oksh +osh +posh +yash +zsh
|
||||
|
||||
__subdue() { ### @subdue
|
||||
### reconfigure your terminal's color scheme using a preset for [recolor.](#recolor)
|
||||
|
|
2
sh/sum
2
sh/sum
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env sh
|
||||
# compat: +ash +bash +dash +zsh
|
||||
# compat: +ash +bash +dash +hush -ksh +mksh +oksh +osh +posh +yash +zsh
|
||||
|
||||
sum() { ### @-
|
||||
### compute the summation of its arguments without forking processes.
|
||||
|
|
2
sh/sv
2
sh/sv
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env sh
|
||||
# compat: +ash +bash +dash +zsh YES_BB_AWK
|
||||
# compat: +ash +bash +dash +hush +ksh +mksh +oksh +osh +posh +yash +zsh YES_BB_AWK
|
||||
|
||||
sv() { ### @-
|
||||
### collect the lastmost value of every key.
|
||||
|
|
2
sh/trash
2
sh/trash
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env sh
|
||||
# compat: +ash +bash +dash +zsh
|
||||
# compat: +ash +bash +dash +hush +ksh +mksh +oksh +osh +posh +yash +zsh
|
||||
|
||||
trash() { ### @-
|
||||
### output a given number of bytes from `/dev/random`.
|
||||
|
|
6
sh/trunc
6
sh/trunc
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env sh
|
||||
# compat: +ash +bash +dash +zsh YES_BB_AWK
|
||||
# compat: +ash +bash +dash +hush +ksh +mksh +oksh +osh +posh +yash +zsh YES_BB_AWK
|
||||
|
||||
trunc() { ### @-
|
||||
### truncate text to fit within your terminal using the unicode character `…`.
|
||||
|
@ -12,8 +12,8 @@ trunc() { ### @-
|
|||
### ```
|
||||
|
||||
[ $# -le 1 ] || { printf "%s\n" "$0: too many arguments" >&2; return 1; }
|
||||
COLUMNS=${COLUMNS:-$(tput cols)}
|
||||
awk -vL=${1:-$COLUMNS} '{e=length()>L?"…":"";print substr($0,0,L-(e?1:0)) e}'
|
||||
COLUMNS="${COLUMNS:-"$(tput cols)"}"
|
||||
awk -vL="${1:-$COLUMNS}" '{e=length()>L?"…":"";print substr($0,0,L-(e?1:0)) e}'
|
||||
}
|
||||
|
||||
[ -n "${preload+-}" ] || trunc "$@"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env zsh
|
||||
# compat: -ash -bash -dash +zsh
|
||||
# compat: -ash -bash -dash -hush -ksh -mksh -oksh -osh -posh -yash +zsh
|
||||
|
||||
unarchive() { ### @- extract the contents of an archive file in one of many formats.
|
||||
### borrowed from [prezto.](https://github.com/sorin-ionescu/prezto)
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#!/usr/bin/env sh
|
||||
# compat: +ash +bash +dash +zsh
|
||||
# compat: +ash +bash +dash +hush +ksh +mksh +oksh +osh +posh +yash +zsh
|
||||
|
||||
unwrap() { ### @- join paragraphs into one line each.
|
||||
awk '\''BEGIN{RS="\n\n";FS="\n"}{for(i=1;i<=NF;i++)printf "%s ",$i;print "\n"}'\'
|
||||
awk 'BEGIN{RS="\n\n";FS="\n"}{for(i=1;i<=NF;i++)printf "%s ",$i;print "\n"}'
|
||||
}
|
||||
|
||||
[ -n "${preload+-}" ] || unwrap "$@"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env sh
|
||||
# compat: +ash +bash +dash +zsh
|
||||
# compat: +ash +bash +dash -hush -ksh +mksh -oksh +osh +posh +yash +zsh
|
||||
|
||||
v_domap() {
|
||||
argc $# -eq 1 "$0" || return
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env sh
|
||||
# compat: +ash +bash +dash +zsh
|
||||
# compat: +ash +bash +dash -hush -ksh +mksh -oksh +osh +posh +yash +zsh
|
||||
|
||||
v_lower() { ### @- transform the contents of a variable to lowercase.
|
||||
argc $# -eq 1 "$0" || return
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env sh
|
||||
# compat: +ash +bash +dash +zsh
|
||||
# compat: +ash +bash +dash -hush -ksh +mksh -oksh +osh +posh +yash +zsh
|
||||
|
||||
v_upper() { ### @- transform the contents of a variable to uppercase.
|
||||
argc $# -eq 1 "$0" || return
|
||||
|
|
2
sh/wat
2
sh/wat
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env zsh
|
||||
# compat: -ash -bash -dash +zsh
|
||||
# compat: -ash -bash -dash -hush -ksh -mksh -oksh -osh -posh -yash +zsh
|
||||
|
||||
# wat - a better and recursive which/whence
|
||||
# via: https://leahneukirchen.org/dotfiles/tools.html
|
||||
|
|
2
sh/xxp
2
sh/xxp
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env sh
|
||||
# compat: +ash +bash +dash +zsh
|
||||
# compat: +ash +bash +dash +hush +ksh +mksh +oksh +osh +posh +yash +zsh
|
||||
|
||||
xxp() { ### @-
|
||||
### act like `xxd -p`, but nicely formatted.
|
||||
|
|
Loading…
Reference in a new issue