dd388/crals

Contributing guidelines

Opened this issue · 9 comments

It would be nice to add contribution guidelines. I think Github now supports a contributing.md, but I'm not that well-versed in writing contribution guidelines.

One thing I'd like to see highlighted is ways to find frequently used commands to turn into contributions. I'm starting with history | less but working towards a cut command.

ablwr commented

ffmprovisr has some copy-able guidelines in its README: https://github.com/amiaopensource/ffmprovisr

(Although should also have a contributing.md -- the benefit of this is that it pops up whenever you are drafting an issue or opening a PR as a reminder!).

dd388 commented

This is a really good suggestion. I hadn't heard about a contributing.md but it sounds pretty perfect. Hopefully I can put together something in the next week or so.

This comes super close to my dreamed of command contribution recommendation engine.
history | cut -d' ' -f4 | sort | uniq -c | sort

It has problems when the history line numbers increase in digit count. So that command works for everything in lines 1000-9999 in my history, but not <999 and not >10000. I'll think about this some more. Maybe it needs some grepping with sed.

Still not perfect, but this is getting somewhere
history | sed -En 's/^\s*[0-9]+\s+(([a-z0-9A-Z_-]+\s*){2}).*$/\1/p' | sort | uniq -c | sort
Apparently, -E is more universal than -r. Not sure... Let me know if this works on your platforms. Output should look like this:

...
 201 python3 drive_survey
 291 git add
 394 git commit
...

Changing the number in the curly brackets changes the number of match groups.
1 for commands
2 for commands + first group of flags
3 for commands + first group of flags + an argument
4 for etc

[a-z0-9A-Z_-]+ matches all the typical characters for bash commands and flags. I'd like to use [^\s]+, but sed doesn't have the full perl regex vocabulary, so that doesn't work. In the meantime, the list doesn't match paths, home squiggles, extension dots, etc. Could be added if useful.

dd388 commented

@ablwr thank you! Contribution guidelines are now a thing.

dd388 commented

@nkrabben your command isn't pulling up anything when I run it on the Terminal (using a Mac). Are you on Linux?

dd388 commented

Okay, what about this, using perl instead of sed:

history | perl -pe 's/\s{2}[0-9]+\s{2}(([a-z0-9A-Z_-]+\s*){2}).*$/\1/p' | sort| uniq -c | sort -n

Turns out I run ls and echo a lot. Hrm...

Nice, I thought it had something to do with sed's regex renderer but hadn't figured it out.

Is the output useful at all? I can also tweak the regex to count up only piped commands or other patterns. Also, usefulness might depend on how deep your history records. Mine is set to 10,000... new issue/commit incoming when i get home...

dd388 commented

Are you thinking of adding to to the CRALS front page or to the contributing guidelines? I think it'd work either way, but it could be cool to have it in the contributing guidelines. Like, look through your history to see what commands you use often to see what you might want to add to the site! What do you think?