Alfred
Strip title and subtext from input. Put inside JSON utility. Useful to get clean prompts in Alfred (i.e. it's used in web-searches workflow)
1
{
2
"alfredworkflow": {
3
"arg": "{query}",
4
"config": {
5
"title": "",
6
"runningsubtext": "",
7
"subtext": ""
8
},
9
"variables": {}
10
}
11
}
Copied!
Export workflow to a location with version number in clipboard.
1
readonly workflow_dir="{query}"
2
โ€‹
3
if [[ ! "${workflow_dir}" == *'Alfred.alfredpreferences/workflows/user.workflow.'* ]]
4
then
5
echo "You need to be inside the workflowโ€™s directory in Alfredโ€™s preferences directory." >&2
6
exit 1
7
fi
8
โ€‹
9
readonly workflow_name="$(/usr/libexec/PlistBuddy -c 'print name' "${workflow_dir}/info.plist")"
10
readonly workflow_version="$(/usr/libexec/PlistBuddy -c 'print version' "${workflow_dir}/info.plist")"
11
readonly workflow_file="${HOME}/Desktop/${workflow_name}-${workflow_version}.alfredworkflow"
12
โ€‹
13
find "${workflow_dir}" -iname '.DS_Store' -delete
14
โ€‹
15
if /usr/libexec/PlistBuddy -c 'Print variablesdontexport' "${workflow_dir}/info.plist" &> /dev/null
16
then
17
readonly workflow_dir_to_package="$(mktemp -d)"
18
cp -R "${workflow_dir}/"* "${workflow_dir_to_package}"
19
readonly tmp_info_plist="${workflow_dir_to_package}/info.plist"
20
/usr/libexec/PlistBuddy -c 'print variablesdontexport' "${tmp_info_plist}" | grep ' ' | sed -E 's/ {4}//' | xargs -I {} /usr/libexec/PlistBuddy -c "set variables:'{}' ''" "${tmp_info_plist}"
21
else
22
readonly workflow_dir_to_package="${workflow_dir}"
23
fi
24
โ€‹
25
if ditto -ck "${workflow_dir_to_package}" "${workflow_file}"
26
then
27
echo "Created ${workflow_file}"
28
exit 0
29
else
30
echo "There was and error creating ${workflow_file}"
31
exit 1
32
fi
Copied!
Last modified 1yr ago
Copy link