Git Product home page Git Product logo

rr's Introduction

rr

Bash scripts: useful, fun to write, disorganized, easy to forget, easy to lose. Let's address some negatives!

rr is a compact meta-script, which organizes and runs other scripts:

# rr
The core /usr/local/libexec/rr module directory does not exist! Try making it.

Oops. Okay, let's fix that:

# mkdir -p /usr/local/libexec/rr
# rr
/usr/local/libexec/rr is empty! Try making a script and/or a dir.

Alright, let's make something:

# echo 'echo hi' > /usr/local/libexec/rr/hello
# rr
hello => No description! Add one by starting a line with ###

"hello" is there, but it isn't described:

# echo '### returns a friendly greeting' >> /usr/local/libexec/rr/hello
# rr
hello => returns a friendly greeting

Now let's run it:

# rr hellp
usage: [debug=1] /usr/local/sbin/rr [module|command]

Oops! Typo. Anything invalid yields usage. Let's try again:

# rr hello
hi

Now, with a DEEP DIVE ('bash -x'):

# debug=1 rr hello
+ echo hi
hi

That's basically it. Use dirs to group scripts (dirs can be nested):

# mkdir /usr/local/libexec/rr/foo
# echo 'echo bar' > /usr/local/libexec/rr/foo/bar
# echo '### returns bar' > /usr/local/libexec/rr/foo/bar
# rr
foo/
hello => returns a friendly greeting
# rr foo
bar => returns bar
# rr foo/bar
bar

And so on. While I'd still find rr useful on a single host, it excels on a wider environment: deploy rr to a bindir, and recursively deploy your scripts with something like Puppet. Or store them on a safe, shared directory. Just change the 'moduledir' variable in rr if you don't want to use /usr/local/libexec/rr.

You won't forget your scripts, because they're all in one place. You will know what they do, because they have auto-encouraged one-line descriptions. They'll be widely-available, because they're widely-shared. Cool?

rr's People

Contributors

astrostl avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.