Skip to content

Instantly share code, notes, and snippets.

@amsnickw
amsnickw / gencert.sh
Last active April 20, 2016 18:12
Generate self-signed SSL cert for local development (OS X) and add it as trusted in System keychain
#!/bin/bash
#
# Generate a self-signed SSL cert for local development and (optionally)
# add it as trusted in the system keychain to prevent browser warnings.
# Files are generated in the current directory; copy them as needed
# to your /etc/apache2/...
# Tested on OS X El Capitan.
#
# Sample Usage:
# ./gencert.sh -n example.localhost [-y] # -y to bypass all prompts
@amsnickw
amsnickw / crontab_wrapper
Created August 19, 2016 08:29
Safer use of crontab. Add this function to the user's ~/.profile or ~/.bashrc
crontab() {
crontab_usage() {
echo 'Usage:' >&2
echo ' $ crontab -[elr]' >&2
echo ' $ crontab ~/crons # to update your crons' >&2
}
if [ $# -eq 1 ]; then
if [ "$*" = '-' ]; then # worse than crontab -e
crontab_usage
@amsnickw
amsnickw / simple_ksh_git_prompt.sh
Last active March 15, 2023 02:41
Lightweight git prompt for ksh93 (real, AT&T version of the Korn shell).
# Simple, lightweight git prompt for ksh93: if inside a git repo, adds the
# branch name to PS1, using a different color for master, develop* and other.
# Put this snippet at the bottom of your ~/.kshrc
__get_current_git_branch_name() {
__determine_branch_color() {
case "${1:-}" in
master) branch_color=196 ;; # red
develop*) branch_color=226 ;; # yellow
*) branch_color=39 # blue
esac