Jump to content

jeremycherfas

Member
  • Posts

    34
  • Joined

  • Last visited

  • Days Won

    1

Reputation Activity

  1. Like
    jeremycherfas reacted to Stephen_C in Simple ideas: intermission—variables & cheese sandwiches   
    Background
    Do not be frightened of variables! Variables are nothing more than little titbits saved in a pocket for future use—just like cheese sandwiches.

    Except, except…you wouldn't put a cheese sandwich straight into your pocket, would you? First you'd tenderly wrap it to preserve its identity through the vicissitudes of pocket travel. So you won't be surprised to know that variables are exactly like cheese sandwiches: they need wrapping too.

    The skeletal workflow


    Explanation
    This is a quick and reasonably useless workflow purely to demonstrate use of variables: please excuse both it and me.

    1. We have a Universal Action limited to URLs (and we'll talk more about Universal Actions another day). All we do is to select a URL (remember, you always need to select something before using a Universal Action), press our Universal Actions hotkey, chose "Copy the URL” and press ⏎:


    2. We don't want to close the Alfred window (which we covered in this post).

    3. We're going to need to use the URL later in the workflow so we must pocket it in order not to lose it. That's what we do here:


    We use Alfred's Arg and Vars Utility. When we first open it {query} appears in the top box after Argument:. {query}, in this case, is the URL we just copied. We don't want to pass that on directly to the next item (the prompt for a friendly name) because if we do the URL will appear in the prompt field we have to complete. So we delete {query} if it appears after Argument:.

    What we do need to do is to save the URL as a variable. To do that we click on the + sign at the bottom of the Variables: box. First we give the variable a sensible name. That's important because we want easily to be able to recall what we called it. You can use any form of name you like—although I tend to use Camel case as here. After we've named the variable we must indicate what it contains. In this case it's very simple: {query} is what Alfred passed in to this Arg and Vars utility, so {query} is the URL and that's what we want to save to the variable.

    4. Now, for the first time we're going to use a variable <cue sound of distant trumpets>. The prompt for the URL friendly name is this:

    Friendly name for '{var:theURL}'

    (Note you can use variables in prompts like that—as well as in things like notifications and dialogs—to make them more helpful.)

    It's very important to note that when we use a variable we must use its wrapped-up form so that Alfred recognises it as a variable. That form is {var:variableName}: so the only thing that changes from case to case is variableName.

    In this case we've encased the variable in single quotation marks simply to make look better in the prompt:


    5. We don't close Alfred's window.

    6. Now, in a blaze of glory and another Arg and Vars Utility, we assemble the final text:


    We use the saved URL ({var:theURL}), the friendly name (which Alfred has passed us as {query}) and a little bit of text between them.

    We want to pass the text to Alfred 5.5's Text View but we can't pass out a new created variable from the Arg and Vars Utility that created it so, while ensuring this Arg and Vars Utility is not passing out anything (blank Argument:, unchecked Pass through input argument), we…

    7. Pass the text with another Arg and Vars Utility:


    Note, again, that the variable we saved as theText must appear here as a wrapped variable Alfred will recognise: {var:theText}.

    8. Finally…in Alfred's text view {var:theText} is translated into Real (if uninspiring) English:


    In conclusion
    This was intended to be a short post but, obsessed with the variables of cheese and Spam and the need to provide a foundation for future simple ideas, it has not been so. I apologise. Please take a break, choose your favourite sandwich and munch while meditating upon the delights of variables.
     
    Stephen
     
    The Simple Ideas posts
  2. Like
    jeremycherfas got a reaction from Stephen_C in Shrink JPEG/PNG file(s)   
    Thanks for this; very useful.
  3. Thanks
    jeremycherfas got a reaction from cands in Smartify quotes   
    alfred-smartify-quotes is a very simple Workflow I made to meet a very personal need.
     
    It takes selected text and transforms straight quotes into curly, smart, typographical quotes. It also converts two hyphens into an em dash. For me, the replacement text is pasted straight back over the selected text,. You can change that behaviour in the Copy to Clipboard block.
     
    I hope someone else finds it useful.
     
    Direct download.
     
    Jeremy
     
  4. Like
    jeremycherfas reacted to ichitaro in grep workflow   
    This searches for lines matching a regular expression like the grep command.
     

     
    You can install this workflow by downloading the .alfredworkflow file from:
    https://github.com/ichitaro/alfred-grep
     
    Notes: Input files are supposed to be encoded in UTF-8. For performance reasons, please consider using Alfred's File Buffer to reduce search scope, instead of passing a large directory tree to the file action.  
  5. Like
    jeremycherfas reacted to Vero in Alfred crashing repeatedly on macOS 10.13.1   
    @jeremycherfas I see you are using an early version of macOS High Sierra. The crash is actually a lower level crash in the macOS Metadata API in macOS 10.13.1. We raised this bug with Apple and they closed it as fixed in macOS 10.13.2. 
     
    If you update to the latest macOS (currently 10.13.3), this crash should go away
     
    Cheers,
    Vero
  6. Like
    jeremycherfas reacted to ayn in Append to nvALT journal   
    I have a prepend to text file workflow, you can download it here.
×
×
  • Create New...