Simple Git & GitHub CLI Shell Scripts
1#!/bin/bash 2 3function gdf { 4 if ! is_a_git_repo; then 5 echo "${BOLD} This won't work, you are not in a git repo !"; 6 return 0 7 fi 8 9 git diff ${1:-} 10} 11 12# Resolve the full path to the script's directory 13REAL_PATH="$(dirname "$(readlink -f "$0")")" 14PARENT_DIR="$(dirname "$REAL_PATH")" 15CATEGORY="git.scripts" 16 17HELPS_DIR="$PARENT_DIR/helps/$CATEGORY" 18HELP_FILE="$(basename "$0" .sh)_help.sh" 19 20UTILS_DIR="$PARENT_DIR/utils" 21 22# Import necessary variables and functions 23source "$UTILS_DIR/check_git.sh" 24source "$UTILS_DIR/setup_git.sh" 25source "$UTILS_DIR/check_sudo.sh" 26source "$UTILS_DIR/colors.sh" 27source "$UTILS_DIR/usage.sh" 28 29# Import help file 30source "$HELPS_DIR/$HELP_FILE" 31 32# Usage function to display help 33function usage { 34 show_help "Usage" "${gdf_arguments[@]}" 35 show_help "Description" "${gdf_descriptions[@]}" 36 show_help "Options" "${gdf_options[@]}" 37 show_extra "${gdf_extras[@]}" 38 exit 0 39} 40 41# Check if --help is the first argument 42[ "$1" = "--help" ] && usage 43 44# prompt for sudo 45# password if required 46allow_sudo 47 48# Setting up git 49setup_git 50 51# Call gdf function 52gdf "$@"