Last active
August 29, 2015 14:08
-
-
Save michaelabon/f2835df5e09e06ac0b15 to your computer and use it in GitHub Desktop.
Keep your keys on an encrypted drive
This file contains hidden or 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
#!/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