Jump to content

Displaying a text file (or a .md file)

Recommended Posts

I'm trying to write a workflow right now that will query a lot of files, mine them for data, and display the results. But I'm running into a problem with an elegant way to display the results.


I'd like to have a window like Alfred's "Large Text" notification but one that will display something like a Markdown file (I want the formatting), and one that will stay open until closed/clicked outside of (think: lightbox image display type thingie).


Right now, the best solution that I can think of would be to create a file and display it with "Preview," but I don't want to open a program that will need to be closed manually. Does anyone have an idea of how to do what is described above?


Any help would be very much appreciated.



Link to comment

I agree that it would be great to have native Alfred support for something like this with html support (you can easily convert markdown to html in most langues). It would really be a nice way to show results that have a lot of text. It could be implemented as one large box below the query box (where the search results are), the query box could disappear and the window could be closed a small x in the top right corner. Simple and clean design...


As long as that does not exists  You could use qlmanage, which is the quick look 'debug and management tool'. You can start it from the command line and it opens a quick look window with the document as long as the format is supported by quick look (html, pdf etc). Some people discourage this use of qlmanage manage though because it misuses a debug and management tool. Below are some details.



Link to comment

@rice.shawn  Thank you, this opens up a lot of possibilities :o)

@CarlosNZ Here is an example of outputting a {query} and displaying with quicklook. && another example forcing the {query} to use whatever ql generator you have installed:


Action > Run Script

zsh escaping everything


# this will output your query & display it as rendered html

echo -n '{query}' > ~/index.html && cd ~ && qlmanage -p index.html

#this will display it has syntax highlighted code instead (as long as you have QLColorCode.qlgenerator)

qlmanage -p index.html -c .html -g /Users/rootscript/Library/QuickLook/QLColorCode.qlgenerator

This thread is turning out to be a lot of {query} output fun :o)

Edited by rootscript
Link to comment
  • 9 months later...

Looking to piggyback off this. I simply want to display the many available keyword options I'm building into a workflow. Seems like formatting them in an HTML document and then displaying them with this method would be a good way to go. 


However, I'm a newb and struggling with where I should store the file so it can be packaged up with the workflow and then how to refer to said file in the script. I need to be able to distribute it as a single package. 

Link to comment
  • 2 weeks later...

backlon —


It depends on how many keywords you want to put into the package. If they're between like 9 or 15 or something, then you could think about putting it as a script filter and showing the information directly in the Alfred window itself. If you want to use the quicklook option, then just create the html file and do something like "qlmanage -p index.html" because quicklook works with html natively, although css support is minimal and there is no javascript support. For css, you do need to include it all in the document itself — no external css files.


Another option that you could do is to look into automator applications. You can create one that simply uses the "open a webpage in a hud" (or something like that) action and opens a specific html page. Then export it as an application. After that, you'd just open the application via the path (you could do this in bash with "open path/to/appname.app").


If these are all static files, then you could just put them in the workflow directory itself (cmd+click on the workflow in Alfred Preferences and select "Show in Finder"). Then just call them via the relative paths.


Hope these help.

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...