commit 286d99a02de4faf9ee58189bebbe37c34180466d
parent 33b3e6eecca0b2e2787ab1f7315fa03698dbecc3
Author: Alex Balgavy <alex@balgavy.eu>
Date: Sun, 2 May 2021 12:14:51 +0200
Move from bitwarden-cli to rbw
It's a much nicer CLI. It also simplifies a lot of things I was doing
since I don't need to track the session key, so I can get rid of some
scripts.
Diffstat:
11 files changed, 17 insertions(+), 63 deletions(-)
diff --git a/newsboat/config b/newsboat/config
@@ -1,7 +1,7 @@
urls-source "miniflux"
miniflux-url "https://miniflux.alex.balgavy.eu"
miniflux-login "admin"
-miniflux-passwordeval "bw get password miniflux.alex.balgavy.eu"
+miniflux-passwordeval "rbw get miniflux.alex.balgavy.eu"
auto-reload no
reload-threads 8
diff --git a/scripts/bwg b/scripts/bwg
@@ -1,4 +0,0 @@
-#!/bin/sh
-command -v bw 1>/dev/null 2>&1 || { printf "Bitwarden CLI not installed.\n" && exit 1; }
-[ -n "$BW_SESHFILE" ] || { printf "Set BW_SESHFILE in your env.\n" && exit 1; }
-{ [ -f "$BW_SESHFILE" ] && cat "$BW_SESHFILE"; } || printf "No active session.\n"
diff --git a/scripts/bwl b/scripts/bwl
@@ -1,5 +0,0 @@
-#!/bin/sh
-command -v bw 1>/dev/null 2>&1 || { printf "Bitwarden CLI not installed.\n" && exit 1; }
-[ -n "$BW_SESHFILE" ] || { printf "Set BW_SESHFILE in your env.\n" && exit 1; }
-[ -f "$BW_SESHFILE" ] && rm "$BW_SESHFILE"
-bw lock
diff --git a/scripts/bwu b/scripts/bwu
@@ -1,13 +0,0 @@
-#!/bin/sh
-command -v bw 1>/dev/null 2>&1 || { printf "Bitwarden CLI not installed.\n" && exit 1; }
-[ -n "$BW_SESHFILE" ] || { printf "Set BW_SESHFILE in your env.\n" && exit 1; }
-if ! [ -f "$BW_SESHFILE" ]; then
- touch "$BW_SESHFILE"
- chmod 600 "$BW_SESHFILE"
- { bw unlock --raw > "$BW_SESHFILE" \
- && printf "Vault unlocked.\n"; } \
- || rm "$BW_SESHFILE";
-else
- printf "Session already active.\n"
-fi
-
diff --git a/scripts/mailsync b/scripts/mailsync
@@ -1,13 +1,5 @@
#!/bin/sh
-if [ -z "$BW_SESSION" ]; then
- if [ -n "$BW_SESHFILE" ] && [ -f "$BW_SESHFILE" ]; then
- BW_SESSION="$(cat "$BW_SESHFILE")"
- else
- BW_SESSION="$(bw unlock --raw)"
- [ $? -eq 0 ] || { printf "Could not unlock vault.\n" && exit 1; }
- fi
- export BW_SESSION
-fi
+rbw unlock
mbsync -c /Users/alex/.config/mbsync/mbsyncrc -Va
notmuch new
notification_str=""
diff --git a/scripts/newsrefreshd b/scripts/newsrefreshd
@@ -2,16 +2,16 @@
set -e
notidie() {
- terminal-notifier -group news -sender news -title "$1" -message "$2"
+ notify "$1" "$2" news
exit 1
}
os=$(uname -s | tr '[:upper:]' '[:lower:]')
case "$os" in
darwin*)
- seshkey="$(printf "%s\n" "$(osascript -e 'tell application "System Events" to get text returned of (display dialog "Unlock your Bitwarden vault" default answer "" hidden answer true giving up after 0 with title "Newsboat Refresh")')" | bw unlock --raw 2>/dev/null)"
+ /usr/local/bin/alacritty -e /Users/alex/.local/share/cargo/bin/rbw unlock
;;
esac
-BW_SESSION="$seshkey" newsboat -x reload 2>&1 || notidie "Newsboat: error reloading" "Unable to reload"
-BW_SESSION="$seshkey" newsboat -x print-unread | xargs -I{} terminal-notifier -group news -sender news -title 'Newsboat reloaded' -message "{}"
+newsboat -x reload 2>&1 || notidie "Newsboat: error reloading" "Unable to reload"
+newsboat -x print-unread | xargs -I{} notify 'Newsboat reloaded' "{}" news
diff --git a/shell/aliases b/shell/aliases
@@ -25,7 +25,9 @@ alias mpva="mpv --no-audio-display --no-video --volume=50"
alias irrsi="irssi --home=~/.config/irssi"
alias scim="sc-im"
alias mbsync='mbsync -c $HOME/.config/mbsync/mbsyncrc'
-alias mutt='{ [ -f "$BW_SESHFILE" ] && BW_SESSION="$(cat $BW_SESHFILE)" neomutt; } || BW_SESSION="$(bw unlock --raw)" neomutt;'
+alias mutt="neomutt"
+alias bwu="rbw unlock"
+alias bwl="rbw lock"
alias yt="pipe-viewer"
alias gotop='sudo gotop -C $XDG_CONFIG_HOME/gotop/gotop.conf'
[ -n "$VIM_TERMINAL" ] && alias vim=vimsend
diff --git a/shell/env b/shell/env
@@ -12,8 +12,6 @@ export MUSIC_DIR="/Volumes/HDD/Music/Libraries/Mine"
export PAGER="less"
export LESS="-FRiX"
-[ -n "$BW_SESHFILE" ] && [ -f "$BW_SESHFILE" ] && export BW_SESSION="$(cat $BW_SESHFILE)"
-
export LANG="en_US.UTF-8"
export LC_ALL="en_US.UTF-8"
export LC_COLLATE="en_US.UTF-8"
diff --git a/shell/functions b/shell/functions
@@ -143,15 +143,3 @@ if [ -d ~/.config/fzf ]; then
fzf --preview "cat $1 | jq {q}"
}
fi
-
-# bitwarden functions
-if command -v bw 1>/dev/null 2>&1; then
- bwl() {
- command bwl
- unset BW_SESSION
- }
- bwu() {
- command bwu
- [ -f "$BW_SESHFILE" ] && export BW_SESSION="$(cat $BW_SESHFILE)"
- }
-fi
diff --git a/shell/p10k-dark.zsh b/shell/p10k-dark.zsh
@@ -49,7 +49,7 @@
# automatically hidden when the input line reaches it. Right prompt above the
# last prompt line gets hidden if it would overlap with left prompt.
typeset -g POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(
- bitwarden_session_timer # how much longer until Bitwarden locks
+ bitwarden_session_status # how much longer until Bitwarden locks
command_execution_time # duration of the last command
background_jobs # presence of background jobs
# direnv # direnv status (https://direnv.net/)
@@ -1147,11 +1147,9 @@
(( $D > 0 || $H > 0 || $M > 0 )) && printf ':'
printf '%02d' $S
}
- function prompt_bitwarden_session_timer() {
- if [ -z "$BW_SESHFILE" ] || ! [ -f "$BW_SESHFILE" ]; then
- return
- else
- p10k segment -f 2 -t "[🔓 -$(hms $(($(stat -c '%Y' $BW_SESHFILE)+(30*60)-$(date +%s))))]"
+ function prompt_bitwarden_session_status() {
+ if rbw unlocked >/dev/null 2>&1; then
+ p10k segment -f 2 -t "[🔓]"
fi
}
diff --git a/shell/p10k-light.zsh b/shell/p10k-light.zsh
@@ -48,7 +48,7 @@
# automatically hidden when the input line reaches it. Right prompt above the
# last prompt line gets hidden if it would overlap with left prompt.
typeset -g POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(
- bitwarden_session_timer # how much longer until Bitwarden locks
+ bitwarden_session_status # how much longer until Bitwarden locks
command_execution_time # duration of the last command
background_jobs # presence of background jobs
direnv # direnv status (https://direnv.net/)
@@ -1283,11 +1283,9 @@
(( $D > 0 || $H > 0 || $M > 0 )) && printf ':'
printf '%02d' $S
}
- function prompt_bitwarden_session_timer() {
- if [ -z "$BW_SESHFILE" ] || ! [ -f "$BW_SESHFILE" ]; then
- return
- else
- p10k segment -f 2 -t "[🔓 -$(hms $(($(stat -c '%Y' $BW_SESHFILE)+(30*60)-$(date +%s))))]"
+ function prompt_bitwarden_session_status() {
+ if rbw unlocked >/dev/null 2>&1; then
+ p10k segment -f 2 -t "[🔓]"
fi
}