Skip to content

Instantly share code, notes, and snippets.

@michaelabon
Last active August 29, 2015 14:08
Show Gist options
  • Save michaelabon/f2835df5e09e06ac0b15 to your computer and use it in GitHub Desktop.
Save michaelabon/f2835df5e09e06ac0b15 to your computer and use it in GitHub Desktop.
Keep your keys on an encrypted drive
#!/usr/bin/env bash
HOURS=$1
if [ -z $HOURS ]; then
CURRENT_HOUR=$(date +"%H")
QUITTING_HOUR=18
MARGIN_OF_ERROR=1
HOURS=$(expr $QUITTING_HOUR - $CURRENT_HOUR + $MARGIN_OF_ERROR)
fi
RED="\033[31m"
CLEAR="\033[0m"
MESSAGE="Don't forget your house keys."
trap 'echo -e "$RED$MESSAGE$CLEAR"' EXIT
ssh-add -D
ssh-add -t ${HOURS}H $(dirname $0)/id_rsa
typeahead() {
TYPING=0.02
GOAL_PRINT=$1
BASE_PRINT=$2
if [ -z $BASE_PRINT ]; then
BASE_PRINT=1
fi
for i in $(seq $BASE_PRINT ${#GOAL_PRINT});
do
echo -en "\r$RED${GOAL_PRINT:0:$i}$CLEAR"
sleep $TYPING
done
}
typeahead "Working......"
sleep 0.2
typeahead "Working...... please wait." 14
echo
diskutil umount force $(dirname $0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment