Skip to content

Instantly share code, notes, and snippets.

View ethicalaakash's full-sized avatar
💻
Learning

Aakash Singhal ethicalaakash

💻
Learning
View GitHub Profile
@mrinalwadhwa
mrinalwadhwa / usage.sh
Created August 3, 2016 17:36
Extract and display block of usage info
#!/usr/bin/env bash
##
## Usage: usage [command|path]
## Assuming that a command script file starts with a block of usage info
## where each line in the block starts with two '##' characters. This script
## extracts and displays that block of usage info.
##
## Example:
## Given a file a_command with the following contents:
##
@mrinalwadhwa
mrinalwadhwa / afk-osx.sh
Created August 3, 2016 17:30
Lock Screen on MacOS
#!/usr/bin/env bash
##
## Usage: afk
## Lock Screen on MacOS
##
/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend
#!/usr/bin/env bash
# redsymbol.net/articles/unofficial-bash-strict-mode/
set -euo pipefail
IFS=$'\n\t'
# `set` is safer than relying on a hashbang like `#!/bin/bash -e`
# because that is neutralized when someone runs the script as `bash script.sh`
# Exit on error. Append `|| true` if we expect an error.
# set -o errexit