diff --git a/dot_config/fish/private_functions/bwunlock.fish b/dot_config/fish/private_functions/bwunlock.fish index 6c67472..dc1ef26 100644 --- a/dot_config/fish/private_functions/bwunlock.fish +++ b/dot_config/fish/private_functions/bwunlock.fish @@ -1,3 +1,10 @@ function bwunlock -set -g BW_SESSION (bw unlock --raw) + set -x NODE_OPTIONS "--no-deprecation" + + if not bw login --check + set -gx BW_SESSION (bw login --raw) + end + if not bw unlock --check + set -gx BW_SESSION (bw unlock --raw) + end end diff --git a/dot_config/fish/private_functions/chezmoiapply.fish b/dot_config/fish/private_functions/chezmoiapply.fish index 55d5031..0540509 100644 --- a/dot_config/fish/private_functions/chezmoiapply.fish +++ b/dot_config/fish/private_functions/chezmoiapply.fish @@ -1,11 +1,4 @@ function chezmoiapply - set -x NODE_OPTIONS "--no-deprecation" - - if not bw login --check - set -x BW_SESSION (bw login --raw) - end - if not bw unlock --check - set -x BW_SESSION (bw unlock --raw) - end - chezmoi apply + bwunlock + chezmoi apply end diff --git a/dot_config/fish/private_functions/chezmoiupdate.fish b/dot_config/fish/private_functions/chezmoiupdate.fish index 898e250..d53d1ff 100644 --- a/dot_config/fish/private_functions/chezmoiupdate.fish +++ b/dot_config/fish/private_functions/chezmoiupdate.fish @@ -1,10 +1,4 @@ function chezmoiupdate - set -x NODE_OPTIONS "--no-deprecation" - if not bw login --check - set -x BW_SESSION (bw login --raw) - end - if not bw unlock --check - set -x BW_SESSION (bw unlock --raw) - end - chezmoi update + bwunlock + chezmoi update end diff --git a/dot_config/fish/private_functions/private_fetchkeys.fish b/dot_config/fish/private_functions/private_fetchkeys.fish index 497b901..2709744 100644 --- a/dot_config/fish/private_functions/private_fetchkeys.fish +++ b/dot_config/fish/private_functions/private_fetchkeys.fish @@ -1,23 +1,18 @@ function fetchkeys -if not bw login --check -set -x BW_SESSION (bw login --raw) -end -if not bw unlock --check -set -x BW_SESSION (bw unlock --raw) -end -set key_item (bw list items --search "SSH Main" | jq ".[0]" --raw-output) -set key_item_id (echo $key_item | jq ".id" --raw-output) -set key1 (echo $key_item | jq ".attachments[0]" --raw-output) -set key1_name (echo $key1 | jq ".fileName" --raw-output) -set key1_id (echo $key1 | jq ".id" --raw-output) -set key2 (echo $key_item | jq ".attachments[1]" --raw-output) -set key2_name (echo $key2 | jq ".fileName" --raw-output) -set key2_id (echo $key2 | jq ".id" --raw-output) -bw get attachment $key1_id --output "./$key1_name" --itemid $key_item_id -bw get attachment $key2_id --output "./$key2_name" --itemid $key_item_id -if string match -q -- '*.pub' $key1_name -chmod 600 $key2_name -else -chmod 600 $key1_name -end + bwunlock + set key_item (bw list items --search "SSH Main" | jq ".[0]" --raw-output) + set key_item_id (echo $key_item | jq ".id" --raw-output) + set key1 (echo $key_item | jq ".attachments[0]" --raw-output) + set key1_name (echo $key1 | jq ".fileName" --raw-output) + set key1_id (echo $key1 | jq ".id" --raw-output) + set key2 (echo $key_item | jq ".attachments[1]" --raw-output) + set key2_name (echo $key2 | jq ".fileName" --raw-output) + set key2_id (echo $key2 | jq ".id" --raw-output) + bw get attachment $key1_id --output "./$key1_name" --itemid $key_item_id + bw get attachment $key2_id --output "./$key2_name" --itemid $key_item_id + if string match -q -- '*.pub' $key1_name + chmod 600 $key2_name + else + chmod 600 $key1_name + end end diff --git a/dot_config/fish/private_functions/upgrade.fish.tmpl b/dot_config/fish/private_functions/upgrade.fish.tmpl index aba8a7a..af92f71 100644 --- a/dot_config/fish/private_functions/upgrade.fish.tmpl +++ b/dot_config/fish/private_functions/upgrade.fish.tmpl @@ -1,13 +1,7 @@ function upgrade --wraps=topgrade - set -x NODE_OPTIONS "--no-deprecation" - if not bw login --check - set -x BW_SESSION (bw login --raw) - end - if not bw unlock --check - set -x BW_SESSION (bw unlock --raw) - end - {{- if get . "sudo" }} - sudo ls >/dev/null - {{- end }} - topgrade $argv + bwunlock + {{- if get . "sudo" }} + sudo ls >/dev/null + {{- end }} + topgrade $argv end