it would be nice if mr would keep things in order while adding stuff to our every-growing .mrconfig
files. I try to keep mine sorted, and did that by hand until I had to add a bunch of entries at once (because i managed to detect unregistered repos in tree), and it was then really impractical.
I hacked together this ridiculous Python script which reads a .INI file from stdin (or commandline arguments) and spews out a sorted version on stdout. A simple way to use this is:
sort-ini ~/.mrconfig | sponge ~/.mrconfig
The script is sort-ini and is available in my scripts repo. --?anarcat
I am by no way a command line expert, but I was unable to get the sort-ini method to work for me so I looked into generalized sorting by pattern and came across a site that had an example that was pretty close to what I needed.
A couple of paragraphs down the original example is labeled "Robbins' awk based shell pipeline"
https://homepage.smc.edu/morgan_david/linadmin/labs/sort-multiline-blocks.htm
From there I came to this
The
###
is my temp replacement for the newline so that sort can be used, at which point it is returned to a newline. I had trouble with the^Z
characters in the example.Which I then set up as an alias