From 52cccd81415f93e8e989c8b73b7843be86092a2c Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Date: Thu, 25 Jul 2013 11:48:59 +0200 Subject: Added the p function. This function acts as a shortcut to create a patch file from a git repo. --- bashrc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/bashrc b/bashrc index 00ee87b..152c56f 100644 --- a/bashrc +++ b/bashrc @@ -73,3 +73,19 @@ function g { echo "unknown shortcut" } +# The path for patches. +export PATCH=$HOME/.patches + +# Create a patch and save it to the directory of patches. If the patch +# already exists, it will ask if the user wants to overwrite it. +p() { + path="$PATCH/$1.patch" + if [ -f $path ]; then + echo "The patch \`$1' already exists." + read -p "Do you want to overwrite its contents ? (Y/n) " yn + case $yn in + n | N | no | NO ) exit 1 + esac + fi + git diff > $path +} -- cgit v1.2.3