hitzhangjie Posted November 6, 2021 Share Posted November 6, 2021 (edited) Hi, guys, I am a newbie to Alfred. I want to use Alfred Snippets to do some text expanding task. Like writing the markdown liquid headers in my blogs: --- layout:post title: 2-debugger_demo.md date: 2021-11-06 15:34:07 +08:00 tags: [] toc: true --- I use Typinator before, I can customize my snippet as following: --- layout:post title: {Scripts/FrontWindowTitle.applescript} date: {YYYY}-{MM}-{DD} {h024}:{m}:{s} {zn} tags: [] toc: true --- In above snippet, {YYYY}-{MM}-{DD} {h024}:{m}:{s} {zn} works like {date:yyyy-MM-dd HH:mm:ss Z} in Alfred snippet. What I cares is the property `title: {Scripts/FrontWindowTitle.applescript}`. Here this applescript just returns the frontmost window's title. At most occassions, this title is the document's name. That's what I want. The script file is as following, which is very easy: tell application "System Events" set frontApp to name of first application process whose frontmost is true end tell tell application frontApp set windowTitle to the name of the front window end tell return windowTitle Now I want to use Alfred Snippet & Snippet Trigger to replace Typinator, so I: - add a snippet in Alfred : --- layout:post title: {cursor} date: {date:yyyy-MM-dd HH:mm:ss Z} tags: [] toc: true --- - and I add a workflow including a Snippet Trigger: Here, step 2 applescript update {query} to the window title, and copy to clipboard. I can type `\\title` to get the title of window correctly. But when I type `!post` which triggers the snippet, it generate: --- layout:post title: {snippet:\\title} date: 2021-11-06 15:48:08 +0800 tags: [] toc: true --- Apparently, it didn't call the Snippet Trigger. I don't know how to solve this problem, Please help me. Thanks! Edited November 6, 2021 by hitzhangjie format Link to comment
deanishe Posted November 6, 2021 Share Posted November 6, 2021 Hi @hitzhangjie, welcome to the forum. Snippet Triggers don't work with {snippet:...}, only regular snippets. In the future, could you upload your workflow and post a link to it, not screenshots and code snippets? Link to comment
hitzhangjie Posted November 7, 2021 Author Share Posted November 7, 2021 @deanishe Thank you. Oh, {snippet:name}, this form only works for snippet not workflow. Hope in the future, Alfred supports workflow or scripts like Typinator. devalias 1 Link to comment
deanishe Posted November 7, 2021 Share Posted November 7, 2021 2 hours ago, hitzhangjie said: Hope in the future, Alfred supports workflow or scripts like Typinator. Yeah, would be a powerful feature. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now