Skip to content

Instantly share code, notes, and snippets.

@oliverralbertini
Last active March 29, 2018 02:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oliverralbertini/7870093b87c16e6d00c340121812001e to your computer and use it in GitHub Desktop.
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
# .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