From 8cbae36433b9079adfd6ff5d4cf833a0306f0349 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Wed, 12 Jun 2024 14:26:32 -0500 Subject: [PATCH] Silence and document function --- home/xonsh_footer.xsh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/home/xonsh_footer.xsh b/home/xonsh_footer.xsh index 1b6c8a2..019831e 100644 --- a/home/xonsh_footer.xsh +++ b/home/xonsh_footer.xsh @@ -1,13 +1,16 @@ # vim: set ft=python : def bw_unlock(): + """Unlocks the BitWarden CLI and adds the resulting session code to the + current environment variables. Also returns the code for them.""" if "BW_SESSION" in ${...}: return $BW_SESSION - result = !(bw unlock) - while not result: - result = !(bw unlock) - l = [k for k in result.lines if 'BW_SESSION="' in k][0] - left, right = l.split("=") + result = $(bw unlock) + while "BW_SESSION" not in result: + result = $(bw unlock) + lines = result.split("\n") + l = [k for k in lines if 'BW_SESSION="' in k][0] + left, right = l.split("=", 1) token = right[1:-1] $BW_SESSION = token return token