Last active
March 29, 2018 02:39
-
-
Save oliverralbertini/7870093b87c16e6d00c340121812001e to your computer and use it in GitHub Desktop.
Get time in seconds until end of day to use as LPASS_AGENT_TIMEOUT
This file contains 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
# .bashrc or .bash_profile | |
lpass () | |
{ | |
! [[ $1 == login ]] && { | |
command lpass "$@"; | |
return | |
}; | |
local pau_time current_time LPASS_AGENT_TIMEOUT; | |
if [[ $(uname) == [Ll]inux ]]; then | |
pau_time="$(date --date='6:00 pm today' +%s)"; | |
else | |
pau_time="$(date -j -f "%a %b %d %H:%M:%S %Z %Y" \ | |
"$(date "+%a %b %d 18:00:00 %Z %Y")" "+%s")"; | |
fi; | |
current_time="$(date "+%s")"; | |
LPASS_AGENT_TIMEOUT=$(( pau_time - current_time )); | |
(( LPASS_AGENT_TIMEOUT < 0 )) && LPASS_AGENT_TIMEOUT=3600; | |
export LPASS_AGENT_TIMEOUT | |
echo "Using LPASS_AGENT_TIMEOUT = ${LPASS_AGENT_TIMEOUT} seconds."; | |
command lpass "$@" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment