Shell scripts with expansions

11 views
Skip to first unread message

Sean Mackesey

unread,
Jun 16, 2013, 10:09:49 AM6/16/13
to keym...@googlegroups.com
This command works properly when I run it from pry but doesn't work from triggered with a map in the Keymandorc:

`screencapture -tjpg $SCREENSHOTS_DIR/$(date +%s).jpg`

It invokes screencapture correctly and takes a picture, but something is going wrong when saving the file-- it just doesn't show up.  I think it has to do with the $(date +%s) part.  I thought the problem might be that I normally use zsh and that Keymando was using bash, but testing the command out in a bash prompt showed that it worked.  Any ideas?  As a side note, it would be nice to have access to a log of some kind for debugging issues like this.

Jean-Paul S. Boodhoo

unread,
Jun 17, 2013, 11:48:41 AM6/17/13
to keym...@googlegroups.com
Hey Sean,

Did you try doing regular ruby string interpolation for the date piece:

time = DateTime.now
time = time.strftime("%Q")
`screencapture -tpjg $SCREENSHOTS_DIR/#{time}.jpg`

Let me know if that works for you.

God Bless You,

JP
On 06/16, Sean Mackesey wrote:
> This command works properly when I run it from *pry* but doesn't work from
> triggered with a map in the Keymandorc:
>
> *`screencapture -tjpg $SCREENSHOTS_DIR/$(date +%s).jpg`
> *
>
> It invokes screencapture correctly and takes a picture, but something is
> going wrong when saving the file-- it just doesn't show up. I think it has
> to do with the *$(date +%s)* part. I thought the problem might be that I
> normally use zsh and that Keymando was using bash, but testing the command
> out in a bash prompt showed that it worked. Any ideas? As a side note, it
> would be nice to have access to a log of some kind for debugging issues
> like this.
>
> --
> You received this message because you are subscribed to the Google Groups "Keymando" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to keymando+u...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Sean Mackesey

unread,
Jun 17, 2013, 6:41:07 PM6/17/13
to keym...@googlegroups.com
This doesn't work either-- I've figured out the problem is the SCREENSHOTS_DIR environment variable.  This is defined in my zshenv, so it makes sense that Keymando wouldn't be able to access it (I assume keymando is using bash by default?).  I notice though that if I restart Keymando from a zsh shell using `open /Applications/Keymando.app` it then works.  Is there any way to make it so that Keymando has access to my zshenv-defined environment variables when I start up my system?  Thanks.
You received this message because you are subscribed to a topic in the Google Groups "Keymando" group.
To unsubscribe from this group and all its topics, send an email to keymando+u...@googlegroups.com.

Jean-Paul S. Boodhoo

unread,
Jun 21, 2013, 8:48:07 AM6/21/13
to keym...@googlegroups.com
Hey Sean,

Currently there is not a traditional way to do this. I accomplish this by using an expansion system against all of my dotfiles, so that my "variables" are available to disparate script types in my environment.

If you're curious how it works, let me know!

God Bless You,

JP
> > > To unsubscribe from this group and stop receiving emails from it, send an email to keymando+u...@googlegroups.com (mailto:keymando+u...@googlegroups.com).
> > > For more options, visit https://groups.google.com/groups/opt_out.
> > >
> >
> >
> > --
> > You received this message because you are subscribed to a topic in the Google Groups "Keymando" group.
> > To unsubscribe from this topic, visit https://groups.google.com/d/topic/keymando/biX71c-9Yf4/unsubscribe.
> > To unsubscribe from this group and all its topics, send an email to keymando+u...@googlegroups.com (mailto:keymando+u...@googlegroups.com).
Reply all
Reply to author
Forward
0 new messages