Jump to content

workflow: bash script that calls redcarpet


Recommended Posts

Posted

Hi.

 

I have a script which echos stuff into an html file and then renders markdown there. It works when called from the terminal. When called in a Alfred workflow however, the echo commands work – the redcarpet command doesn't.

 

I suspect it might have to do with me using rbenv and the enviroment not being accessible in the workflow, but am not fluent enough to debug this.

 

Here is the workflow:

#!/bin/bash

f=~/projects/filtercake/linklist.md
t=`mktemp /tmp/alfred_prepend.XXXXXXXX`
q={query}
d=`date +%Y-%m-%d`
e="- "$q"    ["$d"]"

cat - $f <<< $e > $t
mv $t $f
rm $t

~/projects/filtercake/render-linklist

And here is the script:

#!/bin/bash

cd ~/projects/filtercake

touch bookmarks.html
echo "---" > bookmarks.html
echo "layout: default" >> bookmarks.html
echo "title: bookmarks" >> bookmarks.html
echo "---" >> bookmarks.html
echo " " >> bookmarks.html

echo "<h1>Bookmarks</h1>" >> bookmarks.html

redcarpet linklist.md >> bookmarks.html

The workflow is here: https://dl.dropboxusercontent.com/u/2146484/bookmark.alfredworkflow

 

Any help would be much appreciated...

Posted

I suspect it might have to do with me using rbenv and the enviroment not being accessible in the workflow

That is correct. To access rbenv via your shell, you probably added some commands to your .bashrc (or equivalent file). Add those same commands to the top of your script in Alfred, and it should work.

Posted

To access rbenv via your shell, you probably added some commands to your .bashrc (or equivalent file). Add those same commands to the top of your script in Alfred, and it should work.

 

Yes, that solved it. Thx a lot!

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...