mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-05-22 04:51:12 +02:00
Teach the agnoster vaulted timeout about Linux
The first patch only worked for macOS. This patch adds Linux support.
This commit is contained in:
parent
d5f713e950
commit
b46093c2c2
1 changed files with 12 additions and 1 deletions
|
|
@ -198,13 +198,24 @@ prompt_virtualenv() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
epoch_date() {
|
||||||
|
unamestr=`uname`
|
||||||
|
if [[ "$unamestr" == 'Linux' ]]; then
|
||||||
|
echo $(date -d $1 +%s)
|
||||||
|
elif [[ "$unamestr" == 'Darwin' ]]; then
|
||||||
|
echo $(date -j -f %Y-%m-%dT%H:%M:%S%z $1 +%s)
|
||||||
|
else # TODO - other platforms?
|
||||||
|
echo $(date -j -f %Y-%m-%dT%H:%M:%S%z $1 +%s)
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# vaulted: current vaulted shell
|
# vaulted: current vaulted shell
|
||||||
prompt_vaulted() {
|
prompt_vaulted() {
|
||||||
if [[ -z $VAULTED_ENV ]]; then
|
if [[ -z $VAULTED_ENV ]]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
local exp=$(echo $VAULTED_ENV_EXPIRATION | sed 's/Z/+0000/')
|
local exp=$(echo $VAULTED_ENV_EXPIRATION | sed 's/Z/+0000/')
|
||||||
local valid_until=$(date -j -f %Y-%m-%dT%H:%M:%S%z $exp +%s)
|
local valid_until=$(epoch_date $exp)
|
||||||
local bg=009 #orange
|
local bg=009 #orange
|
||||||
local fg=black
|
local fg=black
|
||||||
if [[ $valid_until -lt $(date +%s) ]]; then
|
if [[ $valid_until -lt $(date +%s) ]]; then
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue