This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
readkey() { | |
local char | |
IFS= \ | |
read -rs -d '' -N1 key || return $? # use -n1 on older versions | |
while | |
case "$key" in | |
('') key=$'\n' ; break ;; # compensate for bug | |
( $'\e[M'??? ) break ;; # mouse report | |
( $'\e' | $'\e[' | $'\e['[?O] | $'\e['*[\;0-9] | $'\e[M'* | $'\eO' ) ;; | |
( [$'\xc0'-\$'xfe'] \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
pid=${1:-$PPID} | |
signals="$(trap -l)" | |
declare -A SIG | |
for s in ${signals//') '/=} | |
do | |
i=${s%%=*} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use utf8; | |
binmode STDOUT, ":utf8"; | |
while (<>) { | |
s/ / /g; | |
s/\t/\t\t/g; | |
s/[!-~]/chr(ord($&)+0xff00-0x20)/xge; | |
print $_; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
dryrun=false | |
verbose=false | |
root=/ | |
[[ "--help" = "$1"* && $1 = --h* || "$*" = -h ]] && { cat <<EndOfHelp ; exit 0 ; } | |
${0##*/} [-v|-q] [-n|-N] [-r /PATH] [PATH ...] | |
EndOfHelp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ alias randomly='if ((RANDOM%2)) ; then' | |
$ dorand() { randomly print Hi ; fi ; } | |
$ type dorand | |
dorand is a function | |
dorand () | |
{ | |
if ((RANDOM%2)); then | |
print Hi; | |
fi | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/path/to/your/bash | |
dox=( [1]='a partridge in a pair tree' | |
'2 turtle doves, and' | |
'3 french hens' | |
'4 calling birds' | |
$'5 gold rings\n ...' | |
'6 geese a-laying' | |
'7 swans a-swimming' | |
'8 maids a-milking' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
die() { echo "$*" >&2 ; exit 1 ; } | |
declare -a R=( normal right inverted left ) # rotation descriptions | |
declare -A S | |
declare -A DX | |
declare -a EX |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Update /etc/resolv.conf but keep it unwritable, even by root-owned processes. | |
# Useful to stop WiFi and/or DHCP from messing with it, and quite essential when | |
# there are multiple managers for different interface types. | |
# | |
# Because symlinks don't work, instead we bind-mount an appropriate file onto | |
# /etc/resolv.conf, chosen from those in ~/.resolvconf.d/. | |
# | |
# Since BIND is running locally, almost all the time that will work, so it's the |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use 5.008; | |
use strict; | |
use warnings; | |
use Getopt::Long qw(:config bundling); | |
use POSIX qw( floor ); | |
use utf8; |
OlderNewer