123456789101112131415161718192021222324252627282930 |
- #!/usr/bin/env nix-shell
- #!nix-shell -p expect -i "expect -f"
- log_user 0
- set db_path "$::env(KEEPASS_FILE)"
- set db_entry "$::env(KEEPASS_OP_ENTRY)"
- stty -echo
- puts -nonewline stderr "Enter Password: "
- expect_user -re "(.*)\n"
- puts stderr ""
- stty echo
- set PASS $expect_out(1,string)
- set op_url [exec keepassxc-cli show -q $db_path "$db_entry" -a URL << $PASS]
- set op_username [exec keepassxc-cli show -q $db_path "$db_entry" -a UserName << $PASS]
- set op_password [exec keepassxc-cli show -q $db_path "$db_entry" -a Password << $PASS]
- set op_secretkey [exec keepassxc-cli show -q $db_path "$db_entry" -a "Secret Key" << $PASS]
- spawn op signin $op_url $op_username $op_secretkey
- expect "Enter the password for $op_username at $op_url:"
- expect -re $
- send "$op_password\r"
- expect eof
- set session $expect_out(buffer)
- log_user 1
- regsub -all {\r} $session {} stripped_session
- puts $stripped_session
|