DeleteRepo.sh (1127B)
1 #!/bin/sh 2 3 # This script will automate the removal of git repositories 4 # arguments available for this script are: 5 6 # -h, --help: Prints a help screen 7 # -n, --name: The name of the repo to delete 8 # -z, --fzf: Enables fzf support for the selection of repo to be deleted (Must have fzf installed on system) 9 10 # I should come up with some sort of confirmation for deleting the repo as well 11 12 REPODIR="./repos" 13 FZF=0 14 NAME="" 15 16 help() 17 { 18 echo "-h: Prints this help menu" 19 echo "-n: Name of repository to be deleted" 20 echo "-z: Enables FZF support for selecting repo, must have fzf installed" 21 } 22 23 deleteRepo() 24 { 25 if [ -z ${NAME} ]; then 26 rm -r ${REPODIR}/${NAME}.git 27 fi 28 29 echo "Which repo would you like to delete?" 30 NUM=1 31 for i in $( ls ${REPODIR} ); do 32 echo "${NUM}: $i" 33 NUM=$(expr ${NUM} + 1) 34 done 35 read INPUT 36 echo ${INPUT} 37 } 38 39 if [ "$#" -eq 0 ]; then 40 deleteRepo 41 fi 42 43 while getopts ":hzn:" f; do 44 case $f in 45 n) NAME=${OPTARG};; 46 z) FZF=1;; 47 h | *) help 48 exit 49 ;; 50 esac 51 done 52 shift `expr $OPTIND - 1` 53 54 deleteRepo $NAME