1. 44

Example makes it clearer:

$ with git
git> add .
git> commit -a -m "Commited"
git> push
  1.  

  2. 5

    This reminds me a lot of a common Common Lisp macro idiom. If there’s some thing that’s likely to be used in a block of code in a way which would cause repetition (a socket, an object, etc.), one idiom is to provide a with-xxx macro that makes one specific instance of the thing in question implicit/default in that context. In this case, the command name.

    To illustrate what I mean with some invented Lisp pseudocode for your example, a convenience macro like this would be normal to find in a Lisp package:

    (git-add .)
    (git-commit -a -m "Committed")
    (git-push)
    
    -->
    
    (with-command 'git
      (add .)
      (commit -a -m "Committed")
      (push))
    
    1. 2

      Really like this idea!

      Will have to watch myself - I can imagine accidentally staying in a “sudo>” shell :/

      1. 1

        Does eat history though (commands run in sub shell are not captured)

        1. 1

          Im no bash expert but I think it could append to the bash history file or at least call a command to. That might be an easy addition.

          1. 2

            the author says it’s on the todo list

        2. 1

          you mean like ‘su’?

          1. 3

            Yeah you’re absolutely right :) - although I tend to avoid su for the exact same reason

            1. 1

              or sudo -s

          2. 2