-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
Copy pathpass.ts
281 lines (279 loc) · 7.37 KB
/
pass.ts
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
const listPasswords: Fig.Generator = {
custom: async (_tokens, executeCommand, context) => {
const { stdout } = await executeCommand({
command: "grep",
args: [
"-r",
"-l",
"",
`${context.environmentVariables["HOME"]}/.password-store`,
"--exclude-dir=.git",
],
});
return stdout.split("\n").map((password) => ({
name: password.split(".password-store/").pop().replace(".gpg", ""),
icon: "🔐",
}));
},
};
const listDirectories: Fig.Generator = {
custom: async (_tokens, executeCommand, context) => {
const { stdout } = await executeCommand({
command: "ls",
args: [
"-dR1a",
`${context.environmentVariables["HOME"]}/.password-store`,
],
});
return stdout.split("\n").map((dir) => ({
name: dir.split(".password-store/").pop(),
icon: "📁",
}));
},
};
const completionSpec: Fig.Spec = {
name: "pass",
description:
"Pass - stores, retrieves, generates, and synchronizes passwords securely",
args: {
name: "pass-name",
description: "The password you want to show",
generators: listPasswords,
},
options: [
{
name: ["--clip", "-c"],
description: "Copy the password to the clipboard",
},
{
name: ["--qrcode", "-q"],
description: "Display a QRcode of the password",
},
{
name: "--help",
description: "Show help for pass",
},
],
subcommands: [
{
name: "init",
description:
"Initialize new password storage and use gpg-id for encryption",
args: {
name: "gpg-id",
description:
"The gpg-id you want to use to encrypt your password store",
},
options: [
{
name: ["--path", "-p"],
description:
"A specific gpg-id or set of gpg-ids is assigned for that specific sub folder of the password store",
args: {
name: "sub-folder",
template: "folders",
},
},
],
},
{
name: "insert",
description:
"Insert a new password into the password store called pass-name",
args: {
name: "pass-name",
description: "The password name",
},
options: [
{
name: ["--echo", "-e"],
description:
"Disable keyboard echo when the password is entered and confirm the password by asking for it twice",
},
{
name: ["--multi-line", "-m"],
description:
"Lines will be read until EOF or Ctrl+D is reached. Otherwise, only a single line from standard in is read",
},
{
name: ["--force", "-f"],
description: "Don't prompt before overwriting an existing password",
},
],
},
{
name: "git",
description: "Password store git functions",
loadSpec: "git",
},
{
name: "version",
description: "Show version information",
},
{
name: "help",
description: "Show usage message",
},
{
name: "cp",
description:
"Copies the password or directory named old-path to new-path",
args: [
{
name: "old-path",
description: "The old password name or directory",
generators: listPasswords,
},
{
name: "new-path",
description: "The new password name or directory",
},
],
options: [
{
name: ["--force", "-f"],
description: "Do not interactively prompt before moving",
},
],
},
{
name: "mv",
description:
"Renames the password or directory named old-path to new-path",
args: [
{
name: "old-path",
description: "The old password name or directory",
generators: listPasswords,
},
{
name: "new-path",
description: "The new password name or directory",
},
],
options: [
{
name: ["--force", "-f"],
description: "Do not interactively prompt before moving",
},
],
},
{
name: "rm",
description:
"Remove the password named pass-name from the password store",
args: {
name: "pass-name",
description: "The password name",
generators: listPasswords,
},
options: [
{
name: ["--recursive", "-r"],
description: "Delete pass-name recursively if it is a directory",
},
{
name: ["--force", "-f"],
description: "Do not interactively prompt before removal",
},
],
},
{
name: "generate",
description:
"Generate a new password of length pass-length and insert into pass-name",
args: [
{
name: "pass-name",
description: "The password name",
},
{
name: "pass-length",
description: "The length of the password",
isOptional: true,
},
],
options: [
{
name: ["--no-symbols", "-n"],
description:
"Do not use any non-alphanumeric characters in the generated password",
},
{
name: ["--clip", "-c"],
description:
"Do not print the password but instead copy it to the clipboard",
},
{
name: ["--in-place", "-i"],
description:
"Do not interactively prompt, and only replace the first line of the password file with the new generated password, keeping the remainder of the file intact",
},
{
name: ["--force", "-f"],
description: "Overwrite the existing password",
},
],
},
{
name: ["ls", "list"],
description:
"List names of passwords inside the tree at subfolder by using the tree",
args: {
name: "password sub-directory",
description: "The password sub directory you want to list",
isOptional: true,
generators: listDirectories,
},
},
{
name: "find",
description:
"List names of passwords inside the tree that match pass-names",
args: {
name: "pass-name",
description: "The password name you want to search for",
},
},
{
name: "show",
description: "Decrypt and print a password",
args: {
name: "pass-name",
description: "The password you want to show",
generators: listPasswords,
},
options: [
{
name: ["--clip", "-c"],
description: "Copy the password to the clipboard",
},
{
name: ["--qrcode", "-q"],
description: "Display a QRcode of the password",
},
],
},
{
name: "edit",
description:
"Insert a new password or edit an existing password using the default text editor specified by the environment",
args: {
name: "pass-name",
description: "The password you want to edit",
generators: listPasswords,
},
},
{
name: "grep",
description:
"Searches inside each decrypted password file for search-string. Grep options can be used",
loadSpec: "grep",
args: {
name: "pass-name",
description: "The password name you want to grep for",
},
},
],
};
export default completionSpec;