I am currently using a shell script to calculate the remaining time of my vaulted session. It would be nice if there was a command that could read the known ENV var and report back the amount of time left.
say
vaulted time-remaining then I can use that value in my various prompts.
function _vaulted_status() {
if [ -z ${VAULTED_ENV+x} ]; then
echo ""
else
current_time=$(date +"%s")
expire_time=$(date -j -f "%C%y-%m-%dT%H:%M:%SZ" "${VAULTED_ENV_EXPIRATION}" +"%s")
secs=$(echo "$expire_time - $current_time" | bc)
if (( secs > 0 )); then
remaining="($(printf '%dh:%dm:%ds\n' $(($secs/3600)) $(($secs%3600/60)) $(($secs%60))))"
else
remaining="expired"
fi
echo -n "[$VAULTED_ENV $remaining] "
fi
}
I am currently using a shell script to calculate the remaining time of my vaulted session. It would be nice if there was a command that could read the known ENV var and report back the amount of time left.
say
vaulted time-remaining
then I can use that value in my various prompts.