Last active
February 10, 2024 08:22
-
-
Save scottrbaxter/99ec088568f45e1e206bca02b85a2753 to your computer and use it in GitHub Desktop.
Revisions
-
scottrbaxter revised this gist
May 18, 2018 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -28,6 +28,7 @@ main(){ signout ) op signout unset OP_EXPIRATION OP_SESSION_"$OP_CLOUD_ACCOUNT" reset_timeout ;; update ) op update;; -
scottrbaxter revised this gist
May 18, 2018 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -26,7 +26,9 @@ main(){ signin ) op signin;; signout ) op signout unset OP_EXPIRATION OP_SESSION_"$OP_CLOUD_ACCOUNT" ;; update ) op update;; * ) # active session required for everything else -
scottrbaxter revised this gist
May 18, 2018 . 1 changed file with 40 additions and 14 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,34 +1,60 @@ #!/usr/bin/env bash # starts (or restarts) a 1password cli session, sets 30 minute countdown variable # use: OP_CLOUD_ACCOUNT="[your-account-name]" source /path/to/op_session.sh command # e.g.: OP_CLOUD_ACCOUNT="familyname" source ~/op_session.sh get account check_session(){ # attempt sign in if session is not active if ! op get account &> /dev/null; then signin check_session fi } main(){ # directly pass inactive session args case "$*" in "" ) op;; --help ) op --help;; --version ) op --version;; signin ) op signin;; signout ) op signout;; update ) op update;; * ) # active session required for everything else check_session eval "op $*" reset_timeout ;; esac } reset_timeout(){ # reset 30 min countdown OS_TYPE=$(uname -s) if [ "$OS_TYPE" = Darwin ]; then # MacOS OP_EXPIRATION_TIME=$(date -v +30M -u +%s) elif [ "$OS_TYPE" = Linux ]; then OP_EXPIRATION_TIME=$(date -d '+30 min' -u +%s) fi export OP_EXPIRATION="$OP_EXPIRATION_TIME" } signin(){ token=$(op signin "$OP_CLOUD_ACCOUNT" | \ grep 'export' | \ awk -F\" '{print $2}' ) export OP_SESSION_"$OP_CLOUD_ACCOUNT"="$token" } main "$*" -
scottrbaxter revised this gist
May 17, 2018 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ #!/usr/bin/env bash # starts (or restarts) a 1password cli session and sets 30 minute countdown variable # use: OP_CLOUD_ACCOUNT="[your-account-name]" source /path/to/op_session.sh set -e @@ -16,6 +16,7 @@ main(){ } set_timeout(){ OS_TYPE=$(uname -s) if [ "$OS_TYPE" = Darwin ]; then # MacOS OP_EXPIRATION_TIME=$(date -v +30M -u +%s) elif [ "$OS_TYPE" = Linux ]; then -
scottrbaxter created this gist
May 17, 2018 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ #!/usr/bin/env bash # starts (or restarts) a 1password cli session and sets 30 minute countdown variable # use: source ~/scripts/op_session.sh set -e main(){ # check if session is active if op get account &> /dev/null; then set_timeout else signin fi # reset 30 min countdown export OP_EXPIRATION="$OP_EXPIRATION_TIME" } set_timeout(){ if [ "$OS_TYPE" = Darwin ]; then # MacOS OP_EXPIRATION_TIME=$(date -v +30M -u +%s) elif [ "$OS_TYPE" = Linux ]; then OP_EXPIRATION_TIME=$(date -d '+30 min' -u +%s) fi } signin(){ token=$(op signin "$OP_CLOUD_ACCOUNT" | grep 'export' | awk -F\" '{print $2}') export OP_SESSION_"$OP_CLOUD_ACCOUNT"="$token" set_timeout } main