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