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
rl_eval() { | |
local a="${READLINE_LINE:0:$READLINE_POINT}" | |
local b="${READLINE_LINE:$READLINE_POINT}" | |
local s; s=$(eval "$@") | |
READLINE_LINE="${a}${s}${b}" | |
((READLINE_POINT += ${#s})) | |
} | |
bind -x '"\C-xx":"rl_eval choose -t meta"' |
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
rtt() { | |
local h="$1" c="${2:-1}" r="" | |
if [ -z "$h" ]; then return 1; fi | |
r=$(ping -W1 -c "$c" "$h" | awk '/rtt/{ gsub("/", " ", $4); print $4 }') | |
if [ -z "$r" ]; then return 2; fi | |
printf "%s %s\n" "$h" "$r" | |
}; | |
sort-by-rtt() { | |
mapfile hosts |
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
rtt() { local h="$1" c="${2:-1}"; if [ -z "$h" ]; then return 1; fi; printf "%s %s\n" "$h" "$(ping -W1 -c "$c" "$h" | awk '/rtt/{ gsub("/", " ", $4); print $4 }')"; }; | |
sort-by-rtt() { mapfile hosts; while read -r h _; do rtt "$h" & done < <(printf "%s\n" "${hosts[@]}") | sort -nk2; wait; } | |
# sort-by-rtt < <( awk '{print $2}' ~/.hosts | shuf -n3) |
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
# ; -*-shell-script-*- | |
# sourced DIRECTORY [LOG] | |
# Source each file in given directory, logging to optional log file. | |
# shellcheck disable=SC1090 | |
sourced() { | |
local dir="$1" | |
if ! [ -d "$dir" ]; then return 1; fi | |
local log="${2:-/dev/stdout}" | |
local _ it | |
for it in "$dir"/*; do |
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
# ; -*-shell-script-*- | |
# filed DIR [OUTFILE] | |
# Combine each file in DIR into OUTFILE. | |
# If a file is executable its output will be used instead of its contents. | |
# The files are considered in lexographic order. | |
filed() { | |
# accept a directory and require that it exists | |
local dir="${1}" | |
if ! [ -n "$dir" ] || ! [ -d "$dir" ]; then return 1; fi | |
# optionally accept an output file that must not exist |
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
# pushf STACKFILE LINE | |
# Treat STACKFILE as a stack, pushing LINE onto the start of the file. | |
pushf() { | |
local file="$1"; shift; | |
[ -n "$file" ] || return 127 | |
declare -a stack; | |
[ -f "$file" ] && mapfile -t stack < "$file" | |
printf "%s\n" "$@" "${stack[@]}" > "$file" | |
} |
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
You are destined to become the commandant of the fighting men of the | |
department of transportation. |
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
Your object is to save the world, while still leading a pleasant life. |
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
> ansible-inventory -i inventory/others --list | |
{ | |
"_meta": { | |
"hostvars": {} | |
}, | |
"all": { | |
"children": [ | |
"mine", | |
"ungrouped" | |
] |