Skip to content

list (& search?) output to Brewfile format #928

@erikw

Description

@erikw

Problem(s) addressed

I manage my Homebrew installations with a few Brewfiles. The workflow is for a new app installation is that a new app from the App Store must be installed the very first time for each Apple Account, either with

  • the App Store.app GUI
  • or with $ mas purchase <id>,

and then after this, if I'm happy with the new app, I can add an entry in my Brewfile to mark this app as now included in my system base setup.

This last step is a bit cumbersome, as the format for mas in Brewfile is very different from the output of the mas commands. After having installed the software from the App Store.app, I could use mas to find the ID, e.g. with

$ mas list | grep Numbers
409203825   Numbers                   (13.2)

or

mas search Numbers
   409203825  Numbers                         (14.4)

Now I have to manually copy the output from these commands, 409203825 Numbers and transform this in my editor to the format of a Brewfile, which is very different,:

mas 'Numbers', id: 409203825

This is a text transformation process involving:

  • Swapping the order of the two words
  • Adding single quotes around the name
  • Adding a comma after the name
  • prefixing id: before the ID.

Luckily Vim has many functions to transform with some strokes, but it's still quite a lot of hands-on to maintain a Brewfile with mas entries!

Proposed solution(s)

It's quite easy, I would imagine, to make working with Brewfile + mas together better. If the list (maybe search too?) commands had an optional switch, say -b , to list the results in Brefile format, it would be a matter of copy&paste or even redirect the output to append to a Brewfile directly!

$ mas list -b | grep Numbers
mas 'Numbers', id: 409203825

Alternative solution(s)

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions