original idea: https://efcl.info/2023/01/31/remove-secret-from-local/
Last active
June 28, 2024 09:20
-
-
Save ka2n/a8e50bc98561cc218d562282632cb4c3 to your computer and use it in GitHub Desktop.
opr-fish
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
if type -q op | |
function opr | |
argparse -n oprr -x 'e,g' 'e/env=' 'g/global' -- $argv | |
or return 1 | |
if not op whoami > /dev/null | |
op signin | |
op whoami | |
end | |
# if $_flag_g is set, use global env file | |
# if $_flag_e is set, use the specified env file | |
# if neither is set, use the default env file | |
# default env file is "$PWD/.env" or "$HOME/.env.1password" | |
if test -n "$_flag_g" | |
set env_file "$HOME/.env.1password" | |
else if test -n "$_flag_e" | |
set env_file "$_flag_e" | |
else | |
if test -f "$PWD/.env" | |
set env_file "$PWD/.env" | |
else | |
set env_file "$HOME/.env.1password" | |
end | |
end | |
set_color blue; echo "Using env file: $env_file"; set_color normal | |
op run --env-file="$env_file" --no-masking -- $argv | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment