forked from withfig/autocomplete
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dotslash.ts
66 lines (56 loc) · 1.91 KB
/
dotslash.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
const completionSpec: Fig.Spec = {
name: "dotslash",
args: {
// This was previously just "filepaths", however, we added folders so
// users of ohmyzsh could cd into a folder by typing the folder name without `cd`
template: ["filepaths", "folders"],
},
};
// const dotslashGenerator: Fig.Generator = {
// script: function (context) {
// let path = context[context.length - 1];
// if (path.includes("/")) {
// const components = path.split("/");
// components.pop();
// path = components.join("/");
// } else {
// path = ".";
// }
// // escape spaces in path
// path = path.split(" ").join("\\");
// // output full filepath for each item in `path` folder
// return `ls -1AF ${path} | xargs -I '{}' echo $PWD/{} `;
// },
// postProcess: function (files) {
// return files.split("\n").map((path) => {
// const components = path.split("/");
// let filename = components[components.length - 1];
// const isExecutable = path.endsWith("*");
// const isFolder = path.endsWith("/");
// if (isFolder) {
// filename = components[components.length - 2] + "/";
// }
// // Removes character at the end of the filepath
// if (["@", "*", "%", "|"].includes(path.slice(-1))) {
// filename = filename.slice(0, -1);
// }
// return {
// name: filename,
// icon: "fig:https://" + path,
// description: isFolder ? "folder" : "file",
// priority: isExecutable && 80,
// };
// });
// },
// trigger: "/",
// getQueryTerm: "/",
// };
// export const completionSpec: Fig.Spec = {
// name: "dotslash",
// args: {
// // This was previously just "filepaths", however, we added folders so
// // users of ohmyzsh could cd into a folder by typing the folder name without `cd`
// generators: [dotslashGenerator],
// },
// };
export default completionSpec;