-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
pass.sh
executable file
·47 lines (42 loc) · 1.76 KB
/
pass.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
# <xbar.title>Password Store</xbar.title>
# <xbar.version>v1.0.1</xbar.version>
# <xbar.author>ri7nz</xbar.author>
# <xbar.author.github>ri7nz</xbar.author.github>
# <xbar.desc>password store with xbar</xbar.desc>
# <xbar.image>https://github.com/ri7nz/x-pass-plugin/blob/master/xbar.image.png?raw=true</xbar.image>
# <xbar.dependencies>pass,gpg,pinentry-mac</xbar.dependencies>
# <xbar.abouturl>https://github.com/ri7nz/x-pass-plugin</xbar.abouturl>
# maybe you need change the path of pass or cut bin
# use where if you didn't know where pass or cut path
export PATH="/opt/homebrew/bin:/usr/local/bin:/usr/bin:$PATH"
echo "Pass"
# first check dependencies is exist
# when exist print all password-store filename without extension
# when user click some from list set variable param1
# when param1 have a value run command pass -c (copy to clipboard)
# done
if (command -v cut && command -v pass)&>/dev/null;then
# get user input (when user click some in list)
[[ $1 ]] && pass -c "$1"
echo "---"
# location of password-store file
cd ~/.password-store || cd ~/.local/share/password-store || exit 0
while IFS= read -r -d '' singelfile
do
singelfile="${singelfile%.*}"
echo "$(basename "$singelfile") | bash='$0' param1='${singelfile}' terminal=false"
done < <(find "." -maxdepth 1 -type f -name '*.gpg' -print0)
while IFS= read -r -d '' dirname
do
dirname=${dirname:2}
echo "${dirname}"
while IFS= read -r -d '' filename
do
filename="${filename%.*}"
echo "-- $(basename "$filename") | bash='$0' param1='${filename}' terminal=false"
done < <(find "$dirname" -type f -name '*.gpg' -print0)
done < <(find ./* -maxdepth 1 -type d -print0)
else
echo "pass or cut insn't installed, please install"
fi