-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
Copy pathwhich.ts
38 lines (36 loc) · 937 Bytes
/
which.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
const programGenerator: Fig.Generator = {
script: [
"bash",
"-c",
`for i in $(echo $PATH | tr ":" "\n"); do find $i -maxdepth 1 -perm -111 -type f; done`,
],
postProcess: (out) =>
out
.split("\n")
.map((path) => path.split("/")[path.split("/").length - 1])
.map((pr) => ({ name: pr, description: "Executable file", type: "arg" })),
};
const completionSpec: Fig.Spec = {
name: "which",
description: "Locate a program in the user's PATH",
args: {
name: "names",
isVariadic: true,
generators: programGenerator,
filterStrategy: "fuzzy",
suggestCurrentToken: true,
},
options: [
{
name: "-s",
description:
"No output, return 0 if all the executables are found, 1 if not",
},
{
name: "-a",
description:
"List all instances of executables found, instead of just the first",
},
],
};
export default completionSpec;