Quieting ``mr`` output

John Whitley whitley at bangpath.org
Thu Jun 25 19:49:23 CEST 2015

Nice idea, Michael.  It’s possible to prepend text only if some command has output.  E.g.:

---- git-status-prepend: https://gist.github.com/2264a228ea64e4313d11

git -c color.status=always status -s | sed "1s/^/$*\\

This would be used as:

git-status-prepend “mr status: /path/to/repo”

The command only outputs the “mr status…” line if the preceding `git status` command has output.

The sed approach should be suitable for use in both `mr status` and `vcsh status`, if folks thought that was desirable.  (I certainly do!)

FWIW, I’ve tested the above approach with both BSD and GNU sed and it works fine.  It’s very basic “core” sed, and so avoids any differences in those lineages.  Looks like sed is already used in vcsh, so this wouldn’t add a new dependency.
— John

On Wed, Jun 24, 2015, at 06:07 PM, Michael Henry wrote:
> All,
> I've been using ``mr`` to track my various projects in git,
> along with my home directory.  I really like how it allows me to
> organize and track my work.  For some time, I've been using a
> home-grown utility to quiet down the output from ``mr status``.
> In this way, I can run ``mr status`` from my home directory and
> check the status of all 130+ repositories at once without having
> to scroll back through twice that many lines of text looking for
> something interesting.
> The output from ``mr status`` by default looks something like
> the following::
>  mr status: /home/mike/.
>  mr status: /home/mike/.vim
>   M vimrc
>  mr status: /home/mike/projects/ProjectOne
>  mr status: /home/mike/projects/ProjectTwo
>  [...]
>  mr status: /home/mike/projects/ProjectN
> I could grep away the blank lines and the ``mr status:...``
> lines, but this makes it difficult in general to tell which
> repository contains the changes.  I prefer to keep the ``mr
> status:...`` lines for repositories with changes, but squelch
> them otherwise.  In the above example, my preferred output
> would be:
>  mr status: /home/mike/.vim
>   M vimrc
> In case someone else might find it useful, I've published this
> Python-based utility (which I've named ``ptee`` for "Progress
> Tee") on the Python Package Index.  I alias ``mr`` to point to
> the below script (which I call ``mrwrap``) so that I can execute
> ``mr status`` and get the quiet output I prefer.
> To try this out::
>  pip install ptee
>  alias mr='mrwrap'
> Then save the text between the ``---cut`` lines as ``mrwrap``
> and make it executable.  The ``ptee`` utility can be found here
> for manual downloading:
> https://pypi.python.org/pypi?name=ptee&version=0.2.0&:action=display
> ---cut mrwrap---
> #!/bin/bash
> mrtee()
> {
>    ptee \
>        --regex '^mr (status|update|push): /' \
>        --regex '^(Everything|Already) up-to-date' \
>        --regex '^\s*$' \
>        --heading-regex '^mr \S+: finished '
> }
> mr "$@" 2>&1 | mrtee
> ---cut mrwrap---
> Michael Henry
> _______________________________________________
> vcs-home mailing list
> vcs-home at lists.madduck.net
> http://lists.madduck.net/listinfo/vcs-home

More information about the vcs-home mailing list