aboutsummaryrefslogtreecommitdiff
path: root/bashrc
diff options
context:
space:
mode:
authorMiquel Sabaté <mikisabate@gmail.com>2013-07-25 11:48:59 +0200
committerMiquel Sabaté <mikisabate@gmail.com>2013-07-25 11:48:59 +0200
commit52cccd81415f93e8e989c8b73b7843be86092a2c (patch)
tree5039e6ca9e78272b601b641459e75719566608e7 /bashrc
parent6b4f63fe0ecfca26d4e4679579f11eaf09fdc281 (diff)
downloaddotfiles-52cccd81415f93e8e989c8b73b7843be86092a2c.tar.gz
dotfiles-52cccd81415f93e8e989c8b73b7843be86092a2c.zip
Added the p function.
This function acts as a shortcut to create a patch file from a git repo.
Diffstat (limited to 'bashrc')
-rw-r--r--bashrc16
1 files changed, 16 insertions, 0 deletions
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
+}