diff --git a/prompt b/prompt index d864d06..a49dcb9 100755 --- a/prompt +++ b/prompt @@ -135,7 +135,7 @@ notify-send -u low -t 3000 "Download complete" download_music() { youtube-dl --no-progress -f bestaudio -o \ "$HOME/downloads/music/%(track)s - %(artist)s.%(ext)s" "$(xclip -selection clipboard -o)" - if [ $? ]; then + if [ ! $? ]; then youtube-dl --no-progress -f bestaudio -o \ "$HOME/downloads/music/%(title)s - %(artist)s.%(ext)s" "$(xclip -selection clipboard -o)" fi @@ -300,6 +300,7 @@ sel_account() { dmenu -p 'account' ) if [ -z "$account" ]; then exit; fi + printf "$account" } username() { @@ -322,14 +323,22 @@ password() { } +# Giving multiple accounts for the same service the same username may cause problems. +# It assumes that the password is always the first line of the account's section, +# and the username is always the second other_password() { account=$(sel_account) name=$(pass show "$account" | sed -n -e "s/^username: //p" | - dmenu -p 'which user password') + dmenu -i -p 'which user password') if [ -z "$name" ]; then exit; fi - pass show $account | sed "/^$/,/^username: $name/ { /^$/n }" | head -n1 | tr -d '\n' | xclip -selection clipboard - + copy=$(pass show $account | grep -B 1 "^username: $name" | head -n1 | tr -d '\n') + printf "$copy" | xclip -selection clipboard notify-send -u low -t 2000 "password copied" "$account: $name" + sleep 30s + new_copy=$(xclip -o -selection clipboard) + if [ "$copy" = $newcopy ]; then + printf '' | xclip -selection clipboard + fi } show_password() {