Skip to content

Instantly share code, notes, and snippets.

View webb's full-sized avatar

Webb Roberts webb

View GitHub Profile
@webb
webb / simple-cli-parser.bash
Created October 2, 2020 15:18
A simple CLI parser in Bash
#!/usr/bin/env bash
print_help () { echo "Option -f \${file}: Set file"; exit 0; }
fail () { echo "Error: $*" >&2; exit 1; }
unset file
OPTIND=1
while getopts :f:h-: option
do case $option in
h ) print_help;;
@webb
webb / restow
Created January 11, 2017 14:17
Script for stowing all the packages in the ~/stow dir
#!/usr/bin/env bash
set -o nounset -o errexit
#HELP:COMMAND_NAME: put packages in their place
#HELP:Options:
command="$0"
#HELP: --help | -h: print this help
@webb
webb / Copy Mail message URI to clipboard.scpt
Created December 22, 2015 13:54
Copy Mac Mail.app message URI to clipboard
# Save as "Copy Mail message URI to clipboard.scpt" in ~/Library/Scripts/Applications/Mail
tell application "Mail"
set theSelectedMessages to selection
set the selected_message to item 1 ¬
of the theSelectedMessages
set message_id to the message id of the selected_message
end tell
set the clipboard to "message://%3c" & message_id & "%3e"
@webb
webb / csv-to-xml.awk
Last active August 29, 2015 14:22
GNU Awk (gawk) script to convert an Excel-generated CSV file to a simple XML format
BEGIN {
printf "<?xml version=\"1.0\" encoding=\"US-ASCII\" standalone=\"yes\"?>\n"
printf "<file xmlns=\"http://example.org/csv-to-xml\">\n"
FPAT = "[^,]*|(\"([^\"]|(\"\"))*\")"
RS = "\n"
}
{
printf "<row>\n"
for (i = 1; i <= NF; i++) {