mirror of
https://github.com/morten-olsen/nixos-config.git
synced 2026-02-08 00:36:27 +01:00
27 lines
488 B
Bash
27 lines
488 B
Bash
function _bw_replace_env() {
|
|
env | while IFS= read -r line; do
|
|
value=${line#*=}
|
|
name=${line%%=*}
|
|
if [[ $value = bw://* ]]; then;
|
|
item=${value:5}
|
|
secret=`bw get password $item`
|
|
export $name="$secret"
|
|
fi
|
|
done
|
|
}
|
|
|
|
function clam-open() {
|
|
command=$1
|
|
if [[ -z "$BW_SESSION" ]]; then;
|
|
export BW_SESSION=`bw unlock --raw`
|
|
fi
|
|
_bw_replace_env
|
|
if [[ ! -z "$command" ]]; then;
|
|
eval $command
|
|
fi
|
|
}
|
|
|
|
function clam-close() {
|
|
unset BW_SESSION
|
|
}
|