-
Notifications
You must be signed in to change notification settings - Fork 2
/
filter.zsh
executable file
·44 lines (37 loc) · 1.22 KB
/
filter.zsh
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
#!/bin/zsh
export PATH=$TOOLS_PATH:$PATH
[[ -d "${alfred_workflow_data}" ]] || mkdir "${alfred_workflow_data}"
source check-jq.sh
source list_profiles.zsh
# | Sed -e 's/\\/\\\\\\/g' \
# | sed -e 's/"/\\&/g' \
# | sed -e 's/\r$//g' \
# fzf search
cat ${alfred_workflow_data}/profiles.txt \
| fzf -e +s -f "$1" \
| head -n30 \
> ${alfred_workflow_data}/matches.txt
cat ${alfred_workflow_data}/matches.txt | jq -nR '{ "items":
[ inputs
| select(length>0) as $name |
split("-") as $parts |
{
"uid": $name,
"title":$name | sub("-"; " "; "g") | sub("\\("; " "; "g") | sub("\\)"; " "; "g"),
"subtitle":$name,
"arg":$name,
"autocomplete":$name | sub("-"; " "; "g") | sub("\\("; " "; "g") | sub("\\)"; " "; "g")
}
]}'
# echo $profile | jq -nR '{ "items":
# [ inputs
# | select(length>0) as $name |
# split("-") as $parts |
# {
# "uid": $name,
# "title":$name | sub("-"; " "; "g") | sub("\\("; " "; "g") | sub("\\)"; " "; "g"),
# "subtitle":$name,
# "arg":$name,
# "autocomplete":$name | sub("-"; " "; "g") | sub("\\("; " "; "g") | sub("\\)"; " "; "g")
# }
# ]}'