This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def general_query(question, validator, default=None): | |
""" | |
Asks the given question, returning the (possibly modified) result if validator | |
allows it, and keeps asking until a valid answer is given. | |
:param str question: The question to ask. | |
:param validator: A function that acts on user response strings, and returns | |
`(success, modified_response, message)`. The loop ends if `success` is `True`, | |
in which case `modified_response` is returned. `message` is printed in | |
any case. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
timestamp() { | |
date +"%Y-%m-%d_%H:%M:%S" | |
} | |
pushd "$PWD" > /dev/null | |
SHA="$(git rev-parse --short HEAD)" | |
FILENAME="$HOME/Dropbox/diff/${PWD##*/}_$(timestamp)_$SHA.diff" | |
git diff > $FILENAME |
OlderNewer