Skip to content

Commit

Permalink
Updates to 1password (#29)
Browse files Browse the repository at this point in the history
This fixes an instance of dirname - also adds a test + updates README.

Signed-off-by: Ross Turk <[email protected]>
Co-authored-by: Ross Turk <[email protected]>
  • Loading branch information
rossturk and Ross Turk authored Oct 21, 2024
1 parent f0df433 commit a5b2e79
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 84 deletions.
3 changes: 1 addition & 2 deletions 1password/.flox/env/manifest.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
"pkg-path": "_1password"
}
},
"vars": {},
"hook": {
"on-activate": "\n # Start OP injection code\n if ! op vault list >/dev/null 2>&1; then\n CACHE=\"$HOME/.cache/op-session\"\n OP_TOKEN=$( [[ -f \"$CACHE\" ]] && cat \"$CACHE\" || op signin --raw 2>&1 )\n if op whoami --session \"${OP_TOKEN}\" >/dev/null 2>&1; then\n mkdir -p dirname \"$CACHE\" 2>/dev/null && echo \"${OP_TOKEN}\" > \"$CACHE\"\n chmod 600 \"$CACHE\"\n else\n echo \"op auth failed!\" && return 1\n fi\n fi\n export op_token=$( [[ \"$OP_TOKEN\" ]] && echo \"--session $OP_TOKEN\" )\n # End OP injection code\n\n export ANTHROPIC_API_KEY=$(op $op_token item get \"Anthropic\" --field \"credential\")\n export TAILSCALE_TOKEN=$(op $op_token item get \"Tailscale\" --field \"token\")\n"
"on-activate": "\n # Start OP injection code\n if ! op vault list >/dev/null 2>&1; then\n CACHE=\"$HOME/.cache/op-session\"\n OP_TOKEN=$( [[ -f \"$CACHE\" ]] && cat \"$CACHE\" || op signin --raw 2>&1 )\n if op whoami --session \"${OP_TOKEN}\" >/dev/null 2>&1; then\n mkdir -p $(dirname \"$CACHE\") 2>/dev/null && echo \"${OP_TOKEN}\" > \"$CACHE\"\n chmod 600 \"$CACHE\"\n else\n echo \"op auth failed!\" && return 1\n fi\n fi\n export op_token=$( [[ \"$OP_TOKEN\" ]] && echo \"--session $OP_TOKEN\" )\n # End OP injection code\n\n export ANTHROPIC_API_KEY=$(op $op_token item get \"Anthropic\" --field \"credential\")\n export TAILSCALE_TOKEN=$(op $op_token item get \"Tailscale\" --field \"token\")\n"
},
"profile": {
"common": " alias op=\"op $op_token\"\n"
Expand Down
2 changes: 1 addition & 1 deletion 1password/.flox/env/manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on-activate = '''
CACHE="$HOME/.cache/op-session"
OP_TOKEN=$( [[ -f "$CACHE" ]] && cat "$CACHE" || op signin --raw 2>&1 )
if op whoami --session "${OP_TOKEN}" >/dev/null 2>&1; then
mkdir -p dirname "$CACHE" 2>/dev/null && echo "${OP_TOKEN}" > "$CACHE"
mkdir -p $(dirname "$CACHE") 2>/dev/null && echo "${OP_TOKEN}" > "$CACHE"
chmod 600 "$CACHE"
else
echo "op auth failed!" && return 1
Expand Down
80 changes: 0 additions & 80 deletions 1password/manifest-comments.toml

This file was deleted.

13 changes: 13 additions & 0 deletions 1password/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

set -eo pipefail

command_exists() {
if ! command -v $1 2>&1 >/dev/null; then
echo "Error: '$1' command could not be found."
return 1
fi
echo ">>> '$1' command exists"
}

command_exists op
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
| **Applications:** |
| `nb` |||| IPython notebook |
| `a-perfect-shell` |||| An opinionated shell environment |
| `1password` | | | | |
| `1password` ||| | 1Password + a simple shell helper |
| `anthropic` | | | | |
| `direnv` | | | | |
| `flaim` | | | | |
Expand Down

0 comments on commit a5b2e79

Please sign in to comment.