From d1ef5a0b26f7f102fd2ff4613916203313320f86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Grondek?= Date: Thu, 28 Nov 2019 11:10:46 +0100 Subject: [PATCH] [git] Add custom command --- git/Makefile | 17 ++++++++++++++--- git/bin/git-purge | 3 +++ 2 files changed, 17 insertions(+), 3 deletions(-) create mode 100755 git/bin/git-purge diff --git a/git/Makefile b/git/Makefile index cc87e29..4012492 100644 --- a/git/Makefile +++ b/git/Makefile @@ -1,10 +1,13 @@ GIT_BIN=/usr/bin/git PACKAGE=git +CUSTOM_BINS= $(wildcard bin/*) + GIT_CONFIG=config GIT_CONFIG_OUT=$(HOME)/.config/git/config GIT_GLOBAL_CONFIG=$(HOME)/.gitconfig CONFIG_DIR=$(HOME)/.config/git +HOME_BIN_DIR=$(HOME)/bin ROOT_APT=sudo aptitude @@ -12,13 +15,16 @@ OUT=$(GIT_CONFIG_OUT) .PHONY: clean_install -clean_install: clean install -install: $(GIT_BIN) config -clean: clean_config clean_package +clean_install: clean install +install: $(GIT_BIN) install_bins config +clean: clean_config clean_package clean_bins $(GIT_BIN): $(ROOT_APT) install $(PACKAGE) +install_bins: $(HOME_BIN_DIR) + cp $(CUSTOM_BINS) $(HOME_BIN_DIR) + .ONESHELL: config: $(CONFIG_DIR) $(GIT_BIN) ifeq ("$(wildcard $(GIT_GLOBAL_CONFIG))","") @@ -32,9 +38,14 @@ endif $(CONFIG_DIR): mkdir -p $(CONFIG_DIR) +$(HOME_BIN_DIR): + mkdir -p $(HOME_BIN_DIR) + clean_package: $(ROOT_APT) purge $(PACKAGE) clean_config: rm -f $(GIT_CONFIG_OUT) +clean_bins: + rm -f $(CUSTOM_BINS:bin%=$(HOME_BIN_DIR)%) diff --git a/git/bin/git-purge b/git/bin/git-purge new file mode 100755 index 0000000..aad3a94 --- /dev/null +++ b/git/bin/git-purge @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +git branch --merged|egrep -v "(^*|master|dev)" | xargs git branch -d