Simple Git & GitHub CLI Shell Scripts
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor: switched to dotcase for repo name and directories

+2154 -2154
+2 -2
README.md
··· 18 18 19 19 1. **Clone the repository** 20 20 ```sh 21 - git clone https://github.com/hatixntsoa/source_controller.git 21 + git clone https://tangled.sh/@hatixntsoa.tngl.sh/source.controller 22 22 ``` 23 23 2. **Navigate to the directory** 24 24 ```sh ··· 26 26 ``` 27 27 3. **Set execution permissions** 28 28 ```sh 29 - chmod u+x {gh_scripts/*,git_scripts/*,setup/*} 29 + chmod u+x {gh.scripts/*,git.scripts/*,setup/*} 30 30 ``` 31 31 4. **Run the installation script** 32 32 ```sh
+196
gh.scripts/gbd.sh
··· 1 + #!/bin/bash 2 + 3 + function gbd { 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 + current_branch=$(git branch | awk '/\*/ {print $2}') 10 + default_branch=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@') 11 + current_user=$(awk '/user:/ {print $2; exit}' ~/.config/gh/hosts.yml) 12 + 13 + if [ -z "$default_branch" ]; then 14 + default_branch=$(git config --get init.defaultBranch) 15 + fi 16 + 17 + if [ $# -eq 1 ]; then 18 + if [ "$1" = "$default_branch" ]; then 19 + echo "${BOLD} Fatal ! Cannot Delete the Default Branch " 20 + return 0 21 + fi 22 + 23 + if ! git show-ref --verify --quiet "refs/heads/$1" &>/dev/null; then 24 + echo "${BOLD} Fatal ! Branch ${GREEN}$1 ${RESET_COLOR}doesn't exist ${RESET}" 25 + return 0 26 + fi 27 + 28 + # this to check if we want to delete the remote branch too 29 + check_delete_remote_branch() { 30 + if [ "$current_branch" = "$default_branch" ]; then 31 + echo "${BOLD} Fatal ! Cannot Delete the Default Branch " 32 + return 0 33 + fi 34 + 35 + printf "${BOLD}${RESET_COLOR}Delete remote branch${GREEN} "$current_branch"${RESET_COLOR} ? (y/n) ${RESET}" 36 + read delete_remote_branch 37 + echo ${RESET} 38 + 39 + if [ "$delete_remote_branch" = "y" ]; then 40 + git push origin --delete "$current_branch" 41 + elif [ "$delete_remote_branch" = "n" ]; then 42 + return 0 43 + else 44 + check_delete_remote_branch 45 + fi 46 + } 47 + 48 + check_delete_branch() { 49 + branch_name="$1" 50 + 51 + printf "${BOLD}${RESET_COLOR}Delete branch${GREEN} "$branch_name"${RESET_COLOR} ? (y/n) ${RESET}" 52 + read delete_branch 53 + 54 + if [ "$delete_branch" = "y" ]; then 55 + if [ "$current_branch" != "$default_branch" ]; then 56 + git checkout $default_branch >/dev/null 2>&1 57 + fi 58 + 59 + if has_remote; then 60 + repo_url=$(git config --get remote.origin.url) 61 + repo_owner=$(echo "$repo_url" | awk -F '[/:]' '{print $(NF-1)}') 62 + 63 + # check if we are not the owner of the repo 64 + if [ "$repo_owner" == "$current_user" ]; then 65 + is_remote_branch=$(git branch -r | grep "origin/$1") 66 + if [ -n "$is_remote_branch" ]; then 67 + # prompt for sudo 68 + # password if required 69 + allow_sudo 70 + 71 + # Check for internet connectivity to GitHub 72 + if $SUDO ping -c 1 github.com &>/dev/null; then 73 + check_delete_remote_branch 74 + fi 75 + fi 76 + fi 77 + fi 78 + 79 + git branch -D "$1" 80 + elif [ "$delete_branch" = "n" ]; then 81 + return 0 82 + else 83 + check_delete_branch $branch_name 84 + fi 85 + } 86 + 87 + check_delete_branch $1 88 + elif [ $# -eq 0 ]; then 89 + if [ "$current_branch" = "$default_branch" ]; then 90 + echo "${BOLD}${RESET_COLOR} Fatal ! Cannot Delete the Default Branch " 91 + return 0 92 + fi 93 + 94 + check_delete_branch() { 95 + printf "${BOLD}${RESET_COLOR}Delete branch${GREEN} "$current_branch"${RESET_COLOR} ? (y/n) ${RESET}" 96 + read delete_branch 97 + if [ "$delete_branch" = "y" ]; then 98 + # TODO : Remote branch Deletion 99 + check_delete_remote_branch() { 100 + if [ "$current_branch" = "$default_branch" ]; then 101 + echo "${BOLD}${RESET_COLOR} Fatal ! Cannot Delete the Default Branch " 102 + else 103 + printf "${BOLD}${RESET_COLOR}Delete remote branch${GREEN} "$current_branch"${RESET_COLOR} ? (y/n) ${RESET}" 104 + read delete_remote_branch 105 + echo ${RESET} 106 + if [ "$delete_remote_branch" = "y" ]; then 107 + git push origin --delete "$current_branch" 108 + elif [ "$delete_remote_branch" = "n" ]; then 109 + return 0 110 + else 111 + check_delete_remote_branch 112 + fi 113 + fi 114 + } 115 + 116 + git checkout "$default_branch" >/dev/null 2>&1 117 + 118 + if has_remote; then 119 + repo_url=$(git config --get remote.origin.url) 120 + repo_owner=$(echo "$repo_url" | awk -F '[/:]' '{print $(NF-1)}') 121 + 122 + # check if we are not the owner of the repo 123 + if [ "$repo_owner" == "$current_user" ]; then 124 + is_remote_branch=$(git branch -r | grep "origin/$current_branch") 125 + 126 + if [ -n "$is_remote_branch" ]; then 127 + # prompt for sudo 128 + # password if required 129 + allow_sudo 130 + 131 + # Check for internet connectivity to GitHub 132 + if $SUDO ping -c 1 github.com &>/dev/null; then 133 + check_delete_remote_branch 134 + fi 135 + fi 136 + fi 137 + fi 138 + git branch -D "$current_branch" 139 + elif [ "$delete_branch" = "n" ]; then 140 + return 0 141 + else 142 + check_delete_branch 143 + fi 144 + } 145 + check_delete_branch 146 + else 147 + echo "${BOLD}${RESET_COLOR} Usage : gbd branch_to_delete" 148 + fi 149 + } 150 + 151 + # Resolve the full path to the script's directory 152 + REAL_PATH="$(dirname "$(readlink -f "$0")")" 153 + PARENT_DIR="$(dirname "$REAL_PATH")" 154 + CATEGORY="gh.scripts" 155 + 156 + HELPS_DIR="$PARENT_DIR/helps/$CATEGORY" 157 + HELP_FILE="$(basename "$0" .sh)_help.sh" 158 + 159 + UTILS_DIR="$PARENT_DIR/utils" 160 + 161 + # Import necessary variables and functions 162 + source "$UTILS_DIR/check_connection.sh" 163 + source "$UTILS_DIR/check_remote.sh" 164 + source "$UTILS_DIR/check_git.sh" 165 + source "$UTILS_DIR/setup_git.sh" 166 + source "$UTILS_DIR/check_sudo.sh" 167 + source "$UTILS_DIR/colors.sh" 168 + source "$UTILS_DIR/usage.sh" 169 + 170 + # Import help file 171 + source "$HELPS_DIR/$HELP_FILE" 172 + 173 + # Usage function to display help 174 + function usage { 175 + show_help "Usage" "${gbd_arguments[@]}" 176 + show_help "Description" "${gbd_descriptions[@]}" 177 + show_help "Options" "${gbd_options[@]}" 178 + show_extra "${gbd_extras[@]}" 179 + exit 0 180 + } 181 + 182 + # Check if --help is the first argument 183 + [ "$1" = "--help" ] && usage 184 + 185 + # prompt for sudo 186 + # password if required 187 + allow_sudo 188 + 189 + # Setting up git 190 + setup_git 191 + 192 + # Check for internet connectivity to GitHub 193 + check_connection 194 + 195 + # Call gbd function 196 + gbd "$@"
+177
gh.scripts/gck.sh
··· 1 + #!/bin/bash 2 + 3 + # WARNING : 03-30-2025 02:18 4 + # Specify the base branch 5 + # when trying to create feature 6 + # branches with the following commands 7 + # git switch -c new-branch old-branch 8 + # git push -u origin new-branch 9 + 10 + function gck { 11 + if ! is_a_git_repo; then 12 + echo "${BOLD} This won't work, you are not in a git repo !" 13 + return 0 14 + fi 15 + 16 + current_branch=$(git branch | awk '/\*/ {print $2}') 17 + 18 + if has_remote; then 19 + default_branch=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@') 20 + repo_url=$(git config --get remote.origin.url) 21 + repo_name="$(echo "$repo_url" | awk -F '/' '{print $NF}' | sed 's/.git$//')" 22 + repo_owner=$(echo "$repo_url" | awk -F '[/:]' '{print $(NF-1)}') 23 + current_user=$(awk '/user:/ {print $2; exit}' ~/.config/gh/hosts.yml) 24 + else 25 + default_branch=$(git config --get init.defaultBranch) 26 + repo_name=$(basename "$(git rev-parse --show-toplevel)") 27 + fi 28 + 29 + if [ -z "$default_branch" ]; then 30 + default_branch=$(git config --get init.defaultBranch) 31 + fi 32 + 33 + if [ $# -eq 0 ]; then 34 + if [ "$current_branch" != "$default_branch" ]; then 35 + git checkout "$default_branch" 36 + else 37 + user="$(whoami)" 38 + if ! is_a_git_branch "$user"; then 39 + check_new_branch() { 40 + printf "${BOLD}${RESET_COLOR}New branch${GREEN} "$user"${RESET_COLOR} ? (y/n) " 41 + read branch 42 + if [ "$branch" = "y" ]; then 43 + git checkout -b "$user" >/dev/null 2>&1 44 + 45 + # check for remote 46 + if has_remote && gh_installed; then 47 + check_new_remote_branch() { 48 + printf "${BOLD}${RESET_COLOR}Add${GREEN} "$user"${RESET_COLOR} branch to ${LIGHT_BLUE}$repo_name ${RESET_COLOR}on GitHub ? (y/n) " 49 + read remote_branch 50 + if [ "$remote_branch" = "y" ]; then 51 + git push origin "$user" 52 + elif [ "$remote_branch" = "n" ]; then 53 + return 0 54 + else 55 + check_new_remote_branch 56 + fi 57 + } 58 + 59 + # check if we are not the owner of the repo 60 + if [ "$repo_owner" == "$current_user" ]; then 61 + # Check for internet connectivity to GitHub 62 + if $SUDO ping -c 1 github.com &>/dev/null; then 63 + check_new_remote_branch 64 + else 65 + echo "${BOLD} Cannot push to remote branch, you are offline !${RESET}" 66 + fi 67 + fi 68 + fi 69 + elif [ "$branch" = "n" ]; then 70 + return 0 71 + else 72 + check_new_branch 73 + fi 74 + } 75 + check_new_branch 76 + else 77 + git checkout "$user" 78 + fi 79 + fi 80 + elif [ $# -eq 1 ]; then 81 + # check if the branch doesn't exist yet 82 + if ! is_a_git_branch "$1" >/dev/null 2>&1; then 83 + new_branch="$1" 84 + check_new_branch() { 85 + printf "${BOLD}${RESET_COLOR}New branch${GREEN} "$new_branch"${RESET_COLOR} ? (y/n) " 86 + read branch 87 + if [ "$branch" = "y" ]; then 88 + git checkout -b "$new_branch" >/dev/null 2>&1 89 + 90 + # check for remote 91 + if has_remote; then 92 + check_new_remote_branch() { 93 + printf "${BOLD}${RESET_COLOR}Add${GREEN} "$new_branch"${RESET_COLOR} branch to ${LIGHT_BLUE}$repo_name ${RESET_COLOR} on GitHub ? (y/n) " 94 + read remote_branch 95 + echo ${RESET} 96 + if [ "$remote_branch" = "y" ]; then 97 + git push origin "$new_branch" 98 + elif [ "$remote_branch" = "n" ]; then 99 + return 0 100 + else 101 + check_new_remote_branch 102 + fi 103 + } 104 + 105 + # check if we are not the owner of the repo 106 + if [ "$repo_owner" == "$current_user" ]; then 107 + # Check for internet connectivity to GitHub 108 + if $SUDO ping -c 1 github.com &>/dev/null; then 109 + check_new_remote_branch 110 + else 111 + echo "${BOLD} Cannot push to remote branch, you are offline !${RESET}" 112 + fi 113 + fi 114 + fi 115 + elif [ "$branch" = "n" ]; then 116 + return 0 117 + else 118 + check_new_branch 119 + fi 120 + } 121 + check_new_branch 122 + else 123 + git checkout "$1" 124 + fi 125 + else 126 + echo "${BOLD} Usage : gck branch or gck (switch default branch)" 127 + fi 128 + } 129 + 130 + # Resolve the full path to the script's directory 131 + REAL_PATH="$(dirname "$(readlink -f "$0")")" 132 + PARENT_DIR="$(dirname "$REAL_PATH")" 133 + CATEGORY="gh.scripts" 134 + 135 + HELPS_DIR="$PARENT_DIR/helps/$CATEGORY" 136 + HELP_FILE="$(basename "$0" .sh)_help.sh" 137 + 138 + UTILS_DIR="$PARENT_DIR/utils" 139 + 140 + # Import necessary variables and functions 141 + source "$UTILS_DIR/check_connection.sh" 142 + source "$UTILS_DIR/check_remote.sh" 143 + source "$UTILS_DIR/check_git.sh" 144 + source "$UTILS_DIR/check_gh.sh" 145 + source "$UTILS_DIR/setup_git.sh" 146 + source "$UTILS_DIR/check_branch.sh" 147 + source "$UTILS_DIR/check_sudo.sh" 148 + source "$UTILS_DIR/colors.sh" 149 + source "$UTILS_DIR/usage.sh" 150 + 151 + # Import help file 152 + source "$HELPS_DIR/$HELP_FILE" 153 + 154 + # Usage function to display help 155 + function usage { 156 + show_help "Usage" "${gck_arguments[@]}" 157 + show_help "Description" "${gck_descriptions[@]}" 158 + show_help "Options" "${gck_options[@]}" 159 + show_extra "${gck_extras[@]}" 160 + exit 0 161 + } 162 + 163 + # Check if --help is the first argument 164 + [ "$1" = "--help" ] && usage 165 + 166 + # prompt for sudo 167 + # password if required 168 + allow_sudo 169 + 170 + # Setting up git 171 + setup_git 172 + 173 + # Check for internet connectivity to GitHub 174 + check_connection 175 + 176 + # Call gck function 177 + gck "$@"
+105
gh.scripts/gcln.sh
··· 1 + #!/bin/bash 2 + 3 + function clone_repo { 4 + # Default GitHub URL prefix 5 + GITHUB_URL="https://github.com" 6 + 7 + local depth="" 8 + 9 + while [[ $# -gt 0 ]]; do 10 + case "$1" in 11 + --depth | -d) 12 + depth="$2" 13 + shift 2 14 + ;; 15 + *) 16 + # Assuming the first argument is owner/repo 17 + repo="$1" 18 + IFS="/" read -r repo_owner repo_name <<< "$repo" 19 + ;; 20 + esac 21 + shift 22 + done 23 + 24 + # Check if repo has not the format owner/repo 25 + if [[ ! "$repo" =~ $clone_regex ]]; then 26 + current_user=$(awk '/user:/ {print $2; exit}' ~/.config/gh/hosts.yml) 27 + 28 + # if it is our own repo the clone it 29 + if is_my_github_repo "$current_user/$repo"; then 30 + gh repo clone "$current_user/$repo" 31 + return 0 32 + fi 33 + 34 + # else print the help 35 + usage 36 + fi 37 + 38 + # Check if the owner exists on GitHub 39 + if ! is_a_github_user "$repo_owner"; then 40 + echo "${BOLD} Sorry, there is no user named ${GREEN}$repo_owner ${RESET_COLOR}on ${LIGHT_BLUE}GitHub !" 41 + return 0 42 + fi 43 + 44 + # Construct the full GitHub clone URL 45 + url="$GITHUB_URL/$repo" 46 + 47 + # If depth is provided, use it in the git clone command 48 + if [[ -n "$depth" ]]; then 49 + git clone "$url" --depth="$depth" 50 + else 51 + git clone "$url" 52 + fi 53 + } 54 + 55 + # Resolve the full path to the script's directory 56 + REAL_PATH="$(dirname "$(readlink -f "$0")")" 57 + PARENT_DIR="$(dirname "$REAL_PATH")" 58 + CATEGORY="gh.scripts" 59 + 60 + HELPS_DIR="$PARENT_DIR/helps/$CATEGORY" 61 + HELP_FILE="$(basename "$0" .sh)_help.sh" 62 + 63 + UTILS_DIR="$PARENT_DIR/utils" 64 + 65 + # Import necessary variables and functions 66 + source "$UTILS_DIR/check_connection.sh" 67 + source "$UTILS_DIR/check_repo.sh" 68 + source "$UTILS_DIR/check_git.sh" 69 + source "$UTILS_DIR/setup_git.sh" 70 + source "$UTILS_DIR/check_sudo.sh" 71 + source "$UTILS_DIR/check_user.sh" 72 + source "$UTILS_DIR/colors.sh" 73 + source "$UTILS_DIR/usage.sh" 74 + 75 + # Import help file 76 + source "$HELPS_DIR/$HELP_FILE" 77 + 78 + # Usage function to display help 79 + function usage { 80 + show_help "Usage" "${gcln_arguments[@]}" 81 + show_help "Description" "${gcln_descriptions[@]}" 82 + show_help "Options" "${gcln_options[@]}" 83 + exit 0 84 + } 85 + 86 + # regex to match clone repo case 87 + clone_regex='^[a-zA-Z0-9._-]+/[a-zA-Z0-9._-]+$' 88 + 89 + # Display help on --help flag and insifficient argument 90 + if [[ "$1" == "--help" || "$#" -lt 1 ]]; then 91 + usage 92 + fi 93 + 94 + # prompt for sudo 95 + # password if required 96 + allow_sudo 97 + 98 + # Setting up git 99 + setup_git 100 + 101 + # Check for internet connectivity to GitHub 102 + check_connection 103 + 104 + # Call the function with all arguments 105 + clone_repo "$@"
+95
gh.scripts/ghadd.sh
··· 1 + #!/bin/bash 2 + 3 + function ghadd { 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 + if ! has_remote; then 10 + echo "${BOLD} This repo has no remote on GitHub !" 11 + return 0 12 + fi 13 + 14 + if [ $# -eq 0 ]; then 15 + echo "${BOLD} Specify the username of the new collaborator !" 16 + return 0 17 + fi 18 + 19 + current_user=$(awk '/user:/ {print $2; exit}' ~/.config/gh/hosts.yml) 20 + repo_url=$(git config --get remote.origin.url) 21 + repo_owner=$(echo "$repo_url" | awk -F '[/:]' '{print $(NF-1)}') 22 + repo_name="$(echo "$repo_url" | awk -F '/' '{print $NF}' | sed 's/.git$//')" 23 + 24 + # check if we are not the owner of the repo 25 + if [ "$repo_owner" != "$current_user" ]; then 26 + echo "${BOLD} Sorry, you are not the owner of this repo !" 27 + return 0 28 + fi 29 + 30 + # Loop through each collaborator username provided as an argument 31 + for collaborator in "$@"; do 32 + # Check if the collaborator exists on GitHub 33 + if ! is_a_github_user "$collaborator"; then 34 + printf "${BOLD} Cannot invite ${LIGHT_BLUE}$collaborator ${RESET_COLOR}to collaborate on ${LIGHT_BLUE}$repo_name${RESET_COLOR} " 35 + continue 36 + fi 37 + 38 + execute_with_loading \ 39 + "${BOLD} Inviting ${LIGHT_BLUE}$collaborator ${RESET_COLOR}to collaborate on ${LIGHT_BLUE}$repo_name${RESET_COLOR}" \ 40 + "gh api --method=PUT repos/$current_user/$repo_name/collaborators/$collaborator" 41 + done 42 + } 43 + 44 + # Resolve the full path to the script's directory 45 + REAL_PATH="$(dirname "$(readlink -f "$0")")" 46 + PARENT_DIR="$(dirname "$REAL_PATH")" 47 + CATEGORY="gh.scripts" 48 + 49 + HELPS_DIR="$PARENT_DIR/helps/$CATEGORY" 50 + HELP_FILE="$(basename "$0" .sh)_help.sh" 51 + 52 + UTILS_DIR="$PARENT_DIR/utils" 53 + 54 + # Import necessary variables and functions 55 + source "$UTILS_DIR/check_connection.sh" 56 + source "$UTILS_DIR/check_git.sh" 57 + source "$UTILS_DIR/check_gh.sh" 58 + source "$UTILS_DIR/setup_git.sh" 59 + source "$UTILS_DIR/check_remote.sh" 60 + source "$UTILS_DIR/check_sudo.sh" 61 + source "$UTILS_DIR/check_user.sh" 62 + source "$UTILS_DIR/colors.sh" 63 + source "$UTILS_DIR/loading.sh" 64 + source "$UTILS_DIR/usage.sh" 65 + 66 + # Import help file 67 + source "$HELPS_DIR/$HELP_FILE" 68 + 69 + # Usage function to display help 70 + function usage { 71 + show_help "Usage" "${ghadd_arguments[@]}" 72 + show_help "Description" "${ghadd_descriptions[@]}" 73 + show_help "Options" "${ghadd_options[@]}" 74 + show_extra "${ghadd_extras[@]}" 75 + exit 0 76 + } 77 + 78 + # Check if --help is the first argument 79 + [ "$1" = "--help" ] && usage 80 + 81 + # prompt for sudo 82 + # password if required 83 + allow_sudo 84 + 85 + # Setting up git 86 + setup_git 87 + 88 + # Check gh 89 + check_gh 90 + 91 + # Check for internet connectivity to GitHub 92 + check_connection 93 + 94 + # Call ghadd function 95 + ghadd "$@"
+178
gh.scripts/ghc.sh
··· 1 + #!/bin/bash 2 + 3 + function ghc { 4 + # Get the repo name and visibility 5 + if [ $# -eq 0 ]; then 6 + repo="$(basename "$PWD")" 7 + repo_visibility="public" 8 + elif [ $# -eq 1 ]; then 9 + if [ "$1" = "private" ]; then 10 + repo="$(basename "$PWD")" 11 + repo_visibility="private" 12 + else 13 + repo="$1" 14 + repo_visibility="public" 15 + fi 16 + elif [ $# -eq 2 ]; then 17 + repo="$1" 18 + repo_visibility="$2" 19 + else 20 + echo "${BOLD}${RED}Error: Too many arguments.${RESET}" 21 + usage 22 + fi 23 + 24 + # Clean the repo name 25 + repo_name=$(clean_repo "$repo") 26 + 27 + if is_a_git_repo; then 28 + if has_remote; then 29 + printf "${BOLD} This repo already has a remote on GitHub!${RESET}\n" 30 + return 0 31 + fi 32 + 33 + current_user=$(awk '/user:/ {print $2; exit}' ~/.config/gh/hosts.yml) 34 + current_protocol=$(grep 'git_protocol:' ~/.config/gh/hosts.yml | awk '{print $2}') 35 + origin_base_url=$( 36 + [[ "$current_protocol" == "ssh" ]] && 37 + echo "git@github.com:" || 38 + echo "https://github.com/" 39 + ) 40 + 41 + check_set_repo() { 42 + printf "${BOLD}${RESET_COLOR} Create ${GREEN}$repo_visibility ${RESET_COLOR}repo ${LIGHT_BLUE}$repo_name ${RESET_COLOR}? (y/n) ${RESET}" 43 + read set_repo 44 + if [ "$set_repo" = "y" ]; then 45 + # Create the repo & set it as remote of the local one 46 + printf "${BOLD} New repository ${LIGHT_BLUE}$repo_name ${RESET_COLOR}on GitHub ... ${RESET}" 47 + gh repo create "$repo_name" --"$repo_visibility" &>/dev/null 48 + git remote add origin "$origin_base_url$current_user/$repo_name.git" 49 + printf "${BOLD}${GREEN} ${RESET}\n" 50 + 51 + check_push() { 52 + printf "${BOLD}${RESET_COLOR} Push local commits to ${LIGHT_BLUE}$repo_name ${RESET_COLOR}? (y/n) ${RESET}" 53 + read check_push_commit 54 + 55 + if [ "$check_push_commit" = "y" ]; then 56 + current_branch=$(git branch | awk '/\*/ {print $2}') 57 + git push origin "$current_branch" 58 + elif [ "$check_push_commit" = "n" ]; then 59 + return 0 60 + else 61 + check_push 62 + fi 63 + } 64 + 65 + current_branch=$(git branch | awk '/\*/ {print $2}') 66 + 67 + if git rev-list --count "$current_branch" 2>/dev/null | grep -q '^[1-9]'; then 68 + check_push 69 + fi 70 + elif [ "$set_repo" = "n" ]; then 71 + return 0 72 + else 73 + check_set_repo 74 + fi 75 + } 76 + check_set_repo 77 + else 78 + # Check for internet connectivity to GitHub 79 + if ! connected; then 80 + echo "${BOLD} Sorry, you are offline !${RESET}" 81 + check_local() { 82 + printf "${BOLD}${RESET_COLOR} Create ${GREEN}local ${RESET_COLOR}repo ${LIGHT_BLUE}$repo_name ${RESET_COLOR}? (y/n) ${RESET}" 83 + read create_local 84 + 85 + if [ "$create_local" = "y" ]; then 86 + git init &>/dev/null 87 + elif [ "$create_local" = "n" ]; then 88 + return 0 89 + else 90 + check_local 91 + fi 92 + } 93 + check_local 94 + else 95 + check_create_repo() { 96 + printf "${BOLD}${RESET_COLOR} Create ${GREEN}$repo_visibility ${RESET_COLOR}repo ${LIGHT_BLUE}$repo_name ${RESET_COLOR}? (y/n) ${RESET}" 97 + read create_repo 98 + if [ "$create_repo" = "y" ]; then 99 + # Create the repo & clone it locally 100 + printf "${BOLD} New repository ${LIGHT_BLUE}$repo_name ${RESET_COLOR}on GitHub ... ${RESET}" 101 + gh repo create "$repo_name" --"$repo_visibility" -c &>/dev/null 102 + mv "$repo_name/.git" . && rm -rf "$repo_name" 103 + printf "${BOLD}${GREEN} ${RESET}\n" 104 + elif [ "$create_repo" = "n" ]; then 105 + check_local() { 106 + printf "${BOLD}${RESET_COLOR} Create ${GREEN}local ${RESET_COLOR}repo ${LIGHT_BLUE}$repo_name ${RESET_COLOR}? (y/n) ${RESET}" 107 + read create_local 108 + 109 + if [ "$create_local" = "y" ]; then 110 + git init &>/dev/null 111 + elif [ "$create_local" = "n" ]; then 112 + return 0 113 + else 114 + check_local 115 + fi 116 + } 117 + check_local 118 + else 119 + check_create_repo 120 + fi 121 + } 122 + check_create_repo 123 + fi 124 + fi 125 + } 126 + 127 + # Resolve the full path to the script's directory 128 + REAL_PATH="$(dirname "$(readlink -f "$0")")" 129 + PARENT_DIR="$(dirname "$REAL_PATH")" 130 + CATEGORY="gh.scripts" 131 + 132 + HELPS_DIR="$PARENT_DIR/helps/$CATEGORY" 133 + HELP_FILE="$(basename "$0" .sh)_help.sh" 134 + 135 + UTILS_DIR="$PARENT_DIR/utils" 136 + 137 + # Import necessary variables and functions 138 + source "$UTILS_DIR/check_connection.sh" 139 + source "$UTILS_DIR/check_git.sh" 140 + source "$UTILS_DIR/check_gh.sh" 141 + source "$UTILS_DIR/setup_git.sh" 142 + source "$UTILS_DIR/check_remote.sh" 143 + source "$UTILS_DIR/check_sudo.sh" 144 + source "$UTILS_DIR/check_user.sh" 145 + source "$UTILS_DIR/clean_repo.sh" 146 + source "$UTILS_DIR/colors.sh" 147 + source "$UTILS_DIR/usage.sh" 148 + 149 + # Import help file 150 + source "$HELPS_DIR/$HELP_FILE" 151 + 152 + # Usage function to display help 153 + function usage { 154 + show_help "Usage" "${ghc_arguments[@]}" 155 + show_help "Description" "${ghc_descriptions[@]}" 156 + show_help "Options" "${ghc_options[@]}" 157 + show_extra "${ghc_extras[@]}" 158 + exit 0 159 + } 160 + 161 + # Check if --help is the first argument 162 + [ "$1" = "--help" ] && usage 163 + 164 + # prompt for sudo 165 + # password if required 166 + allow_sudo 167 + 168 + # Setting up git 169 + setup_git 170 + 171 + # Check gh 172 + check_gh 173 + 174 + # Check for internet connectivity to GitHub 175 + check_connection 176 + 177 + # Call ghc function 178 + ghc "$@"
+112
gh.scripts/ghcls.sh
··· 1 + #!/bin/bash 2 + 3 + function ghcls { 4 + # Check for git local repo 5 + if ! is_a_git_repo; then 6 + echo "${BOLD} This won't work, you are not in a git repo !" 7 + return 0 8 + fi 9 + 10 + # Check for remote repo 11 + if ! has_remote; then 12 + echo "${BOLD} This repo has no remote on GitHub !" 13 + return 0 14 + fi 15 + 16 + current_user=$(awk '/user:/ {print $2; exit}' ~/.config/gh/hosts.yml) 17 + repo_url=$(git config --get remote.origin.url) 18 + repo_owner=$(echo "$repo_url" | awk -F '[/:]' '{print $(NF-1)}') 19 + repo_name="$(echo "$repo_url" | awk -F '/' '{print $NF}' | sed 's/.git$//')" 20 + 21 + # check if we are not the owner of the repo 22 + if [ "$repo_owner" != "$current_user" ]; then 23 + echo "${BOLD} Sorry, you are not the owner of this repo !" 24 + return 0 25 + fi 26 + 27 + printf "${BOLD} ${LIGHT_BLUE}Collaborators ${RESET_COLOR}for the ${LIGHT_BLUE}$repo_name ${RESET_COLOR}repository " 28 + 29 + # List collaborators using gh api 30 + collaborators=$(gh api "repos/$current_user/$repo_name/collaborators" --jq '.[].login') 31 + invitations=$(gh api "repos/$current_user/$repo_name/invitations" --jq '.[].invitee.login') 32 + 33 + collaborators_count=$(echo "$collaborators" | wc -l) 34 + invitations_count=$(echo "$invitations" | wc -l) 35 + collaborators_num=$((collaborators_count + invitations_count)) 36 + echo "${RESET_COLOR}${BOLD}($collaborators_count)" 37 + 38 + # Check if we get any collaborators 39 + if [ -z "$collaborators" ]; then 40 + echo "No collaborators found." 41 + return 0 42 + fi 43 + 44 + # Iterate through each collaborator 45 + echo "$collaborators" | while IFS= read -r collaborator; do 46 + if [ "$collaborator" = "$current_user" ]; then 47 + echo " ● $collaborator (owner)" 48 + else 49 + echo " ● $collaborator" 50 + fi 51 + done 52 + 53 + # Check if there are pending invitations 54 + if [ -n "$invitations" ]; then 55 + # Print pending invitations 56 + echo "$invitations" | while IFS= read -r invitee; do 57 + echo " ● $invitee (invitation pending)" 58 + done 59 + fi 60 + } 61 + 62 + # Resolve the full path to the script's directory 63 + REAL_PATH="$(dirname "$(readlink -f "$0")")" 64 + PARENT_DIR="$(dirname "$REAL_PATH")" 65 + CATEGORY="gh.scripts" 66 + 67 + HELPS_DIR="$PARENT_DIR/helps/$CATEGORY" 68 + HELP_FILE="$(basename "$0" .sh)_help.sh" 69 + 70 + UTILS_DIR="$PARENT_DIR/utils" 71 + 72 + # Import necessary variables and functions 73 + source "$UTILS_DIR/check_connection.sh" 74 + source "$UTILS_DIR/check_git.sh" 75 + source "$UTILS_DIR/check_gh.sh" 76 + source "$UTILS_DIR/setup_git.sh" 77 + source "$UTILS_DIR/check_remote.sh" 78 + source "$UTILS_DIR/check_sudo.sh" 79 + source "$UTILS_DIR/check_user.sh" 80 + source "$UTILS_DIR/colors.sh" 81 + source "$UTILS_DIR/usage.sh" 82 + 83 + # Import help file 84 + source "$HELPS_DIR/$HELP_FILE" 85 + 86 + # Usage function to display help 87 + function usage { 88 + show_help "Usage" "${ghcls_arguments[@]}" 89 + show_help "Description" "${ghcls_descriptions[@]}" 90 + show_help "Options" "${ghcls_options[@]}" 91 + show_extra "${ghcls_extras[@]}" 92 + exit 0 93 + } 94 + 95 + # Check if --help is the first argument 96 + [ "$1" = "--help" ] && usage 97 + 98 + # prompt for sudo 99 + # password if required 100 + allow_sudo 101 + 102 + # Setting up git 103 + setup_git 104 + 105 + # Check gh 106 + check_gh 107 + 108 + # Check for internet connectivity to GitHub 109 + check_connection 110 + 111 + # Call ghcls function 112 + ghcls
+153
gh.scripts/ghd.sh
··· 1 + #!/bin/bash 2 + 3 + function ghd { 4 + if [ $# -eq 1 ]; then 5 + if ! connected; then 6 + echo "${BOLD} Sorry, you are offline !${RESET}" 7 + return 0 8 + fi 9 + 10 + if ! gh_installed; then 11 + echo "${BOLD} gh is not installed !${RESET}" 12 + return 0 13 + fi 14 + 15 + repo_name="$1" 16 + current_user=$(awk '/user:/ {print $2; exit}' ~/.config/gh/hosts.yml) 17 + 18 + # Check if the repo doesn't exist 19 + if ! load_and_delete \ 20 + "${BOLD} Checking the ${GREEN}repo${RESET_COLOR} named" \ 21 + "${LIGHT_BLUE}$current_user/$repo_name ${RESET_COLOR}on GitHub" \ 22 + "is_my_github_repo $current_user/$repo_name"; then 23 + 24 + echo "${BOLD} Sorry, there is ${GREEN}no repo ${RESET_COLOR}such as" \ 25 + "${LIGHT_BLUE}$current_user/$repo_name ${RESET_COLOR}on GitHub ${RESET}" 26 + return 0 27 + fi 28 + 29 + isPrivate=$(gh repo view "$repo_name" --json isPrivate --jq '.isPrivate') 30 + repo_visibility=$([ "$isPrivate" = "true" ] && echo "private" || echo "public") 31 + 32 + delete_repo "$repo_name" 33 + else 34 + if ! is_a_git_repo; then 35 + echo "${BOLD} This won't work, you are not in a git repo!${RESET}" 36 + return 0 37 + fi 38 + 39 + if has_remote; then 40 + if connected; then 41 + if ! gh_installed; then 42 + echo "${BOLD} gh is not installed !${RESET}" 43 + return 0 44 + fi 45 + 46 + repo_url=$(git config --get remote.origin.url) 47 + current_user=$(awk '/user:/ {print $2; exit}' ~/.config/gh/hosts.yml) 48 + repo_owner=$(echo "$repo_url" | awk -F '[/:]' '{print $(NF-1)}') 49 + 50 + if [ "$repo_owner" != "$current_user" ]; then 51 + echo "${BOLD} Sorry, you are not the owner of this repo!${RESET}" 52 + else 53 + repo_name=$(echo "$repo_url" | awk -F '/' '{print $NF}' | sed 's/.git$//') 54 + isPrivate=$(gh repo view "$repo_name" --json isPrivate --jq '.isPrivate') 55 + repo_visibility=$([ "$isPrivate" = "true" ] && echo "private" || echo "public") 56 + 57 + delete_repo "$repo_name" 58 + git remote remove origin 59 + echo 60 + delete_local_repo "$repo_name" 61 + fi 62 + else 63 + repo_name=$(basename "$(git rev-parse --show-toplevel)") 64 + delete_local_repo "$repo_name" 65 + fi 66 + else 67 + repo_name=$(basename "$(git rev-parse --show-toplevel)") 68 + delete_local_repo "$repo_name" 69 + fi 70 + fi 71 + } 72 + 73 + # Resolve the full path to the script's directory 74 + REAL_PATH="$(dirname "$(readlink -f "$0")")" 75 + PARENT_DIR="$(dirname "$REAL_PATH")" 76 + CATEGORY="gh.scripts" 77 + 78 + HELPS_DIR="$PARENT_DIR/helps/$CATEGORY" 79 + HELP_FILE="$(basename "$0" .sh)_help.sh" 80 + 81 + UTILS_DIR="$PARENT_DIR/utils" 82 + 83 + # Import necessary variables and functions 84 + source "$UTILS_DIR/check_connection.sh" 85 + source "$UTILS_DIR/check_git.sh" 86 + source "$UTILS_DIR/check_gh.sh" 87 + source "$UTILS_DIR/check_repo.sh" 88 + source "$UTILS_DIR/setup_git.sh" 89 + source "$UTILS_DIR/check_remote.sh" 90 + source "$UTILS_DIR/check_sudo.sh" 91 + source "$UTILS_DIR/check_user.sh" 92 + source "$UTILS_DIR/clean_repo.sh" 93 + source "$UTILS_DIR/colors.sh" 94 + source "$UTILS_DIR/loading.sh" 95 + source "$UTILS_DIR/usage.sh" 96 + 97 + # Import help file 98 + source "$HELPS_DIR/$HELP_FILE" 99 + 100 + # Usage function to display help 101 + function usage { 102 + show_help "Usage" "${ghd_arguments[@]}" 103 + show_help "Description" "${ghd_descriptions[@]}" 104 + show_help "Options" "${ghd_options[@]}" 105 + exit 0 106 + } 107 + 108 + # Check if --help is the first argument 109 + [ "$1" = "--help" ] && usage 110 + 111 + # prompt for sudo 112 + # password if required 113 + allow_sudo 114 + 115 + # Setting up git 116 + setup_git 117 + 118 + # Function to delete local repo 119 + function delete_local_repo { 120 + printf "${BOLD}${RESET} Delete ${GREEN}local ${RESET_COLOR}repo ${LIGHT_BLUE}$1 ${RESET}? (y/n) ${RESET}" 121 + read delete_local_repo 122 + 123 + if [ "$delete_local_repo" = "y" ]; then 124 + local repo_source=$(git rev-parse --show-toplevel) 125 + 126 + execute_with_loading \ 127 + "${BOLD} Deleting ${GREEN}local ${RESET_COLOR}repo ${LIGHT_BLUE}$1 ${RESET}" \ 128 + "rm -rf "$repo_source/.git"" 129 + elif [ "$delete_local_repo" = "n" ]; then 130 + return 0 131 + else 132 + delete_local_repo "$1" 133 + fi 134 + } 135 + 136 + # Function to delete GitHub repo 137 + function delete_repo { 138 + printf "${BOLD} Delete ${GREEN}$repo_visibility ${RESET_COLOR}repo ${LIGHT_BLUE}$1 ${RESET_COLOR}? (y/n) ${RESET}" 139 + read delete_repo 140 + 141 + if [ "$delete_repo" = "y" ]; then 142 + execute_with_loading \ 143 + "${BOLD} Deleting repository ${LIGHT_BLUE}$1 ${RESET_COLOR}on GitHub" \ 144 + "gh repo delete "$1" --yes" 145 + elif [ "$delete_repo" = "n" ]; then 146 + return 0 147 + else 148 + delete_repo "$1" 149 + fi 150 + } 151 + 152 + # Call ghd function 153 + ghd "$@"
+107
gh.scripts/ghdel.sh
··· 1 + #!/bin/bash 2 + 3 + function ghdel { 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 + if ! has_remote; then 10 + echo "${BOLD} This repo has no remote on Github !" 11 + return 0 12 + fi 13 + 14 + if [ $# -eq 0 ]; then 15 + echo "${BOLD} Specify the username of the collaborator to remove !" 16 + return 0 17 + fi 18 + 19 + current_user=$(awk '/user:/ {print $2; exit}' ~/.config/gh/hosts.yml) 20 + repo_url=$(git config --get remote.origin.url) 21 + repo_owner=$(echo "$repo_url" | awk -F '[/:]' '{print $(NF-1)}') 22 + repo_name="$(echo "$repo_url" | awk -F '/' '{print $NF}' | sed 's/.git$//')" 23 + 24 + # check if we are not the owner of the repo 25 + if [ "$repo_owner" != "$current_user" ]; then 26 + echo "${BOLD} Sorry, you are not the owner of this repo !" 27 + return 0 28 + fi 29 + 30 + # Retrieve the list of collaborators 31 + collaborators=$(gh api "repos/$current_user/$repo_name/collaborators" --jq '.[].login') 32 + invitations=$(gh api "repos/$current_user/$repo_name/invitations" --jq '.[].invitee.login') 33 + 34 + # Loop through each collaborator username provided as an argument 35 + for collaborator in "$@"; do 36 + # Check if the collaborator exists in the list of collaborators 37 + if echo "$collaborators" | grep -q "$collaborator" || 38 + echo "$invitations" | grep -q "$collaborator"; then 39 + printf "${BOLD} Removing ${LIGHT_BLUE}$collaborator ${RESET_COLOR}from ${LIGHT_BLUE}$repo_name${RESET_COLOR} " 40 + # Check for pending invitations 41 + invitation_id=$(gh api "repos/$current_user/$repo_name/invitations" --jq ".[] | select(.invitee.login==\"$collaborator\") | .id") 42 + 43 + if [ -n "$invitation_id" ]; then 44 + # Delete the pending invitation 45 + gh api --method=DELETE "repos/$current_user/$repo_name/invitations/$invitation_id" >/dev/null 2>&1 46 + printf " ${BOLD}(invitation deleted) " 47 + fi 48 + 49 + # Remove collaborator using gh api 50 + gh api --method=DELETE "repos/$current_user/$repo_name/collaborators/$collaborator" >/dev/null 2>&1 51 + echo "${BOLD}${GREEN} ${RESET_COLOR}" 52 + else 53 + echo "${BOLD}${LIGHT_BLUE}$collaborator ${RESET_COLOR}is not a ${LIGHT_BLUE}collaborator ${RED}✘ ${RESET_COLOR}" 54 + fi 55 + done 56 + } 57 + 58 + # Resolve the full path to the script's directory 59 + REAL_PATH="$(dirname "$(readlink -f "$0")")" 60 + PARENT_DIR="$(dirname "$REAL_PATH")" 61 + CATEGORY="gh.scripts" 62 + 63 + HELPS_DIR="$PARENT_DIR/helps/$CATEGORY" 64 + HELP_FILE="$(basename "$0" .sh)_help.sh" 65 + 66 + UTILS_DIR="$PARENT_DIR/utils" 67 + 68 + # Import necessary variables and functions 69 + source "$UTILS_DIR/check_connection.sh" 70 + source "$UTILS_DIR/check_git.sh" 71 + source "$UTILS_DIR/check_gh.sh" 72 + source "$UTILS_DIR/setup_git.sh" 73 + source "$UTILS_DIR/check_remote.sh" 74 + source "$UTILS_DIR/check_sudo.sh" 75 + source "$UTILS_DIR/colors.sh" 76 + source "$UTILS_DIR/usage.sh" 77 + 78 + # Import help file 79 + source "$HELPS_DIR/$HELP_FILE" 80 + 81 + # Usage function to display help 82 + function usage { 83 + show_help "Usage" "${ghdel_arguments[@]}" 84 + show_help "Description" "${ghdel_descriptions[@]}" 85 + show_help "Options" "${ghdel_options[@]}" 86 + show_extra "${ghdel_extras[@]}" 87 + exit 0 88 + } 89 + 90 + # Check if --help is the first argument 91 + [ "$1" = "--help" ] && usage 92 + 93 + # prompt for sudo 94 + # password if required 95 + allow_sudo 96 + 97 + # Setting up git 98 + setup_git 99 + 100 + # Check gh 101 + check_gh 102 + 103 + # Check for internet connectivity to GitHub 104 + check_connection 105 + 106 + # Call ghdel function 107 + ghdel "$@"
+119
gh.scripts/ghf.sh
··· 1 + #!/bin/bash 2 + 3 + function ghf { 4 + repo="$1" 5 + IFS="/" read -r repo_owner repo_name <<< "$repo" 6 + current_user=$(awk '/user:/ {print $2; exit}' ~/.config/gh/hosts.yml) 7 + clone_repo="--clone" 8 + 9 + # regex to match clone repo case 10 + clone_regex='^[a-zA-Z0-9_-]+/[a-zA-Z0-9_-]+$' 11 + 12 + # Check if repo has not the format owner/repo 13 + if [[ ! "$repo" =~ $clone_regex ]]; then 14 + usage 15 + fi 16 + 17 + # Check if we have already forked it 18 + if load_and_delete \ 19 + "${BOLD} Checking the forked ${GREEN}repo ${RESET_COLOR} named" \ 20 + "${LIGHT_BLUE}$current_user/$repo_name ${RESET_COLOR}on GitHub" \ 21 + "is_a_github_repo $current_user/$repo_name"; then 22 + echo "${BOLD} You have already ${RED}forked ${RESET_COLOR}the repo named" \ 23 + "${GREEN}$repo_name ${RESET_COLOR}on ${LIGHT_BLUE}GitHub ${RESET}" 24 + return 0 25 + fi 26 + 27 + # Check if the owner exists on GitHub 28 + if ! load_and_delete \ 29 + "${BOLD} Checking the ${GREEN}user ${RESET_COLOR}named" \ 30 + "${LIGHT_BLUE}$repo_owner ${RESET_COLOR}on GitHub" \ 31 + "is_a_github_user $repo_owner"; then 32 + echo "${BOLD} Sorry, there is ${GREEN}no user ${RESET_COLOR}named" \ 33 + "${LIGHT_BLUE}$repo_owner ${RESET_COLOR}on GitHub ${RESET}" 34 + return 0 35 + fi 36 + 37 + # Check if the repo doesn't exist 38 + if ! load_and_delete \ 39 + "${BOLD} Checking the ${GREEN}repo ${RESET_COLOR}named" \ 40 + "${LIGHT_BLUE}$repo_owner/$repo_name ${RESET_COLOR}on GitHub" \ 41 + "is_a_github_repo $repo_owner/$repo_name"; then 42 + echo "${BOLD} Sorry, there is ${GREEN}no repo ${RESET_COLOR}such" \ 43 + "${LIGHT_BLUE}$repo_owner/$repo_name ${RESET_COLOR}on GitHub ${RESET}" 44 + return 0 45 + fi 46 + 47 + if load_and_delete \ 48 + "${BOLD} Checking the ${GREEN}local ${RESET_COLOR}git" \ 49 + "${LIGHT_BLUE}repo ${RESET_COLOR}" \ 50 + "is_a_git_repo"; then 51 + printf "${BOLD}${GREEN} Local Git${RESET_COLOR} repo detected," \ 52 + "skipping fork clone for ${LIGHT_BLUE}$repo_name ${RESET}\n" 53 + clone_repo="" 54 + fi 55 + 56 + if execute_with_loading \ 57 + "${BOLD} Forking ${LIGHT_BLUE}$repo_name ${RESET_COLOR}on GitHub" \ 58 + "gh repo fork $repo_owner/$repo_name"; then 59 + 60 + if [ "$clone_repo" == "--clone" ]; then 61 + execute_with_loading \ 62 + "${BOLD} Cloning fork ${LIGHT_BLUE}$repo_name ${RESET_COLOR}locally" \ 63 + "gh repo clone $current_user/$repo_name" 64 + fi 65 + fi 66 + } 67 + 68 + # Resolve the full path to the script's directory 69 + REAL_PATH="$(dirname "$(readlink -f "$0")")" 70 + PARENT_DIR="$(dirname "$REAL_PATH")" 71 + CATEGORY="gh.scripts" 72 + 73 + HELPS_DIR="$PARENT_DIR/helps/$CATEGORY" 74 + HELP_FILE="$(basename "$0" .sh)_help.sh" 75 + 76 + UTILS_DIR="$PARENT_DIR/utils" 77 + 78 + # Import necessary variables and functions 79 + source "$UTILS_DIR/check_connection.sh" 80 + source "$UTILS_DIR/check_git.sh" 81 + source "$UTILS_DIR/check_gh.sh" 82 + source "$UTILS_DIR/check_repo.sh" 83 + source "$UTILS_DIR/setup_git.sh" 84 + source "$UTILS_DIR/check_sudo.sh" 85 + source "$UTILS_DIR/check_user.sh" 86 + source "$UTILS_DIR/colors.sh" 87 + source "$UTILS_DIR/loading.sh" 88 + source "$UTILS_DIR/usage.sh" 89 + 90 + # Import help file 91 + source "$HELPS_DIR/$HELP_FILE" 92 + 93 + # Usage function to display help 94 + function usage { 95 + show_help "Usage" "${ghf_arguments[@]}" 96 + show_help "Description" "${ghf_descriptions[@]}" 97 + show_help "Options" "${ghf_options[@]}" 98 + show_help "Example" "${ghf_extras[@]}" 99 + exit 0 100 + } 101 + 102 + # Check if --help is the first argument 103 + [ "$1" = "--help" ] && usage 104 + 105 + # prompt for sudo 106 + # password if required 107 + allow_sudo 108 + 109 + # Setting up git 110 + setup_git 111 + 112 + # Check gh 113 + check_gh 114 + 115 + # Check for internet connectivity to GitHub 116 + check_connection 117 + 118 + # Call the function with all arguments 119 + ghf "$@"
+91
gh.scripts/ghnm.sh
··· 1 + #!/bin/bash 2 + 3 + function ghnm { 4 + # Check if we are inside a git repo 5 + if ! load_and_delete \ 6 + "${BOLD} Checking the ${GREEN}local ${RESET_COLOR}git" \ 7 + "${LIGHT_BLUE}repo ${RESET_COLOR}" \ 8 + "is_a_git_repo"; then 9 + echo "${BOLD} This won't work, you are not in a git repo !" 10 + return 0 11 + fi 12 + 13 + # Check if the repo has a remote 14 + if ! load_and_delete \ 15 + "${BOLD} Checking the ${GREEN}remote ${RESET_COLOR}git" \ 16 + "${LIGHT_BLUE}repo ${RESET_COLOR}on GitHub" \ 17 + "has_remote"; then 18 + echo "${BOLD} This repo has no remote on GitHub !" 19 + return 0 20 + fi 21 + 22 + # Define the new name of the repo 23 + new_name="$1" 24 + repo_url=$(git config --get remote.origin.url) 25 + repo_name=$(echo "$repo_url" | awk -F '/' '{print $NF}' | sed 's/.git$//') 26 + 27 + if [ "$new_name" == "$repo_name" ]; then 28 + echo "${BOLD} The ${GREEN}remote ${RESET_COLOR}repo name is" \ 29 + "${LIGHT_BLUE}$repo_name ${RESET}" 30 + return 0 31 + fi 32 + 33 + execute_with_loading \ 34 + "${BOLD} Renaming ${GREEN}remote ${RESET_COLOR}repo" \ 35 + "${LIGHT_BLUE}$repo_name ${RESET_COLOR}to ${LIGHT_BLUE}$new_name ${RESET_COLOR}" \ 36 + "gh repo rename "$new_name" --yes" 37 + } 38 + 39 + # Resolve the full path to the script's directory 40 + REAL_PATH="$(dirname "$(readlink -f "$0")")" 41 + PARENT_DIR="$(dirname "$REAL_PATH")" 42 + CATEGORY="gh.scripts" 43 + 44 + HELPS_DIR="$PARENT_DIR/helps/$CATEGORY" 45 + HELP_FILE="$(basename "$0" .sh)_help.sh" 46 + 47 + UTILS_DIR="$PARENT_DIR/utils" 48 + 49 + # Import necessary variables and functions 50 + source "$UTILS_DIR/check_connection.sh" 51 + source "$UTILS_DIR/check_git.sh" 52 + source "$UTILS_DIR/check_gh.sh" 53 + source "$UTILS_DIR/setup_git.sh" 54 + source "$UTILS_DIR/check_remote.sh" 55 + source "$UTILS_DIR/check_sudo.sh" 56 + source "$UTILS_DIR/check_user.sh" 57 + source "$UTILS_DIR/clean_repo.sh" 58 + source "$UTILS_DIR/colors.sh" 59 + source "$UTILS_DIR/loading.sh" 60 + source "$UTILS_DIR/usage.sh" 61 + 62 + # Import help file 63 + source "$HELPS_DIR/$HELP_FILE" 64 + 65 + # Usage function to display help 66 + function usage { 67 + show_help "Usage" "${ghnm_arguments[@]}" 68 + show_help "Description" "${ghnm_descriptions[@]}" 69 + show_help "Options" "${ghnm_options[@]}" 70 + show_help "Example" "${ghnm_extras[@]}" 71 + exit 0 72 + } 73 + 74 + # Check if --help is the first argument 75 + [ "$1" = "--help" ] && usage 76 + 77 + # prompt for sudo 78 + # password if required 79 + allow_sudo 80 + 81 + # Setting up git 82 + setup_git 83 + 84 + # Check gh 85 + check_gh 86 + 87 + # Check for internet connectivity to GitHub 88 + check_connection 89 + 90 + # Call ghc function 91 + ghnm "$@"
+128
gh.scripts/ghv.sh
··· 1 + #!/bin/bash 2 + 3 + function ghv { 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 + if [[ ! connected && "$1" = "owner" ]]; then 10 + if has_remote; then 11 + repo_url=$(git config --get remote.origin.url) 12 + repo_owner=$(echo "$repo_url" | awk -F '[/:]' '{print $(NF-1)}') 13 + repo_name="$(echo "$repo_url" | awk -F '/' '{print $NF}' | sed 's/.git$//')" 14 + else 15 + repo_owner=$(git config user.name) 16 + repo_name=$(basename "$(git rev-parse --show-toplevel)") 17 + fi 18 + 19 + if has_remote; then 20 + echo "${BOLD} The repo ${LIGHT_BLUE}$repo_name ${RESET_COLOR}is owned by ${GREEN}$repo_owner" 21 + else 22 + echo "${BOLD} The local repo ${LIGHT_BLUE}$repo_name ${RESET_COLOR}is owned by ${GREEN}$repo_owner" 23 + fi 24 + 25 + return 0 26 + fi 27 + 28 + if [ "$#" -eq 0 ] || [ "$1" = "show" ] || [ "$1" = "owner" ]; then 29 + current_user=$(awk '/user:/ {print $2; exit}' ~/.config/gh/hosts.yml) 30 + 31 + if has_remote; then 32 + repo_url=$(git config --get remote.origin.url) 33 + repo_owner=$(echo "$repo_url" | awk -F '[/:]' '{print $(NF-1)}') 34 + repo_name="$(echo "$repo_url" | awk -F '/' '{print $NF}' | sed 's/.git$//')" 35 + else 36 + repo_owner=$(git config user.name) 37 + repo_name=$(basename "$(git rev-parse --show-toplevel)") 38 + fi 39 + 40 + if [ "$repo_owner" != "$current_user" ] && [ "$1" != "owner" ]; then 41 + echo "${BOLD} Sorry, you are not the owner of this repo !" 42 + elif [ "$1" = "owner" ]; then 43 + if has_remote; then 44 + echo "${BOLD} The repo ${LIGHT_BLUE}$repo_name ${RESET_COLOR}is owned by ${GREEN}$repo_owner" 45 + else 46 + echo "${BOLD} The local repo ${LIGHT_BLUE}$repo_name ${RESET_COLOR}is owned by ${GREEN}$repo_owner" 47 + fi 48 + else 49 + if has_remote; then 50 + isPrivate=$(gh repo view "$repo_owner/$repo_name" --json isPrivate --jq '.isPrivate') 51 + 52 + if [ "$1" = "show" ]; then 53 + visibility=$([ "$isPrivate" = "true" ] && echo "private" || echo "public") 54 + echo "${BOLD} This repo ${LIGHT_BLUE}$repo_name ${RESET_COLOR}is ${GREEN}$visibility" 55 + else 56 + new_visibility=$([ "$isPrivate" = "true" ] && echo "public" || echo "private") 57 + toggle_visibility() { 58 + printf "${BOLD}${RESET_COLOR} Make ${LIGHT_BLUE}$repo_name ${RESET_COLOR}repo ${GREEN}$new_visibility ${RESET_COLOR}? (y/n) " 59 + read -r change_visibility 60 + if [ "$change_visibility" = "y" ]; then 61 + # toggle visibility 62 + printf "${BOLD} Changing repo visibility to ${GREEN}$new_visibility ${RESET_COLOR}... " 63 + gh repo edit "$repo_owner/$repo_name" --visibility "$new_visibility" &>/dev/null 64 + echo "${BOLD}${GREEN} ${RESET_COLOR}" 65 + elif [ "$change_visibility" = "n" ]; then 66 + return 0 67 + else 68 + toggle_visibility 69 + fi 70 + } 71 + toggle_visibility 72 + fi 73 + else 74 + echo "${BOLD} The local repo ${LIGHT_BLUE}$repo_name ${RESET_COLOR}is owned by ${GREEN}$repo_owner" 75 + fi 76 + fi 77 + else 78 + echo "${BOLD} Sorry, wrong command argument !" 79 + fi 80 + } 81 + 82 + # Resolve the full path to the script's directory 83 + REAL_PATH="$(dirname "$(readlink -f "$0")")" 84 + PARENT_DIR="$(dirname "$REAL_PATH")" 85 + CATEGORY="gh.scripts" 86 + 87 + HELPS_DIR="$PARENT_DIR/helps/$CATEGORY" 88 + HELP_FILE="$(basename "$0" .sh)_help.sh" 89 + 90 + UTILS_DIR="$PARENT_DIR/utils" 91 + 92 + # Import necessary variables and functions 93 + source "$UTILS_DIR/check_connection.sh" 94 + source "$UTILS_DIR/check_git.sh" 95 + source "$UTILS_DIR/check_gh.sh" 96 + source "$UTILS_DIR/setup_git.sh" 97 + source "$UTILS_DIR/check_remote.sh" 98 + source "$UTILS_DIR/check_sudo.sh" 99 + source "$UTILS_DIR/colors.sh" 100 + source "$UTILS_DIR/usage.sh" 101 + 102 + # Import help file 103 + source "$HELPS_DIR/$HELP_FILE" 104 + 105 + # Usage function to display help 106 + function usage { 107 + show_help "Usage" "${ghv_arguments[@]}" 108 + show_help "Description" "${ghv_descriptions[@]}" 109 + show_help "Options" "${ghv_options[@]}" 110 + show_extra "${ghv_extras[@]}" 111 + exit 0 112 + } 113 + 114 + # Check if --help is the first argument 115 + [ "$1" = "--help" ] && usage 116 + 117 + # prompt for sudo 118 + # password if required 119 + allow_sudo 120 + 121 + # Setting up git 122 + setup_git 123 + 124 + # Check gh 125 + check_gh 126 + 127 + # Call ghv function 128 + ghv "$@"
-196
gh_scripts/gbd.sh
··· 1 - #!/bin/bash 2 - 3 - function gbd { 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 - current_branch=$(git branch | awk '/\*/ {print $2}') 10 - default_branch=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@') 11 - current_user=$(awk '/user:/ {print $2; exit}' ~/.config/gh/hosts.yml) 12 - 13 - if [ -z "$default_branch" ]; then 14 - default_branch=$(git config --get init.defaultBranch) 15 - fi 16 - 17 - if [ $# -eq 1 ]; then 18 - if [ "$1" = "$default_branch" ]; then 19 - echo "${BOLD} Fatal ! Cannot Delete the Default Branch " 20 - return 0 21 - fi 22 - 23 - if ! git show-ref --verify --quiet "refs/heads/$1" &>/dev/null; then 24 - echo "${BOLD} Fatal ! Branch ${GREEN}$1 ${RESET_COLOR}doesn't exist ${RESET}" 25 - return 0 26 - fi 27 - 28 - # this to check if we want to delete the remote branch too 29 - check_delete_remote_branch() { 30 - if [ "$current_branch" = "$default_branch" ]; then 31 - echo "${BOLD} Fatal ! Cannot Delete the Default Branch " 32 - return 0 33 - fi 34 - 35 - printf "${BOLD}${RESET_COLOR}Delete remote branch${GREEN} "$current_branch"${RESET_COLOR} ? (y/n) ${RESET}" 36 - read delete_remote_branch 37 - echo ${RESET} 38 - 39 - if [ "$delete_remote_branch" = "y" ]; then 40 - git push origin --delete "$current_branch" 41 - elif [ "$delete_remote_branch" = "n" ]; then 42 - return 0 43 - else 44 - check_delete_remote_branch 45 - fi 46 - } 47 - 48 - check_delete_branch() { 49 - branch_name="$1" 50 - 51 - printf "${BOLD}${RESET_COLOR}Delete branch${GREEN} "$branch_name"${RESET_COLOR} ? (y/n) ${RESET}" 52 - read delete_branch 53 - 54 - if [ "$delete_branch" = "y" ]; then 55 - if [ "$current_branch" != "$default_branch" ]; then 56 - git checkout $default_branch >/dev/null 2>&1 57 - fi 58 - 59 - if has_remote; then 60 - repo_url=$(git config --get remote.origin.url) 61 - repo_owner=$(echo "$repo_url" | awk -F '[/:]' '{print $(NF-1)}') 62 - 63 - # check if we are not the owner of the repo 64 - if [ "$repo_owner" == "$current_user" ]; then 65 - is_remote_branch=$(git branch -r | grep "origin/$1") 66 - if [ -n "$is_remote_branch" ]; then 67 - # prompt for sudo 68 - # password if required 69 - allow_sudo 70 - 71 - # Check for internet connectivity to GitHub 72 - if $SUDO ping -c 1 github.com &>/dev/null; then 73 - check_delete_remote_branch 74 - fi 75 - fi 76 - fi 77 - fi 78 - 79 - git branch -D "$1" 80 - elif [ "$delete_branch" = "n" ]; then 81 - return 0 82 - else 83 - check_delete_branch $branch_name 84 - fi 85 - } 86 - 87 - check_delete_branch $1 88 - elif [ $# -eq 0 ]; then 89 - if [ "$current_branch" = "$default_branch" ]; then 90 - echo "${BOLD}${RESET_COLOR} Fatal ! Cannot Delete the Default Branch " 91 - return 0 92 - fi 93 - 94 - check_delete_branch() { 95 - printf "${BOLD}${RESET_COLOR}Delete branch${GREEN} "$current_branch"${RESET_COLOR} ? (y/n) ${RESET}" 96 - read delete_branch 97 - if [ "$delete_branch" = "y" ]; then 98 - # TODO : Remote branch Deletion 99 - check_delete_remote_branch() { 100 - if [ "$current_branch" = "$default_branch" ]; then 101 - echo "${BOLD}${RESET_COLOR} Fatal ! Cannot Delete the Default Branch " 102 - else 103 - printf "${BOLD}${RESET_COLOR}Delete remote branch${GREEN} "$current_branch"${RESET_COLOR} ? (y/n) ${RESET}" 104 - read delete_remote_branch 105 - echo ${RESET} 106 - if [ "$delete_remote_branch" = "y" ]; then 107 - git push origin --delete "$current_branch" 108 - elif [ "$delete_remote_branch" = "n" ]; then 109 - return 0 110 - else 111 - check_delete_remote_branch 112 - fi 113 - fi 114 - } 115 - 116 - git checkout "$default_branch" >/dev/null 2>&1 117 - 118 - if has_remote; then 119 - repo_url=$(git config --get remote.origin.url) 120 - repo_owner=$(echo "$repo_url" | awk -F '[/:]' '{print $(NF-1)}') 121 - 122 - # check if we are not the owner of the repo 123 - if [ "$repo_owner" == "$current_user" ]; then 124 - is_remote_branch=$(git branch -r | grep "origin/$current_branch") 125 - 126 - if [ -n "$is_remote_branch" ]; then 127 - # prompt for sudo 128 - # password if required 129 - allow_sudo 130 - 131 - # Check for internet connectivity to GitHub 132 - if $SUDO ping -c 1 github.com &>/dev/null; then 133 - check_delete_remote_branch 134 - fi 135 - fi 136 - fi 137 - fi 138 - git branch -D "$current_branch" 139 - elif [ "$delete_branch" = "n" ]; then 140 - return 0 141 - else 142 - check_delete_branch 143 - fi 144 - } 145 - check_delete_branch 146 - else 147 - echo "${BOLD}${RESET_COLOR} Usage : gbd branch_to_delete" 148 - fi 149 - } 150 - 151 - # Resolve the full path to the script's directory 152 - REAL_PATH="$(dirname "$(readlink -f "$0")")" 153 - PARENT_DIR="$(dirname "$REAL_PATH")" 154 - CATEGORY="gh_scripts" 155 - 156 - HELPS_DIR="$PARENT_DIR/helps/$CATEGORY" 157 - HELP_FILE="$(basename "$0" .sh)_help.sh" 158 - 159 - UTILS_DIR="$PARENT_DIR/utils" 160 - 161 - # Import necessary variables and functions 162 - source "$UTILS_DIR/check_connection.sh" 163 - source "$UTILS_DIR/check_remote.sh" 164 - source "$UTILS_DIR/check_git.sh" 165 - source "$UTILS_DIR/setup_git.sh" 166 - source "$UTILS_DIR/check_sudo.sh" 167 - source "$UTILS_DIR/colors.sh" 168 - source "$UTILS_DIR/usage.sh" 169 - 170 - # Import help file 171 - source "$HELPS_DIR/$HELP_FILE" 172 - 173 - # Usage function to display help 174 - function usage { 175 - show_help "Usage" "${gbd_arguments[@]}" 176 - show_help "Description" "${gbd_descriptions[@]}" 177 - show_help "Options" "${gbd_options[@]}" 178 - show_extra "${gbd_extras[@]}" 179 - exit 0 180 - } 181 - 182 - # Check if --help is the first argument 183 - [ "$1" = "--help" ] && usage 184 - 185 - # prompt for sudo 186 - # password if required 187 - allow_sudo 188 - 189 - # Setting up git 190 - setup_git 191 - 192 - # Check for internet connectivity to GitHub 193 - check_connection 194 - 195 - # Call gbd function 196 - gbd "$@"
-177
gh_scripts/gck.sh
··· 1 - #!/bin/bash 2 - 3 - # WARNING : 03-30-2025 02:18 4 - # Specify the base branch 5 - # when trying to create feature 6 - # branches with the following commands 7 - # git switch -c new-branch old-branch 8 - # git push -u origin new-branch 9 - 10 - function gck { 11 - if ! is_a_git_repo; then 12 - echo "${BOLD} This won't work, you are not in a git repo !" 13 - return 0 14 - fi 15 - 16 - current_branch=$(git branch | awk '/\*/ {print $2}') 17 - 18 - if has_remote; then 19 - default_branch=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@') 20 - repo_url=$(git config --get remote.origin.url) 21 - repo_name="$(echo "$repo_url" | awk -F '/' '{print $NF}' | sed 's/.git$//')" 22 - repo_owner=$(echo "$repo_url" | awk -F '[/:]' '{print $(NF-1)}') 23 - current_user=$(awk '/user:/ {print $2; exit}' ~/.config/gh/hosts.yml) 24 - else 25 - default_branch=$(git config --get init.defaultBranch) 26 - repo_name=$(basename "$(git rev-parse --show-toplevel)") 27 - fi 28 - 29 - if [ -z "$default_branch" ]; then 30 - default_branch=$(git config --get init.defaultBranch) 31 - fi 32 - 33 - if [ $# -eq 0 ]; then 34 - if [ "$current_branch" != "$default_branch" ]; then 35 - git checkout "$default_branch" 36 - else 37 - user="$(whoami)" 38 - if ! is_a_git_branch "$user"; then 39 - check_new_branch() { 40 - printf "${BOLD}${RESET_COLOR}New branch${GREEN} "$user"${RESET_COLOR} ? (y/n) " 41 - read branch 42 - if [ "$branch" = "y" ]; then 43 - git checkout -b "$user" >/dev/null 2>&1 44 - 45 - # check for remote 46 - if has_remote && gh_installed; then 47 - check_new_remote_branch() { 48 - printf "${BOLD}${RESET_COLOR}Add${GREEN} "$user"${RESET_COLOR} branch to ${LIGHT_BLUE}$repo_name ${RESET_COLOR}on GitHub ? (y/n) " 49 - read remote_branch 50 - if [ "$remote_branch" = "y" ]; then 51 - git push origin "$user" 52 - elif [ "$remote_branch" = "n" ]; then 53 - return 0 54 - else 55 - check_new_remote_branch 56 - fi 57 - } 58 - 59 - # check if we are not the owner of the repo 60 - if [ "$repo_owner" == "$current_user" ]; then 61 - # Check for internet connectivity to GitHub 62 - if $SUDO ping -c 1 github.com &>/dev/null; then 63 - check_new_remote_branch 64 - else 65 - echo "${BOLD} Cannot push to remote branch, you are offline !${RESET}" 66 - fi 67 - fi 68 - fi 69 - elif [ "$branch" = "n" ]; then 70 - return 0 71 - else 72 - check_new_branch 73 - fi 74 - } 75 - check_new_branch 76 - else 77 - git checkout "$user" 78 - fi 79 - fi 80 - elif [ $# -eq 1 ]; then 81 - # check if the branch doesn't exist yet 82 - if ! is_a_git_branch "$1" >/dev/null 2>&1; then 83 - new_branch="$1" 84 - check_new_branch() { 85 - printf "${BOLD}${RESET_COLOR}New branch${GREEN} "$new_branch"${RESET_COLOR} ? (y/n) " 86 - read branch 87 - if [ "$branch" = "y" ]; then 88 - git checkout -b "$new_branch" >/dev/null 2>&1 89 - 90 - # check for remote 91 - if has_remote; then 92 - check_new_remote_branch() { 93 - printf "${BOLD}${RESET_COLOR}Add${GREEN} "$new_branch"${RESET_COLOR} branch to ${LIGHT_BLUE}$repo_name ${RESET_COLOR} on GitHub ? (y/n) " 94 - read remote_branch 95 - echo ${RESET} 96 - if [ "$remote_branch" = "y" ]; then 97 - git push origin "$new_branch" 98 - elif [ "$remote_branch" = "n" ]; then 99 - return 0 100 - else 101 - check_new_remote_branch 102 - fi 103 - } 104 - 105 - # check if we are not the owner of the repo 106 - if [ "$repo_owner" == "$current_user" ]; then 107 - # Check for internet connectivity to GitHub 108 - if $SUDO ping -c 1 github.com &>/dev/null; then 109 - check_new_remote_branch 110 - else 111 - echo "${BOLD} Cannot push to remote branch, you are offline !${RESET}" 112 - fi 113 - fi 114 - fi 115 - elif [ "$branch" = "n" ]; then 116 - return 0 117 - else 118 - check_new_branch 119 - fi 120 - } 121 - check_new_branch 122 - else 123 - git checkout "$1" 124 - fi 125 - else 126 - echo "${BOLD} Usage : gck branch or gck (switch default branch)" 127 - fi 128 - } 129 - 130 - # Resolve the full path to the script's directory 131 - REAL_PATH="$(dirname "$(readlink -f "$0")")" 132 - PARENT_DIR="$(dirname "$REAL_PATH")" 133 - CATEGORY="gh_scripts" 134 - 135 - HELPS_DIR="$PARENT_DIR/helps/$CATEGORY" 136 - HELP_FILE="$(basename "$0" .sh)_help.sh" 137 - 138 - UTILS_DIR="$PARENT_DIR/utils" 139 - 140 - # Import necessary variables and functions 141 - source "$UTILS_DIR/check_connection.sh" 142 - source "$UTILS_DIR/check_remote.sh" 143 - source "$UTILS_DIR/check_git.sh" 144 - source "$UTILS_DIR/check_gh.sh" 145 - source "$UTILS_DIR/setup_git.sh" 146 - source "$UTILS_DIR/check_branch.sh" 147 - source "$UTILS_DIR/check_sudo.sh" 148 - source "$UTILS_DIR/colors.sh" 149 - source "$UTILS_DIR/usage.sh" 150 - 151 - # Import help file 152 - source "$HELPS_DIR/$HELP_FILE" 153 - 154 - # Usage function to display help 155 - function usage { 156 - show_help "Usage" "${gck_arguments[@]}" 157 - show_help "Description" "${gck_descriptions[@]}" 158 - show_help "Options" "${gck_options[@]}" 159 - show_extra "${gck_extras[@]}" 160 - exit 0 161 - } 162 - 163 - # Check if --help is the first argument 164 - [ "$1" = "--help" ] && usage 165 - 166 - # prompt for sudo 167 - # password if required 168 - allow_sudo 169 - 170 - # Setting up git 171 - setup_git 172 - 173 - # Check for internet connectivity to GitHub 174 - check_connection 175 - 176 - # Call gck function 177 - gck "$@"
-105
gh_scripts/gcln.sh
··· 1 - #!/bin/bash 2 - 3 - function clone_repo { 4 - # Default GitHub URL prefix 5 - GITHUB_URL="https://github.com" 6 - 7 - local depth="" 8 - 9 - while [[ $# -gt 0 ]]; do 10 - case "$1" in 11 - --depth | -d) 12 - depth="$2" 13 - shift 2 14 - ;; 15 - *) 16 - # Assuming the first argument is owner/repo 17 - repo="$1" 18 - IFS="/" read -r repo_owner repo_name <<< "$repo" 19 - ;; 20 - esac 21 - shift 22 - done 23 - 24 - # Check if repo has not the format owner/repo 25 - if [[ ! "$repo" =~ $clone_regex ]]; then 26 - current_user=$(awk '/user:/ {print $2; exit}' ~/.config/gh/hosts.yml) 27 - 28 - # if it is our own repo the clone it 29 - if is_my_github_repo "$current_user/$repo"; then 30 - gh repo clone "$current_user/$repo" 31 - return 0 32 - fi 33 - 34 - # else print the help 35 - usage 36 - fi 37 - 38 - # Check if the owner exists on GitHub 39 - if ! is_a_github_user "$repo_owner"; then 40 - echo "${BOLD} Sorry, there is no user named ${GREEN}$repo_owner ${RESET_COLOR}on ${LIGHT_BLUE}GitHub !" 41 - return 0 42 - fi 43 - 44 - # Construct the full GitHub clone URL 45 - url="$GITHUB_URL/$repo" 46 - 47 - # If depth is provided, use it in the git clone command 48 - if [[ -n "$depth" ]]; then 49 - git clone "$url" --depth="$depth" 50 - else 51 - git clone "$url" 52 - fi 53 - } 54 - 55 - # Resolve the full path to the script's directory 56 - REAL_PATH="$(dirname "$(readlink -f "$0")")" 57 - PARENT_DIR="$(dirname "$REAL_PATH")" 58 - CATEGORY="gh_scripts" 59 - 60 - HELPS_DIR="$PARENT_DIR/helps/$CATEGORY" 61 - HELP_FILE="$(basename "$0" .sh)_help.sh" 62 - 63 - UTILS_DIR="$PARENT_DIR/utils" 64 - 65 - # Import necessary variables and functions 66 - source "$UTILS_DIR/check_connection.sh" 67 - source "$UTILS_DIR/check_repo.sh" 68 - source "$UTILS_DIR/check_git.sh" 69 - source "$UTILS_DIR/setup_git.sh" 70 - source "$UTILS_DIR/check_sudo.sh" 71 - source "$UTILS_DIR/check_user.sh" 72 - source "$UTILS_DIR/colors.sh" 73 - source "$UTILS_DIR/usage.sh" 74 - 75 - # Import help file 76 - source "$HELPS_DIR/$HELP_FILE" 77 - 78 - # Usage function to display help 79 - function usage { 80 - show_help "Usage" "${gcln_arguments[@]}" 81 - show_help "Description" "${gcln_descriptions[@]}" 82 - show_help "Options" "${gcln_options[@]}" 83 - exit 0 84 - } 85 - 86 - # regex to match clone repo case 87 - clone_regex='^[a-zA-Z0-9._-]+/[a-zA-Z0-9._-]+$' 88 - 89 - # Display help on --help flag and insifficient argument 90 - if [[ "$1" == "--help" || "$#" -lt 1 ]]; then 91 - usage 92 - fi 93 - 94 - # prompt for sudo 95 - # password if required 96 - allow_sudo 97 - 98 - # Setting up git 99 - setup_git 100 - 101 - # Check for internet connectivity to GitHub 102 - check_connection 103 - 104 - # Call the function with all arguments 105 - clone_repo "$@"
-95
gh_scripts/ghadd.sh
··· 1 - #!/bin/bash 2 - 3 - function ghadd { 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 - if ! has_remote; then 10 - echo "${BOLD} This repo has no remote on GitHub !" 11 - return 0 12 - fi 13 - 14 - if [ $# -eq 0 ]; then 15 - echo "${BOLD} Specify the username of the new collaborator !" 16 - return 0 17 - fi 18 - 19 - current_user=$(awk '/user:/ {print $2; exit}' ~/.config/gh/hosts.yml) 20 - repo_url=$(git config --get remote.origin.url) 21 - repo_owner=$(echo "$repo_url" | awk -F '[/:]' '{print $(NF-1)}') 22 - repo_name="$(echo "$repo_url" | awk -F '/' '{print $NF}' | sed 's/.git$//')" 23 - 24 - # check if we are not the owner of the repo 25 - if [ "$repo_owner" != "$current_user" ]; then 26 - echo "${BOLD} Sorry, you are not the owner of this repo !" 27 - return 0 28 - fi 29 - 30 - # Loop through each collaborator username provided as an argument 31 - for collaborator in "$@"; do 32 - # Check if the collaborator exists on GitHub 33 - if ! is_a_github_user "$collaborator"; then 34 - printf "${BOLD} Cannot invite ${LIGHT_BLUE}$collaborator ${RESET_COLOR}to collaborate on ${LIGHT_BLUE}$repo_name${RESET_COLOR} " 35 - continue 36 - fi 37 - 38 - execute_with_loading \ 39 - "${BOLD} Inviting ${LIGHT_BLUE}$collaborator ${RESET_COLOR}to collaborate on ${LIGHT_BLUE}$repo_name${RESET_COLOR}" \ 40 - "gh api --method=PUT repos/$current_user/$repo_name/collaborators/$collaborator" 41 - done 42 - } 43 - 44 - # Resolve the full path to the script's directory 45 - REAL_PATH="$(dirname "$(readlink -f "$0")")" 46 - PARENT_DIR="$(dirname "$REAL_PATH")" 47 - CATEGORY="gh_scripts" 48 - 49 - HELPS_DIR="$PARENT_DIR/helps/$CATEGORY" 50 - HELP_FILE="$(basename "$0" .sh)_help.sh" 51 - 52 - UTILS_DIR="$PARENT_DIR/utils" 53 - 54 - # Import necessary variables and functions 55 - source "$UTILS_DIR/check_connection.sh" 56 - source "$UTILS_DIR/check_git.sh" 57 - source "$UTILS_DIR/check_gh.sh" 58 - source "$UTILS_DIR/setup_git.sh" 59 - source "$UTILS_DIR/check_remote.sh" 60 - source "$UTILS_DIR/check_sudo.sh" 61 - source "$UTILS_DIR/check_user.sh" 62 - source "$UTILS_DIR/colors.sh" 63 - source "$UTILS_DIR/loading.sh" 64 - source "$UTILS_DIR/usage.sh" 65 - 66 - # Import help file 67 - source "$HELPS_DIR/$HELP_FILE" 68 - 69 - # Usage function to display help 70 - function usage { 71 - show_help "Usage" "${ghadd_arguments[@]}" 72 - show_help "Description" "${ghadd_descriptions[@]}" 73 - show_help "Options" "${ghadd_options[@]}" 74 - show_extra "${ghadd_extras[@]}" 75 - exit 0 76 - } 77 - 78 - # Check if --help is the first argument 79 - [ "$1" = "--help" ] && usage 80 - 81 - # prompt for sudo 82 - # password if required 83 - allow_sudo 84 - 85 - # Setting up git 86 - setup_git 87 - 88 - # Check gh 89 - check_gh 90 - 91 - # Check for internet connectivity to GitHub 92 - check_connection 93 - 94 - # Call ghadd function 95 - ghadd "$@"
-178
gh_scripts/ghc.sh
··· 1 - #!/bin/bash 2 - 3 - function ghc { 4 - # Get the repo name and visibility 5 - if [ $# -eq 0 ]; then 6 - repo="$(basename "$PWD")" 7 - repo_visibility="public" 8 - elif [ $# -eq 1 ]; then 9 - if [ "$1" = "private" ]; then 10 - repo="$(basename "$PWD")" 11 - repo_visibility="private" 12 - else 13 - repo="$1" 14 - repo_visibility="public" 15 - fi 16 - elif [ $# -eq 2 ]; then 17 - repo="$1" 18 - repo_visibility="$2" 19 - else 20 - echo "${BOLD}${RED}Error: Too many arguments.${RESET}" 21 - usage 22 - fi 23 - 24 - # Clean the repo name 25 - repo_name=$(clean_repo "$repo") 26 - 27 - if is_a_git_repo; then 28 - if has_remote; then 29 - printf "${BOLD} This repo already has a remote on GitHub!${RESET}\n" 30 - return 0 31 - fi 32 - 33 - current_user=$(awk '/user:/ {print $2; exit}' ~/.config/gh/hosts.yml) 34 - current_protocol=$(grep 'git_protocol:' ~/.config/gh/hosts.yml | awk '{print $2}') 35 - origin_base_url=$( 36 - [[ "$current_protocol" == "ssh" ]] && 37 - echo "git@github.com:" || 38 - echo "https://github.com/" 39 - ) 40 - 41 - check_set_repo() { 42 - printf "${BOLD}${RESET_COLOR} Create ${GREEN}$repo_visibility ${RESET_COLOR}repo ${LIGHT_BLUE}$repo_name ${RESET_COLOR}? (y/n) ${RESET}" 43 - read set_repo 44 - if [ "$set_repo" = "y" ]; then 45 - # Create the repo & set it as remote of the local one 46 - printf "${BOLD} New repository ${LIGHT_BLUE}$repo_name ${RESET_COLOR}on GitHub ... ${RESET}" 47 - gh repo create "$repo_name" --"$repo_visibility" &>/dev/null 48 - git remote add origin "$origin_base_url$current_user/$repo_name.git" 49 - printf "${BOLD}${GREEN} ${RESET}\n" 50 - 51 - check_push() { 52 - printf "${BOLD}${RESET_COLOR} Push local commits to ${LIGHT_BLUE}$repo_name ${RESET_COLOR}? (y/n) ${RESET}" 53 - read check_push_commit 54 - 55 - if [ "$check_push_commit" = "y" ]; then 56 - current_branch=$(git branch | awk '/\*/ {print $2}') 57 - git push origin "$current_branch" 58 - elif [ "$check_push_commit" = "n" ]; then 59 - return 0 60 - else 61 - check_push 62 - fi 63 - } 64 - 65 - current_branch=$(git branch | awk '/\*/ {print $2}') 66 - 67 - if git rev-list --count "$current_branch" 2>/dev/null | grep -q '^[1-9]'; then 68 - check_push 69 - fi 70 - elif [ "$set_repo" = "n" ]; then 71 - return 0 72 - else 73 - check_set_repo 74 - fi 75 - } 76 - check_set_repo 77 - else 78 - # Check for internet connectivity to GitHub 79 - if ! connected; then 80 - echo "${BOLD} Sorry, you are offline !${RESET}" 81 - check_local() { 82 - printf "${BOLD}${RESET_COLOR} Create ${GREEN}local ${RESET_COLOR}repo ${LIGHT_BLUE}$repo_name ${RESET_COLOR}? (y/n) ${RESET}" 83 - read create_local 84 - 85 - if [ "$create_local" = "y" ]; then 86 - git init &>/dev/null 87 - elif [ "$create_local" = "n" ]; then 88 - return 0 89 - else 90 - check_local 91 - fi 92 - } 93 - check_local 94 - else 95 - check_create_repo() { 96 - printf "${BOLD}${RESET_COLOR} Create ${GREEN}$repo_visibility ${RESET_COLOR}repo ${LIGHT_BLUE}$repo_name ${RESET_COLOR}? (y/n) ${RESET}" 97 - read create_repo 98 - if [ "$create_repo" = "y" ]; then 99 - # Create the repo & clone it locally 100 - printf "${BOLD} New repository ${LIGHT_BLUE}$repo_name ${RESET_COLOR}on GitHub ... ${RESET}" 101 - gh repo create "$repo_name" --"$repo_visibility" -c &>/dev/null 102 - mv "$repo_name/.git" . && rm -rf "$repo_name" 103 - printf "${BOLD}${GREEN} ${RESET}\n" 104 - elif [ "$create_repo" = "n" ]; then 105 - check_local() { 106 - printf "${BOLD}${RESET_COLOR} Create ${GREEN}local ${RESET_COLOR}repo ${LIGHT_BLUE}$repo_name ${RESET_COLOR}? (y/n) ${RESET}" 107 - read create_local 108 - 109 - if [ "$create_local" = "y" ]; then 110 - git init &>/dev/null 111 - elif [ "$create_local" = "n" ]; then 112 - return 0 113 - else 114 - check_local 115 - fi 116 - } 117 - check_local 118 - else 119 - check_create_repo 120 - fi 121 - } 122 - check_create_repo 123 - fi 124 - fi 125 - } 126 - 127 - # Resolve the full path to the script's directory 128 - REAL_PATH="$(dirname "$(readlink -f "$0")")" 129 - PARENT_DIR="$(dirname "$REAL_PATH")" 130 - CATEGORY="gh_scripts" 131 - 132 - HELPS_DIR="$PARENT_DIR/helps/$CATEGORY" 133 - HELP_FILE="$(basename "$0" .sh)_help.sh" 134 - 135 - UTILS_DIR="$PARENT_DIR/utils" 136 - 137 - # Import necessary variables and functions 138 - source "$UTILS_DIR/check_connection.sh" 139 - source "$UTILS_DIR/check_git.sh" 140 - source "$UTILS_DIR/check_gh.sh" 141 - source "$UTILS_DIR/setup_git.sh" 142 - source "$UTILS_DIR/check_remote.sh" 143 - source "$UTILS_DIR/check_sudo.sh" 144 - source "$UTILS_DIR/check_user.sh" 145 - source "$UTILS_DIR/clean_repo.sh" 146 - source "$UTILS_DIR/colors.sh" 147 - source "$UTILS_DIR/usage.sh" 148 - 149 - # Import help file 150 - source "$HELPS_DIR/$HELP_FILE" 151 - 152 - # Usage function to display help 153 - function usage { 154 - show_help "Usage" "${ghc_arguments[@]}" 155 - show_help "Description" "${ghc_descriptions[@]}" 156 - show_help "Options" "${ghc_options[@]}" 157 - show_extra "${ghc_extras[@]}" 158 - exit 0 159 - } 160 - 161 - # Check if --help is the first argument 162 - [ "$1" = "--help" ] && usage 163 - 164 - # prompt for sudo 165 - # password if required 166 - allow_sudo 167 - 168 - # Setting up git 169 - setup_git 170 - 171 - # Check gh 172 - check_gh 173 - 174 - # Check for internet connectivity to GitHub 175 - check_connection 176 - 177 - # Call ghc function 178 - ghc "$@"
-112
gh_scripts/ghcls.sh
··· 1 - #!/bin/bash 2 - 3 - function ghcls { 4 - # Check for git local repo 5 - if ! is_a_git_repo; then 6 - echo "${BOLD} This won't work, you are not in a git repo !" 7 - return 0 8 - fi 9 - 10 - # Check for remote repo 11 - if ! has_remote; then 12 - echo "${BOLD} This repo has no remote on GitHub !" 13 - return 0 14 - fi 15 - 16 - current_user=$(awk '/user:/ {print $2; exit}' ~/.config/gh/hosts.yml) 17 - repo_url=$(git config --get remote.origin.url) 18 - repo_owner=$(echo "$repo_url" | awk -F '[/:]' '{print $(NF-1)}') 19 - repo_name="$(echo "$repo_url" | awk -F '/' '{print $NF}' | sed 's/.git$//')" 20 - 21 - # check if we are not the owner of the repo 22 - if [ "$repo_owner" != "$current_user" ]; then 23 - echo "${BOLD} Sorry, you are not the owner of this repo !" 24 - return 0 25 - fi 26 - 27 - printf "${BOLD} ${LIGHT_BLUE}Collaborators ${RESET_COLOR}for the ${LIGHT_BLUE}$repo_name ${RESET_COLOR}repository " 28 - 29 - # List collaborators using gh api 30 - collaborators=$(gh api "repos/$current_user/$repo_name/collaborators" --jq '.[].login') 31 - invitations=$(gh api "repos/$current_user/$repo_name/invitations" --jq '.[].invitee.login') 32 - 33 - collaborators_count=$(echo "$collaborators" | wc -l) 34 - invitations_count=$(echo "$invitations" | wc -l) 35 - collaborators_num=$((collaborators_count + invitations_count)) 36 - echo "${RESET_COLOR}${BOLD}($collaborators_count)" 37 - 38 - # Check if we get any collaborators 39 - if [ -z "$collaborators" ]; then 40 - echo "No collaborators found." 41 - return 0 42 - fi 43 - 44 - # Iterate through each collaborator 45 - echo "$collaborators" | while IFS= read -r collaborator; do 46 - if [ "$collaborator" = "$current_user" ]; then 47 - echo " ● $collaborator (owner)" 48 - else 49 - echo " ● $collaborator" 50 - fi 51 - done 52 - 53 - # Check if there are pending invitations 54 - if [ -n "$invitations" ]; then 55 - # Print pending invitations 56 - echo "$invitations" | while IFS= read -r invitee; do 57 - echo " ● $invitee (invitation pending)" 58 - done 59 - fi 60 - } 61 - 62 - # Resolve the full path to the script's directory 63 - REAL_PATH="$(dirname "$(readlink -f "$0")")" 64 - PARENT_DIR="$(dirname "$REAL_PATH")" 65 - CATEGORY="gh_scripts" 66 - 67 - HELPS_DIR="$PARENT_DIR/helps/$CATEGORY" 68 - HELP_FILE="$(basename "$0" .sh)_help.sh" 69 - 70 - UTILS_DIR="$PARENT_DIR/utils" 71 - 72 - # Import necessary variables and functions 73 - source "$UTILS_DIR/check_connection.sh" 74 - source "$UTILS_DIR/check_git.sh" 75 - source "$UTILS_DIR/check_gh.sh" 76 - source "$UTILS_DIR/setup_git.sh" 77 - source "$UTILS_DIR/check_remote.sh" 78 - source "$UTILS_DIR/check_sudo.sh" 79 - source "$UTILS_DIR/check_user.sh" 80 - source "$UTILS_DIR/colors.sh" 81 - source "$UTILS_DIR/usage.sh" 82 - 83 - # Import help file 84 - source "$HELPS_DIR/$HELP_FILE" 85 - 86 - # Usage function to display help 87 - function usage { 88 - show_help "Usage" "${ghcls_arguments[@]}" 89 - show_help "Description" "${ghcls_descriptions[@]}" 90 - show_help "Options" "${ghcls_options[@]}" 91 - show_extra "${ghcls_extras[@]}" 92 - exit 0 93 - } 94 - 95 - # Check if --help is the first argument 96 - [ "$1" = "--help" ] && usage 97 - 98 - # prompt for sudo 99 - # password if required 100 - allow_sudo 101 - 102 - # Setting up git 103 - setup_git 104 - 105 - # Check gh 106 - check_gh 107 - 108 - # Check for internet connectivity to GitHub 109 - check_connection 110 - 111 - # Call ghcls function 112 - ghcls
-153
gh_scripts/ghd.sh
··· 1 - #!/bin/bash 2 - 3 - function ghd { 4 - if [ $# -eq 1 ]; then 5 - if ! connected; then 6 - echo "${BOLD} Sorry, you are offline !${RESET}" 7 - return 0 8 - fi 9 - 10 - if ! gh_installed; then 11 - echo "${BOLD} gh is not installed !${RESET}" 12 - return 0 13 - fi 14 - 15 - repo_name="$1" 16 - current_user=$(awk '/user:/ {print $2; exit}' ~/.config/gh/hosts.yml) 17 - 18 - # Check if the repo doesn't exist 19 - if ! load_and_delete \ 20 - "${BOLD} Checking the ${GREEN}repo${RESET_COLOR} named" \ 21 - "${LIGHT_BLUE}$current_user/$repo_name ${RESET_COLOR}on GitHub" \ 22 - "is_my_github_repo $current_user/$repo_name"; then 23 - 24 - echo "${BOLD} Sorry, there is ${GREEN}no repo ${RESET_COLOR}such as" \ 25 - "${LIGHT_BLUE}$current_user/$repo_name ${RESET_COLOR}on GitHub ${RESET}" 26 - return 0 27 - fi 28 - 29 - isPrivate=$(gh repo view "$repo_name" --json isPrivate --jq '.isPrivate') 30 - repo_visibility=$([ "$isPrivate" = "true" ] && echo "private" || echo "public") 31 - 32 - delete_repo "$repo_name" 33 - else 34 - if ! is_a_git_repo; then 35 - echo "${BOLD} This won't work, you are not in a git repo!${RESET}" 36 - return 0 37 - fi 38 - 39 - if has_remote; then 40 - if connected; then 41 - if ! gh_installed; then 42 - echo "${BOLD} gh is not installed !${RESET}" 43 - return 0 44 - fi 45 - 46 - repo_url=$(git config --get remote.origin.url) 47 - current_user=$(awk '/user:/ {print $2; exit}' ~/.config/gh/hosts.yml) 48 - repo_owner=$(echo "$repo_url" | awk -F '[/:]' '{print $(NF-1)}') 49 - 50 - if [ "$repo_owner" != "$current_user" ]; then 51 - echo "${BOLD} Sorry, you are not the owner of this repo!${RESET}" 52 - else 53 - repo_name=$(echo "$repo_url" | awk -F '/' '{print $NF}' | sed 's/.git$//') 54 - isPrivate=$(gh repo view "$repo_name" --json isPrivate --jq '.isPrivate') 55 - repo_visibility=$([ "$isPrivate" = "true" ] && echo "private" || echo "public") 56 - 57 - delete_repo "$repo_name" 58 - git remote remove origin 59 - echo 60 - delete_local_repo "$repo_name" 61 - fi 62 - else 63 - repo_name=$(basename "$(git rev-parse --show-toplevel)") 64 - delete_local_repo "$repo_name" 65 - fi 66 - else 67 - repo_name=$(basename "$(git rev-parse --show-toplevel)") 68 - delete_local_repo "$repo_name" 69 - fi 70 - fi 71 - } 72 - 73 - # Resolve the full path to the script's directory 74 - REAL_PATH="$(dirname "$(readlink -f "$0")")" 75 - PARENT_DIR="$(dirname "$REAL_PATH")" 76 - CATEGORY="gh_scripts" 77 - 78 - HELPS_DIR="$PARENT_DIR/helps/$CATEGORY" 79 - HELP_FILE="$(basename "$0" .sh)_help.sh" 80 - 81 - UTILS_DIR="$PARENT_DIR/utils" 82 - 83 - # Import necessary variables and functions 84 - source "$UTILS_DIR/check_connection.sh" 85 - source "$UTILS_DIR/check_git.sh" 86 - source "$UTILS_DIR/check_gh.sh" 87 - source "$UTILS_DIR/check_repo.sh" 88 - source "$UTILS_DIR/setup_git.sh" 89 - source "$UTILS_DIR/check_remote.sh" 90 - source "$UTILS_DIR/check_sudo.sh" 91 - source "$UTILS_DIR/check_user.sh" 92 - source "$UTILS_DIR/clean_repo.sh" 93 - source "$UTILS_DIR/colors.sh" 94 - source "$UTILS_DIR/loading.sh" 95 - source "$UTILS_DIR/usage.sh" 96 - 97 - # Import help file 98 - source "$HELPS_DIR/$HELP_FILE" 99 - 100 - # Usage function to display help 101 - function usage { 102 - show_help "Usage" "${ghd_arguments[@]}" 103 - show_help "Description" "${ghd_descriptions[@]}" 104 - show_help "Options" "${ghd_options[@]}" 105 - exit 0 106 - } 107 - 108 - # Check if --help is the first argument 109 - [ "$1" = "--help" ] && usage 110 - 111 - # prompt for sudo 112 - # password if required 113 - allow_sudo 114 - 115 - # Setting up git 116 - setup_git 117 - 118 - # Function to delete local repo 119 - function delete_local_repo { 120 - printf "${BOLD}${RESET} Delete ${GREEN}local ${RESET_COLOR}repo ${LIGHT_BLUE}$1 ${RESET}? (y/n) ${RESET}" 121 - read delete_local_repo 122 - 123 - if [ "$delete_local_repo" = "y" ]; then 124 - local repo_source=$(git rev-parse --show-toplevel) 125 - 126 - execute_with_loading \ 127 - "${BOLD} Deleting ${GREEN}local ${RESET_COLOR}repo ${LIGHT_BLUE}$1 ${RESET}" \ 128 - "rm -rf "$repo_source/.git"" 129 - elif [ "$delete_local_repo" = "n" ]; then 130 - return 0 131 - else 132 - delete_local_repo "$1" 133 - fi 134 - } 135 - 136 - # Function to delete GitHub repo 137 - function delete_repo { 138 - printf "${BOLD} Delete ${GREEN}$repo_visibility ${RESET_COLOR}repo ${LIGHT_BLUE}$1 ${RESET_COLOR}? (y/n) ${RESET}" 139 - read delete_repo 140 - 141 - if [ "$delete_repo" = "y" ]; then 142 - execute_with_loading \ 143 - "${BOLD} Deleting repository ${LIGHT_BLUE}$1 ${RESET_COLOR}on GitHub" \ 144 - "gh repo delete "$1" --yes" 145 - elif [ "$delete_repo" = "n" ]; then 146 - return 0 147 - else 148 - delete_repo "$1" 149 - fi 150 - } 151 - 152 - # Call ghd function 153 - ghd "$@"
-107
gh_scripts/ghdel.sh
··· 1 - #!/bin/bash 2 - 3 - function ghdel { 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 - if ! has_remote; then 10 - echo "${BOLD} This repo has no remote on Github !" 11 - return 0 12 - fi 13 - 14 - if [ $# -eq 0 ]; then 15 - echo "${BOLD} Specify the username of the collaborator to remove !" 16 - return 0 17 - fi 18 - 19 - current_user=$(awk '/user:/ {print $2; exit}' ~/.config/gh/hosts.yml) 20 - repo_url=$(git config --get remote.origin.url) 21 - repo_owner=$(echo "$repo_url" | awk -F '[/:]' '{print $(NF-1)}') 22 - repo_name="$(echo "$repo_url" | awk -F '/' '{print $NF}' | sed 's/.git$//')" 23 - 24 - # check if we are not the owner of the repo 25 - if [ "$repo_owner" != "$current_user" ]; then 26 - echo "${BOLD} Sorry, you are not the owner of this repo !" 27 - return 0 28 - fi 29 - 30 - # Retrieve the list of collaborators 31 - collaborators=$(gh api "repos/$current_user/$repo_name/collaborators" --jq '.[].login') 32 - invitations=$(gh api "repos/$current_user/$repo_name/invitations" --jq '.[].invitee.login') 33 - 34 - # Loop through each collaborator username provided as an argument 35 - for collaborator in "$@"; do 36 - # Check if the collaborator exists in the list of collaborators 37 - if echo "$collaborators" | grep -q "$collaborator" || 38 - echo "$invitations" | grep -q "$collaborator"; then 39 - printf "${BOLD} Removing ${LIGHT_BLUE}$collaborator ${RESET_COLOR}from ${LIGHT_BLUE}$repo_name${RESET_COLOR} " 40 - # Check for pending invitations 41 - invitation_id=$(gh api "repos/$current_user/$repo_name/invitations" --jq ".[] | select(.invitee.login==\"$collaborator\") | .id") 42 - 43 - if [ -n "$invitation_id" ]; then 44 - # Delete the pending invitation 45 - gh api --method=DELETE "repos/$current_user/$repo_name/invitations/$invitation_id" >/dev/null 2>&1 46 - printf " ${BOLD}(invitation deleted) " 47 - fi 48 - 49 - # Remove collaborator using gh api 50 - gh api --method=DELETE "repos/$current_user/$repo_name/collaborators/$collaborator" >/dev/null 2>&1 51 - echo "${BOLD}${GREEN} ${RESET_COLOR}" 52 - else 53 - echo "${BOLD}${LIGHT_BLUE}$collaborator ${RESET_COLOR}is not a ${LIGHT_BLUE}collaborator ${RED}✘ ${RESET_COLOR}" 54 - fi 55 - done 56 - } 57 - 58 - # Resolve the full path to the script's directory 59 - REAL_PATH="$(dirname "$(readlink -f "$0")")" 60 - PARENT_DIR="$(dirname "$REAL_PATH")" 61 - CATEGORY="gh_scripts" 62 - 63 - HELPS_DIR="$PARENT_DIR/helps/$CATEGORY" 64 - HELP_FILE="$(basename "$0" .sh)_help.sh" 65 - 66 - UTILS_DIR="$PARENT_DIR/utils" 67 - 68 - # Import necessary variables and functions 69 - source "$UTILS_DIR/check_connection.sh" 70 - source "$UTILS_DIR/check_git.sh" 71 - source "$UTILS_DIR/check_gh.sh" 72 - source "$UTILS_DIR/setup_git.sh" 73 - source "$UTILS_DIR/check_remote.sh" 74 - source "$UTILS_DIR/check_sudo.sh" 75 - source "$UTILS_DIR/colors.sh" 76 - source "$UTILS_DIR/usage.sh" 77 - 78 - # Import help file 79 - source "$HELPS_DIR/$HELP_FILE" 80 - 81 - # Usage function to display help 82 - function usage { 83 - show_help "Usage" "${ghdel_arguments[@]}" 84 - show_help "Description" "${ghdel_descriptions[@]}" 85 - show_help "Options" "${ghdel_options[@]}" 86 - show_extra "${ghdel_extras[@]}" 87 - exit 0 88 - } 89 - 90 - # Check if --help is the first argument 91 - [ "$1" = "--help" ] && usage 92 - 93 - # prompt for sudo 94 - # password if required 95 - allow_sudo 96 - 97 - # Setting up git 98 - setup_git 99 - 100 - # Check gh 101 - check_gh 102 - 103 - # Check for internet connectivity to GitHub 104 - check_connection 105 - 106 - # Call ghdel function 107 - ghdel "$@"
-119
gh_scripts/ghf.sh
··· 1 - #!/bin/bash 2 - 3 - function ghf { 4 - repo="$1" 5 - IFS="/" read -r repo_owner repo_name <<< "$repo" 6 - current_user=$(awk '/user:/ {print $2; exit}' ~/.config/gh/hosts.yml) 7 - clone_repo="--clone" 8 - 9 - # regex to match clone repo case 10 - clone_regex='^[a-zA-Z0-9_-]+/[a-zA-Z0-9_-]+$' 11 - 12 - # Check if repo has not the format owner/repo 13 - if [[ ! "$repo" =~ $clone_regex ]]; then 14 - usage 15 - fi 16 - 17 - # Check if we have already forked it 18 - if load_and_delete \ 19 - "${BOLD} Checking the forked ${GREEN}repo ${RESET_COLOR} named" \ 20 - "${LIGHT_BLUE}$current_user/$repo_name ${RESET_COLOR}on GitHub" \ 21 - "is_a_github_repo $current_user/$repo_name"; then 22 - echo "${BOLD} You have already ${RED}forked ${RESET_COLOR}the repo named" \ 23 - "${GREEN}$repo_name ${RESET_COLOR}on ${LIGHT_BLUE}GitHub ${RESET}" 24 - return 0 25 - fi 26 - 27 - # Check if the owner exists on GitHub 28 - if ! load_and_delete \ 29 - "${BOLD} Checking the ${GREEN}user ${RESET_COLOR}named" \ 30 - "${LIGHT_BLUE}$repo_owner ${RESET_COLOR}on GitHub" \ 31 - "is_a_github_user $repo_owner"; then 32 - echo "${BOLD} Sorry, there is ${GREEN}no user ${RESET_COLOR}named" \ 33 - "${LIGHT_BLUE}$repo_owner ${RESET_COLOR}on GitHub ${RESET}" 34 - return 0 35 - fi 36 - 37 - # Check if the repo doesn't exist 38 - if ! load_and_delete \ 39 - "${BOLD} Checking the ${GREEN}repo ${RESET_COLOR}named" \ 40 - "${LIGHT_BLUE}$repo_owner/$repo_name ${RESET_COLOR}on GitHub" \ 41 - "is_a_github_repo $repo_owner/$repo_name"; then 42 - echo "${BOLD} Sorry, there is ${GREEN}no repo ${RESET_COLOR}such" \ 43 - "${LIGHT_BLUE}$repo_owner/$repo_name ${RESET_COLOR}on GitHub ${RESET}" 44 - return 0 45 - fi 46 - 47 - if load_and_delete \ 48 - "${BOLD} Checking the ${GREEN}local ${RESET_COLOR}git" \ 49 - "${LIGHT_BLUE}repo ${RESET_COLOR}" \ 50 - "is_a_git_repo"; then 51 - printf "${BOLD}${GREEN} Local Git${RESET_COLOR} repo detected," \ 52 - "skipping fork clone for ${LIGHT_BLUE}$repo_name ${RESET}\n" 53 - clone_repo="" 54 - fi 55 - 56 - if execute_with_loading \ 57 - "${BOLD} Forking ${LIGHT_BLUE}$repo_name ${RESET_COLOR}on GitHub" \ 58 - "gh repo fork $repo_owner/$repo_name"; then 59 - 60 - if [ "$clone_repo" == "--clone" ]; then 61 - execute_with_loading \ 62 - "${BOLD} Cloning fork ${LIGHT_BLUE}$repo_name ${RESET_COLOR}locally" \ 63 - "gh repo clone $current_user/$repo_name" 64 - fi 65 - fi 66 - } 67 - 68 - # Resolve the full path to the script's directory 69 - REAL_PATH="$(dirname "$(readlink -f "$0")")" 70 - PARENT_DIR="$(dirname "$REAL_PATH")" 71 - CATEGORY="gh_scripts" 72 - 73 - HELPS_DIR="$PARENT_DIR/helps/$CATEGORY" 74 - HELP_FILE="$(basename "$0" .sh)_help.sh" 75 - 76 - UTILS_DIR="$PARENT_DIR/utils" 77 - 78 - # Import necessary variables and functions 79 - source "$UTILS_DIR/check_connection.sh" 80 - source "$UTILS_DIR/check_git.sh" 81 - source "$UTILS_DIR/check_gh.sh" 82 - source "$UTILS_DIR/check_repo.sh" 83 - source "$UTILS_DIR/setup_git.sh" 84 - source "$UTILS_DIR/check_sudo.sh" 85 - source "$UTILS_DIR/check_user.sh" 86 - source "$UTILS_DIR/colors.sh" 87 - source "$UTILS_DIR/loading.sh" 88 - source "$UTILS_DIR/usage.sh" 89 - 90 - # Import help file 91 - source "$HELPS_DIR/$HELP_FILE" 92 - 93 - # Usage function to display help 94 - function usage { 95 - show_help "Usage" "${ghf_arguments[@]}" 96 - show_help "Description" "${ghf_descriptions[@]}" 97 - show_help "Options" "${ghf_options[@]}" 98 - show_help "Example" "${ghf_extras[@]}" 99 - exit 0 100 - } 101 - 102 - # Check if --help is the first argument 103 - [ "$1" = "--help" ] && usage 104 - 105 - # prompt for sudo 106 - # password if required 107 - allow_sudo 108 - 109 - # Setting up git 110 - setup_git 111 - 112 - # Check gh 113 - check_gh 114 - 115 - # Check for internet connectivity to GitHub 116 - check_connection 117 - 118 - # Call the function with all arguments 119 - ghf "$@"
-91
gh_scripts/ghnm.sh
··· 1 - #!/bin/bash 2 - 3 - function ghnm { 4 - # Check if we are inside a git repo 5 - if ! load_and_delete \ 6 - "${BOLD} Checking the ${GREEN}local ${RESET_COLOR}git" \ 7 - "${LIGHT_BLUE}repo ${RESET_COLOR}" \ 8 - "is_a_git_repo"; then 9 - echo "${BOLD} This won't work, you are not in a git repo !" 10 - return 0 11 - fi 12 - 13 - # Check if the repo has a remote 14 - if ! load_and_delete \ 15 - "${BOLD} Checking the ${GREEN}remote ${RESET_COLOR}git" \ 16 - "${LIGHT_BLUE}repo ${RESET_COLOR}on GitHub" \ 17 - "has_remote"; then 18 - echo "${BOLD} This repo has no remote on GitHub !" 19 - return 0 20 - fi 21 - 22 - # Define the new name of the repo 23 - new_name="$1" 24 - repo_url=$(git config --get remote.origin.url) 25 - repo_name=$(echo "$repo_url" | awk -F '/' '{print $NF}' | sed 's/.git$//') 26 - 27 - if [ "$new_name" == "$repo_name" ]; then 28 - echo "${BOLD} The ${GREEN}remote ${RESET_COLOR}repo name is" \ 29 - "${LIGHT_BLUE}$repo_name ${RESET}" 30 - return 0 31 - fi 32 - 33 - execute_with_loading \ 34 - "${BOLD} Renaming ${GREEN}remote ${RESET_COLOR}repo" \ 35 - "${LIGHT_BLUE}$repo_name ${RESET_COLOR}to ${LIGHT_BLUE}$new_name ${RESET_COLOR}" \ 36 - "gh repo rename "$new_name" --yes" 37 - } 38 - 39 - # Resolve the full path to the script's directory 40 - REAL_PATH="$(dirname "$(readlink -f "$0")")" 41 - PARENT_DIR="$(dirname "$REAL_PATH")" 42 - CATEGORY="gh_scripts" 43 - 44 - HELPS_DIR="$PARENT_DIR/helps/$CATEGORY" 45 - HELP_FILE="$(basename "$0" .sh)_help.sh" 46 - 47 - UTILS_DIR="$PARENT_DIR/utils" 48 - 49 - # Import necessary variables and functions 50 - source "$UTILS_DIR/check_connection.sh" 51 - source "$UTILS_DIR/check_git.sh" 52 - source "$UTILS_DIR/check_gh.sh" 53 - source "$UTILS_DIR/setup_git.sh" 54 - source "$UTILS_DIR/check_remote.sh" 55 - source "$UTILS_DIR/check_sudo.sh" 56 - source "$UTILS_DIR/check_user.sh" 57 - source "$UTILS_DIR/clean_repo.sh" 58 - source "$UTILS_DIR/colors.sh" 59 - source "$UTILS_DIR/loading.sh" 60 - source "$UTILS_DIR/usage.sh" 61 - 62 - # Import help file 63 - source "$HELPS_DIR/$HELP_FILE" 64 - 65 - # Usage function to display help 66 - function usage { 67 - show_help "Usage" "${ghnm_arguments[@]}" 68 - show_help "Description" "${ghnm_descriptions[@]}" 69 - show_help "Options" "${ghnm_options[@]}" 70 - show_help "Example" "${ghnm_extras[@]}" 71 - exit 0 72 - } 73 - 74 - # Check if --help is the first argument 75 - [ "$1" = "--help" ] && usage 76 - 77 - # prompt for sudo 78 - # password if required 79 - allow_sudo 80 - 81 - # Setting up git 82 - setup_git 83 - 84 - # Check gh 85 - check_gh 86 - 87 - # Check for internet connectivity to GitHub 88 - check_connection 89 - 90 - # Call ghc function 91 - ghnm "$@"
-128
gh_scripts/ghv.sh
··· 1 - #!/bin/bash 2 - 3 - function ghv { 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 - if [[ ! connected && "$1" = "owner" ]]; then 10 - if has_remote; then 11 - repo_url=$(git config --get remote.origin.url) 12 - repo_owner=$(echo "$repo_url" | awk -F '[/:]' '{print $(NF-1)}') 13 - repo_name="$(echo "$repo_url" | awk -F '/' '{print $NF}' | sed 's/.git$//')" 14 - else 15 - repo_owner=$(git config user.name) 16 - repo_name=$(basename "$(git rev-parse --show-toplevel)") 17 - fi 18 - 19 - if has_remote; then 20 - echo "${BOLD} The repo ${LIGHT_BLUE}$repo_name ${RESET_COLOR}is owned by ${GREEN}$repo_owner" 21 - else 22 - echo "${BOLD} The local repo ${LIGHT_BLUE}$repo_name ${RESET_COLOR}is owned by ${GREEN}$repo_owner" 23 - fi 24 - 25 - return 0 26 - fi 27 - 28 - if [ "$#" -eq 0 ] || [ "$1" = "show" ] || [ "$1" = "owner" ]; then 29 - current_user=$(awk '/user:/ {print $2; exit}' ~/.config/gh/hosts.yml) 30 - 31 - if has_remote; then 32 - repo_url=$(git config --get remote.origin.url) 33 - repo_owner=$(echo "$repo_url" | awk -F '[/:]' '{print $(NF-1)}') 34 - repo_name="$(echo "$repo_url" | awk -F '/' '{print $NF}' | sed 's/.git$//')" 35 - else 36 - repo_owner=$(git config user.name) 37 - repo_name=$(basename "$(git rev-parse --show-toplevel)") 38 - fi 39 - 40 - if [ "$repo_owner" != "$current_user" ] && [ "$1" != "owner" ]; then 41 - echo "${BOLD} Sorry, you are not the owner of this repo !" 42 - elif [ "$1" = "owner" ]; then 43 - if has_remote; then 44 - echo "${BOLD} The repo ${LIGHT_BLUE}$repo_name ${RESET_COLOR}is owned by ${GREEN}$repo_owner" 45 - else 46 - echo "${BOLD} The local repo ${LIGHT_BLUE}$repo_name ${RESET_COLOR}is owned by ${GREEN}$repo_owner" 47 - fi 48 - else 49 - if has_remote; then 50 - isPrivate=$(gh repo view "$repo_owner/$repo_name" --json isPrivate --jq '.isPrivate') 51 - 52 - if [ "$1" = "show" ]; then 53 - visibility=$([ "$isPrivate" = "true" ] && echo "private" || echo "public") 54 - echo "${BOLD} This repo ${LIGHT_BLUE}$repo_name ${RESET_COLOR}is ${GREEN}$visibility" 55 - else 56 - new_visibility=$([ "$isPrivate" = "true" ] && echo "public" || echo "private") 57 - toggle_visibility() { 58 - printf "${BOLD}${RESET_COLOR} Make ${LIGHT_BLUE}$repo_name ${RESET_COLOR}repo ${GREEN}$new_visibility ${RESET_COLOR}? (y/n) " 59 - read -r change_visibility 60 - if [ "$change_visibility" = "y" ]; then 61 - # toggle visibility 62 - printf "${BOLD} Changing repo visibility to ${GREEN}$new_visibility ${RESET_COLOR}... " 63 - gh repo edit "$repo_owner/$repo_name" --visibility "$new_visibility" &>/dev/null 64 - echo "${BOLD}${GREEN} ${RESET_COLOR}" 65 - elif [ "$change_visibility" = "n" ]; then 66 - return 0 67 - else 68 - toggle_visibility 69 - fi 70 - } 71 - toggle_visibility 72 - fi 73 - else 74 - echo "${BOLD} The local repo ${LIGHT_BLUE}$repo_name ${RESET_COLOR}is owned by ${GREEN}$repo_owner" 75 - fi 76 - fi 77 - else 78 - echo "${BOLD} Sorry, wrong command argument !" 79 - fi 80 - } 81 - 82 - # Resolve the full path to the script's directory 83 - REAL_PATH="$(dirname "$(readlink -f "$0")")" 84 - PARENT_DIR="$(dirname "$REAL_PATH")" 85 - CATEGORY="gh_scripts" 86 - 87 - HELPS_DIR="$PARENT_DIR/helps/$CATEGORY" 88 - HELP_FILE="$(basename "$0" .sh)_help.sh" 89 - 90 - UTILS_DIR="$PARENT_DIR/utils" 91 - 92 - # Import necessary variables and functions 93 - source "$UTILS_DIR/check_connection.sh" 94 - source "$UTILS_DIR/check_git.sh" 95 - source "$UTILS_DIR/check_gh.sh" 96 - source "$UTILS_DIR/setup_git.sh" 97 - source "$UTILS_DIR/check_remote.sh" 98 - source "$UTILS_DIR/check_sudo.sh" 99 - source "$UTILS_DIR/colors.sh" 100 - source "$UTILS_DIR/usage.sh" 101 - 102 - # Import help file 103 - source "$HELPS_DIR/$HELP_FILE" 104 - 105 - # Usage function to display help 106 - function usage { 107 - show_help "Usage" "${ghv_arguments[@]}" 108 - show_help "Description" "${ghv_descriptions[@]}" 109 - show_help "Options" "${ghv_options[@]}" 110 - show_extra "${ghv_extras[@]}" 111 - exit 0 112 - } 113 - 114 - # Check if --help is the first argument 115 - [ "$1" = "--help" ] && usage 116 - 117 - # prompt for sudo 118 - # password if required 119 - allow_sudo 120 - 121 - # Setting up git 122 - setup_git 123 - 124 - # Check gh 125 - check_gh 126 - 127 - # Call ghv function 128 - ghv "$@"
+71
git.scripts/gad.sh
··· 1 + #!/bin/bash 2 + 3 + function gad { 4 + if ! is_a_git_repo; then 5 + echo "${BOLD} This won't work, you are not in a git repo!${RESET}" 6 + return 0 7 + fi 8 + 9 + if [ $# -eq 0 ]; then 10 + # If no arguments, add all changes and commit (opens editor for commit message) 11 + git add --all && git commit 12 + return 0 13 + fi 14 + 15 + if [ $# -lt 1 ]; then 16 + # File is specified but no commit message 17 + echo "${BOLD}${RED}Error: no commit message!${RESET}" 18 + return 0 19 + fi 20 + 21 + if [ -f "$1" ]; then 22 + # Add the file and commit with message from arguments 2 onwards 23 + git add "$1" && git commit "$1" -m "${*:2}" 24 + return 0 25 + fi 26 + 27 + # Add all changes and commit with the provided message 28 + git add --all && git commit -m "$*" 29 + } 30 + 31 + # Resolve the full path to the script's directory 32 + REAL_PATH="$(dirname "$(readlink -f "$0")")" 33 + PARENT_DIR="$(dirname "$REAL_PATH")" 34 + CATEGORY="git.scripts" 35 + 36 + HELPS_DIR="$PARENT_DIR/helps/$CATEGORY" 37 + HELP_FILE="$(basename "$0" .sh)_help.sh" 38 + 39 + UTILS_DIR="$PARENT_DIR/utils" 40 + 41 + # Import necessary variables and functions 42 + source "$UTILS_DIR/check_git.sh" 43 + source "$UTILS_DIR/setup_git.sh" 44 + source "$UTILS_DIR/check_sudo.sh" 45 + source "$UTILS_DIR/colors.sh" 46 + source "$UTILS_DIR/usage.sh" 47 + 48 + # Import help file 49 + source "$HELPS_DIR/$HELP_FILE" 50 + 51 + # Usage function to display help 52 + function usage { 53 + show_help "Usage" "${gad_arguments[@]}" 54 + show_help "Description" "${gad_descriptions[@]}" 55 + show_help "Options" "${gad_options[@]}" 56 + show_extra "${gad_extras[@]}" 57 + exit 0 58 + } 59 + 60 + # Check if --help is the first argument 61 + [ "$1" = "--help" ] && usage 62 + 63 + # prompt for sudo 64 + # password if required 65 + allow_sudo 66 + 67 + # Setting up git 68 + setup_git 69 + 70 + # Call gad function 71 + gad "$@"
+58
git.scripts/gcb.sh
··· 1 + #!/bin/bash 2 + 3 + function 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 19 + REAL_PATH="$(dirname "$(readlink -f "$0")")" 20 + PARENT_DIR="$(dirname "$REAL_PATH")" 21 + CATEGORY="git.scripts" 22 + 23 + HELPS_DIR="$PARENT_DIR/helps/$CATEGORY" 24 + HELP_FILE="$(basename "$0" .sh)_help.sh" 25 + 26 + UTILS_DIR="$PARENT_DIR/utils" 27 + 28 + # Import necessary variables and functions 29 + source "$UTILS_DIR/check_git.sh" 30 + source "$UTILS_DIR/setup_git.sh" 31 + source "$UTILS_DIR/check_sudo.sh" 32 + source "$UTILS_DIR/colors.sh" 33 + source "$UTILS_DIR/usage.sh" 34 + 35 + # Import help file 36 + source "$HELPS_DIR/$HELP_FILE" 37 + 38 + # Usage function to display help 39 + function 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 52 + allow_sudo 53 + 54 + # Setting up git 55 + setup_git 56 + 57 + # Call gcb function 58 + gcb
+52
git.scripts/gdf.sh
··· 1 + #!/bin/bash 2 + 3 + function 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 13 + REAL_PATH="$(dirname "$(readlink -f "$0")")" 14 + PARENT_DIR="$(dirname "$REAL_PATH")" 15 + CATEGORY="git.scripts" 16 + 17 + HELPS_DIR="$PARENT_DIR/helps/$CATEGORY" 18 + HELP_FILE="$(basename "$0" .sh)_help.sh" 19 + 20 + UTILS_DIR="$PARENT_DIR/utils" 21 + 22 + # Import necessary variables and functions 23 + source "$UTILS_DIR/check_git.sh" 24 + source "$UTILS_DIR/setup_git.sh" 25 + source "$UTILS_DIR/check_sudo.sh" 26 + source "$UTILS_DIR/colors.sh" 27 + source "$UTILS_DIR/usage.sh" 28 + 29 + # Import help file 30 + source "$HELPS_DIR/$HELP_FILE" 31 + 32 + # Usage function to display help 33 + function 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 46 + allow_sudo 47 + 48 + # Setting up git 49 + setup_git 50 + 51 + # Call gdf function 52 + gdf "$@"
+84
git.scripts/glc.sh
··· 1 + #!/bin/bash 2 + 3 + function glc { 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 + has_commits=$(git log > /dev/null 2>&1 && echo "true" || echo "false") 10 + 11 + if [ "$has_commits" = "false" ]; then 12 + echo "${BOLD} Sorry, no commits yet inside this repo !"; 13 + return 0 14 + fi 15 + 16 + repo_name=$(basename "$(git rev-parse --show-toplevel)") 17 + current_branch=$(git branch | awk '/\*/ {print $2}'); 18 + commits_num=$(git log --oneline | wc -l); 19 + last_commit=$(git log --format="%H" -n 1); 20 + last_commit_message=$(git show --format=%B -s "$last_commit" | head -n 1); 21 + last_commit_author=$(git log --format='%an' -n 1) 22 + current_user=$(git config user.name) 23 + commits_done_today=$(git log --oneline --since="$(date +"%Y-%m-%d 00:00:00")" --author="$current_user" | wc -l) 24 + commits_contrib_today=$(git log --oneline --since="$(date +"%Y-%m-%d 00:00:00")" --author="$last_commit_author" | wc -l) 25 + 26 + [ $commits_num -le 1 ] && commit_text="commit" || commit_text="commits"; 27 + [ $commits_done_today -le 1 ] && commit_done_text="commit" || commit_done_text="commits"; 28 + [ $commits_contrib_today -le 1 ] && commit_contrib_text="commit" || commit_contrib_text="commits"; 29 + [ $commits_done_today -gt 0 ] && 30 + commit_done="${RESET_COLOR}Including ${LIGHT_BLUE}$commits_done_today $commit_done_text ${RESET_COLOR}by ${GREEN}$current_user ${RESET_COLOR}today" || 31 + commit_done="${RESET_COLOR}Including ${LIGHT_BLUE}$commits_contrib_today $commit_contrib_text ${RESET_COLOR}by ${GREEN}$last_commit_author ${RESET_COLOR}today" 32 + 33 + if [ "$1" = "show" ]; then 34 + git log --oneline --no-decorate; 35 + return 0 36 + fi 37 + 38 + echo "${BOLD}${LIGHT_BLUE} $repo_name ${RESET_COLOR}has ${LIGHT_BLUE}$commits_num $commit_text "; 39 + echo " $commit_done"; 40 + echo "${BOLD}${RESET_COLOR} Last Commit on ${GREEN}$current_branch ${RESET_COLOR}: $last_commit_message"; 41 + echo 42 + } 43 + 44 + # Resolve the full path to the script's directory 45 + REAL_PATH="$(dirname "$(readlink -f "$0")")" 46 + PARENT_DIR="$(dirname "$REAL_PATH")" 47 + CATEGORY="git.scripts" 48 + 49 + HELPS_DIR="$PARENT_DIR/helps/$CATEGORY" 50 + HELP_FILE="$(basename "$0" .sh)_help.sh" 51 + 52 + UTILS_DIR="$PARENT_DIR/utils" 53 + 54 + # Import necessary variables and functions 55 + source "$UTILS_DIR/check_git.sh" 56 + source "$UTILS_DIR/setup_git.sh" 57 + source "$UTILS_DIR/check_sudo.sh" 58 + source "$UTILS_DIR/colors.sh" 59 + source "$UTILS_DIR/usage.sh" 60 + 61 + # Import help file 62 + source "$HELPS_DIR/$HELP_FILE" 63 + 64 + # Usage function to display help 65 + function usage { 66 + show_help "Usage" "${glc_arguments[@]}" 67 + show_help "Description" "${glc_descriptions[@]}" 68 + show_help "Options" "${glc_options[@]}" 69 + show_extra "${glc_extras[@]}" 70 + exit 0 71 + } 72 + 73 + # Check if --help is the first argument 74 + [ "$1" = "--help" ] && usage 75 + 76 + # prompt for sudo 77 + # password if required 78 + allow_sudo 79 + 80 + # Setting up git 81 + setup_git 82 + 83 + # Call glc function 84 + glc "$@"
+71
git.scripts/gmb.sh
··· 1 + #!/bin/bash 2 + 3 + function gmb { 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 + if [ $# -eq 0 ]; then 10 + echo "${BOLD} Fatal ! Specify the Branch to merge to $current_branch" 11 + return 0 12 + fi 13 + 14 + current_branch=$(git branch | awk '/\*/ {print $2}') 15 + 16 + # check if the branch doesn't exist 17 + if ! is_a_git_branch "$1"; then 18 + echo "${BOLD} Fatal ! $1 is a Non Existing branch " 19 + return 0 20 + fi 21 + 22 + if [ "$current_branch" = "$1" ]; then 23 + echo "${BOLD} Fatal ! Cannot Merge Identical Branch " 24 + return 0 25 + fi 26 + 27 + git merge "$1" 28 + } 29 + 30 + # Resolve the full path to the script's directory 31 + REAL_PATH="$(dirname "$(readlink -f "$0")")" 32 + PARENT_DIR="$(dirname "$REAL_PATH")" 33 + CATEGORY="git.scripts" 34 + 35 + HELPS_DIR="$PARENT_DIR/helps/$CATEGORY" 36 + HELP_FILE="$(basename "$0" .sh)_help.sh" 37 + 38 + UTILS_DIR="$PARENT_DIR/utils" 39 + 40 + # Import necessary variables and functions 41 + source "$UTILS_DIR/check_git.sh" 42 + source "$UTILS_DIR/check_branch.sh" 43 + source "$UTILS_DIR/setup_git.sh" 44 + source "$UTILS_DIR/check_sudo.sh" 45 + source "$UTILS_DIR/colors.sh" 46 + source "$UTILS_DIR/usage.sh" 47 + 48 + # Import help file 49 + source "$HELPS_DIR/$HELP_FILE" 50 + 51 + # Usage function to display help 52 + function usage { 53 + show_help "Usage" "${gmb_arguments[@]}" 54 + show_help "Description" "${gmb_descriptions[@]}" 55 + show_help "Options" "${gmb_options[@]}" 56 + show_help "Examples" "${gmb_extras[@]}" 57 + exit 0 58 + } 59 + 60 + # Check if --help is the first argument 61 + [ "$1" = "--help" ] && usage 62 + 63 + # prompt for sudo 64 + # password if required 65 + allow_sudo 66 + 67 + # Setting up git 68 + setup_git 69 + 70 + # Call gmb function 71 + gmb "$@"
+64
git.scripts/gnm.sh
··· 1 + #!/bin/bash 2 + 3 + function gnm { 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 + echo "${BOLD}${RESET_COLOR} Please pass the new name of '$current_branch' branch as argument " 11 + return 0 12 + fi 13 + 14 + current_branch=$(git branch | awk '/\*/ {print $2}') 15 + 16 + if [ $# -eq 1 ]; then 17 + git branch -M $current_branch "$1" 18 + return 0 19 + fi 20 + 21 + echo "${BOLD}${RESET_COLOR} Usage : gnm new_name_of_the_branch" 22 + } 23 + 24 + # Resolve the full path to the script's directory 25 + REAL_PATH="$(dirname "$(readlink -f "$0")")" 26 + PARENT_DIR="$(dirname "$REAL_PATH")" 27 + CATEGORY="git.scripts" 28 + 29 + HELPS_DIR="$PARENT_DIR/helps/$CATEGORY" 30 + HELP_FILE="$(basename "$0" .sh)_help.sh" 31 + 32 + UTILS_DIR="$PARENT_DIR/utils" 33 + 34 + # Import necessary variables and functions 35 + source "$UTILS_DIR/check_git.sh" 36 + source "$UTILS_DIR/setup_git.sh" 37 + source "$UTILS_DIR/check_sudo.sh" 38 + source "$UTILS_DIR/colors.sh" 39 + source "$UTILS_DIR/usage.sh" 40 + 41 + # Import help file 42 + source "$HELPS_DIR/$HELP_FILE" 43 + 44 + # Usage function to display help 45 + function usage { 46 + show_help "Usage" "${gnm_arguments[@]}" 47 + show_help "Description" "${gnm_descriptions[@]}" 48 + show_help "Options" "${gnm_options[@]}" 49 + show_help "Examples" "${gnm_extras[@]}" 50 + exit 0 51 + } 52 + 53 + # Check if --help is the first argument 54 + [ "$1" = "--help" ] && usage 55 + 56 + # prompt for sudo 57 + # password if required 58 + allow_sudo 59 + 60 + # Setting up git 61 + setup_git 62 + 63 + # Call gnm function 64 + gnm "$@"
+77
git.scripts/gpl.sh
··· 1 + #!/bin/bash 2 + 3 + function gpl { 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 + # check if it has a remote to push 10 + if ! has_remote; then 11 + repo_name=$(basename "$(git rev-parse --show-toplevel)") 12 + echo "${BOLD} The repo ${LIGHT_BLUE}$repo_name ${RESET_COLOR}has ${RED}no remote" 13 + return 0 14 + fi 15 + 16 + repo_url=$(git config --get remote.origin.url) 17 + repo_name="$(echo "$repo_url" | awk -F '/' '{print $NF}' | sed 's/.git$//')" 18 + current_branch=$(git branch | awk '/\*/ {print $2}') 19 + is_remote_branch=$(git branch -r | grep "origin/$current_branch") 20 + 21 + # check if the current branch has remote 22 + if [ -z "$is_remote_branch" ]; then 23 + echo "${BOLD} The remote repo ${LIGHT_BLUE}$repo_name" \ 24 + "${RESET_COLOR}has no branch named ${GREEN}$current_branch ${RESET_COLOR}!" 25 + return 0 26 + fi 27 + 28 + # Pull changes from remote branch 29 + git pull origin $current_branch 30 + } 31 + 32 + # Resolve the full path to the script's directory 33 + REAL_PATH="$(dirname "$(readlink -f "$0")")" 34 + PARENT_DIR="$(dirname "$REAL_PATH")" 35 + CATEGORY="git.scripts" 36 + 37 + HELPS_DIR="$PARENT_DIR/helps/$CATEGORY" 38 + HELP_FILE="$(basename "$0" .sh)_help.sh" 39 + 40 + UTILS_DIR="$PARENT_DIR/utils" 41 + 42 + # Import necessary variables and functions 43 + source "$UTILS_DIR/check_connection.sh" 44 + source "$UTILS_DIR/check_remote.sh" 45 + source "$UTILS_DIR/check_git.sh" 46 + source "$UTILS_DIR/setup_git.sh" 47 + source "$UTILS_DIR/check_sudo.sh" 48 + source "$UTILS_DIR/colors.sh" 49 + source "$UTILS_DIR/usage.sh" 50 + 51 + # Import help file 52 + source "$HELPS_DIR/$HELP_FILE" 53 + 54 + # Usage function to display help 55 + function usage { 56 + show_help "Usage" "${gpl_arguments[@]}" 57 + show_help "Description" "${gpl_descriptions[@]}" 58 + show_help "Options" "${gpl_options[@]}" 59 + show_extra "${gpl_extras[@]}" 60 + exit 0 61 + } 62 + 63 + # Check if --help is the first argument 64 + [ "$1" = "--help" ] && usage 65 + 66 + # prompt for sudo 67 + # password if required 68 + allow_sudo 69 + 70 + # Setting up git 71 + setup_git 72 + 73 + # Check for internet connectivity to GitHub 74 + check_connection 75 + 76 + # Call gpl function 77 + gpl
+69
git.scripts/gpsh.sh
··· 1 + #!/bin/bash 2 + 3 + function gpsh { 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 + # Get the repo name 10 + repo_name=$(basename "$(git rev-parse --show-toplevel)") 11 + 12 + # check if it has a remote to push 13 + if ! has_remote; then 14 + echo "${BOLD} The repo ${LIGHT_BLUE}$repo_name ${RESET_COLOR}has ${RED}no remote" 15 + return 0 16 + fi 17 + 18 + current_branch=$(git branch | awk '/\*/ {print $2}') 19 + 20 + # Push changes to remote branch 21 + git push origin $current_branch 22 + } 23 + 24 + # Resolve the full path to the script's directory 25 + REAL_PATH="$(dirname "$(readlink -f "$0")")" 26 + PARENT_DIR="$(dirname "$REAL_PATH")" 27 + CATEGORY="git.scripts" 28 + 29 + HELPS_DIR="$PARENT_DIR/helps/$CATEGORY" 30 + HELP_FILE="$(basename "$0" .sh)_help.sh" 31 + 32 + UTILS_DIR="$PARENT_DIR/utils" 33 + 34 + # Import necessary variables and functions 35 + source "$UTILS_DIR/check_connection.sh" 36 + source "$UTILS_DIR/check_remote.sh" 37 + source "$UTILS_DIR/check_git.sh" 38 + source "$UTILS_DIR/setup_git.sh" 39 + source "$UTILS_DIR/check_sudo.sh" 40 + source "$UTILS_DIR/colors.sh" 41 + source "$UTILS_DIR/usage.sh" 42 + 43 + # Import help file 44 + source "$HELPS_DIR/$HELP_FILE" 45 + 46 + # Usage function to display help 47 + function usage { 48 + show_help "Usage" "${gpsh_arguments[@]}" 49 + show_help "Description" "${gpsh_descriptions[@]}" 50 + show_help "Options" "${gpsh_options[@]}" 51 + show_help "${gpsh_extras[@]}" 52 + exit 0 53 + } 54 + 55 + # Check if --help is the first argument 56 + [ "$1" = "--help" ] && usage 57 + 58 + # prompt for sudo 59 + # password if required 60 + allow_sudo 61 + 62 + # Setting up git 63 + setup_git 64 + 65 + # Check for internet connectivity to GitHub 66 + check_connection 67 + 68 + # Call gpsh function 69 + gpsh
+76
git.scripts/grst.sh
··· 1 + #!/bin/bash 2 + 3 + function grst { 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 + if [ -f "$1" ]; then 15 + git reset "$1" 16 + return 0 17 + fi 18 + 19 + if [ $1 = "cmt" ]; then 20 + git reset --soft HEAD~1 21 + return 0 22 + fi 23 + 24 + # Loop through each argument and check if it's a file 25 + for arg in "$@"; do 26 + if [ ! -f "$arg" ]; then 27 + echo "${BOLD}${RESET_COLOR} Sorry, only restore file(s). ${LIGHT_BLUE}'$arg'${RESET_COLOR} is not a valid file." 28 + exit 1 29 + fi 30 + done 31 + 32 + # If all arguments are valid files, restore them 33 + git restore "$@" 34 + } 35 + 36 + # Resolve the full path to the script's directory 37 + REAL_PATH="$(dirname "$(readlink -f "$0")")" 38 + PARENT_DIR="$(dirname "$REAL_PATH")" 39 + CATEGORY="git.scripts" 40 + 41 + HELPS_DIR="$PARENT_DIR/helps/$CATEGORY" 42 + HELP_FILE="$(basename "$0" .sh)_help.sh" 43 + 44 + UTILS_DIR="$PARENT_DIR/utils" 45 + 46 + # Import necessary variables and functions 47 + source "$UTILS_DIR/check_git.sh" 48 + source "$UTILS_DIR/setup_git.sh" 49 + source "$UTILS_DIR/check_sudo.sh" 50 + source "$UTILS_DIR/colors.sh" 51 + source "$UTILS_DIR/usage.sh" 52 + 53 + # Import help file 54 + source "$HELPS_DIR/$HELP_FILE" 55 + 56 + # Usage function to display help 57 + function usage { 58 + show_help "Usage" "${grst_arguments[@]}" 59 + show_help "Description" "${grst_descriptions[@]}" 60 + show_help "Options" "${grst_options[@]}" 61 + show_extra "${grst_extras[@]}" 62 + exit 0 63 + } 64 + 65 + # Check if --help is the first argument 66 + [ "$1" = "--help" ] && usage 67 + 68 + # prompt for sudo 69 + # password if required 70 + allow_sudo 71 + 72 + # Setting up git 73 + setup_git 74 + 75 + # Call grst function 76 + grst "$@"
+53
git.scripts/gst.sh
··· 1 + #!/bin/bash 2 + 3 + function gst { 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 + # Get the status 10 + git status -s 11 + } 12 + 13 + # Resolve the full path to the script's directory 14 + REAL_PATH="$(dirname "$(readlink -f "$0")")" 15 + PARENT_DIR="$(dirname "$REAL_PATH")" 16 + CATEGORY="git.scripts" 17 + 18 + HELPS_DIR="$PARENT_DIR/helps/$CATEGORY" 19 + HELP_FILE="$(basename "$0" .sh)_help.sh" 20 + 21 + UTILS_DIR="$PARENT_DIR/utils" 22 + 23 + # Import necessary variables and functions 24 + source "$UTILS_DIR/check_git.sh" 25 + source "$UTILS_DIR/setup_git.sh" 26 + source "$UTILS_DIR/check_sudo.sh" 27 + source "$UTILS_DIR/colors.sh" 28 + source "$UTILS_DIR/usage.sh" 29 + 30 + # Import help file 31 + source "$HELPS_DIR/$HELP_FILE" 32 + 33 + # Usage function to display help 34 + function usage { 35 + show_help "Usage" "${gst_arguments[@]}" 36 + show_help "Description" "${gst_descriptions[@]}" 37 + show_help "Options" "${gst_options[@]}" 38 + show_extra "${gst_extras[@]}" 39 + exit 0 40 + } 41 + 42 + # Check if --help is the first argument 43 + [ "$1" = "--help" ] && usage 44 + 45 + # prompt for sudo 46 + # password if required 47 + allow_sudo 48 + 49 + # Setting up git 50 + setup_git 51 + 52 + # Call gst function 53 + gst
-71
git_scripts/gad.sh
··· 1 - #!/bin/bash 2 - 3 - function gad { 4 - if ! is_a_git_repo; then 5 - echo "${BOLD} This won't work, you are not in a git repo!${RESET}" 6 - return 0 7 - fi 8 - 9 - if [ $# -eq 0 ]; then 10 - # If no arguments, add all changes and commit (opens editor for commit message) 11 - git add --all && git commit 12 - return 0 13 - fi 14 - 15 - if [ $# -lt 1 ]; then 16 - # File is specified but no commit message 17 - echo "${BOLD}${RED}Error: no commit message!${RESET}" 18 - return 0 19 - fi 20 - 21 - if [ -f "$1" ]; then 22 - # Add the file and commit with message from arguments 2 onwards 23 - git add "$1" && git commit "$1" -m "${*:2}" 24 - return 0 25 - fi 26 - 27 - # Add all changes and commit with the provided message 28 - git add --all && git commit -m "$*" 29 - } 30 - 31 - # Resolve the full path to the script's directory 32 - REAL_PATH="$(dirname "$(readlink -f "$0")")" 33 - PARENT_DIR="$(dirname "$REAL_PATH")" 34 - CATEGORY="git_scripts" 35 - 36 - HELPS_DIR="$PARENT_DIR/helps/$CATEGORY" 37 - HELP_FILE="$(basename "$0" .sh)_help.sh" 38 - 39 - UTILS_DIR="$PARENT_DIR/utils" 40 - 41 - # Import necessary variables and functions 42 - source "$UTILS_DIR/check_git.sh" 43 - source "$UTILS_DIR/setup_git.sh" 44 - source "$UTILS_DIR/check_sudo.sh" 45 - source "$UTILS_DIR/colors.sh" 46 - source "$UTILS_DIR/usage.sh" 47 - 48 - # Import help file 49 - source "$HELPS_DIR/$HELP_FILE" 50 - 51 - # Usage function to display help 52 - function usage { 53 - show_help "Usage" "${gad_arguments[@]}" 54 - show_help "Description" "${gad_descriptions[@]}" 55 - show_help "Options" "${gad_options[@]}" 56 - show_extra "${gad_extras[@]}" 57 - exit 0 58 - } 59 - 60 - # Check if --help is the first argument 61 - [ "$1" = "--help" ] && usage 62 - 63 - # prompt for sudo 64 - # password if required 65 - allow_sudo 66 - 67 - # Setting up git 68 - setup_git 69 - 70 - # Call gad function 71 - gad "$@"
-58
git_scripts/gcb.sh
··· 1 - #!/bin/bash 2 - 3 - function 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 19 - REAL_PATH="$(dirname "$(readlink -f "$0")")" 20 - PARENT_DIR="$(dirname "$REAL_PATH")" 21 - CATEGORY="git_scripts" 22 - 23 - HELPS_DIR="$PARENT_DIR/helps/$CATEGORY" 24 - HELP_FILE="$(basename "$0" .sh)_help.sh" 25 - 26 - UTILS_DIR="$PARENT_DIR/utils" 27 - 28 - # Import necessary variables and functions 29 - source "$UTILS_DIR/check_git.sh" 30 - source "$UTILS_DIR/setup_git.sh" 31 - source "$UTILS_DIR/check_sudo.sh" 32 - source "$UTILS_DIR/colors.sh" 33 - source "$UTILS_DIR/usage.sh" 34 - 35 - # Import help file 36 - source "$HELPS_DIR/$HELP_FILE" 37 - 38 - # Usage function to display help 39 - function 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 52 - allow_sudo 53 - 54 - # Setting up git 55 - setup_git 56 - 57 - # Call gcb function 58 - gcb
-52
git_scripts/gdf.sh
··· 1 - #!/bin/bash 2 - 3 - function 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 13 - REAL_PATH="$(dirname "$(readlink -f "$0")")" 14 - PARENT_DIR="$(dirname "$REAL_PATH")" 15 - CATEGORY="git_scripts" 16 - 17 - HELPS_DIR="$PARENT_DIR/helps/$CATEGORY" 18 - HELP_FILE="$(basename "$0" .sh)_help.sh" 19 - 20 - UTILS_DIR="$PARENT_DIR/utils" 21 - 22 - # Import necessary variables and functions 23 - source "$UTILS_DIR/check_git.sh" 24 - source "$UTILS_DIR/setup_git.sh" 25 - source "$UTILS_DIR/check_sudo.sh" 26 - source "$UTILS_DIR/colors.sh" 27 - source "$UTILS_DIR/usage.sh" 28 - 29 - # Import help file 30 - source "$HELPS_DIR/$HELP_FILE" 31 - 32 - # Usage function to display help 33 - function 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 46 - allow_sudo 47 - 48 - # Setting up git 49 - setup_git 50 - 51 - # Call gdf function 52 - gdf "$@"
-84
git_scripts/glc.sh
··· 1 - #!/bin/bash 2 - 3 - function glc { 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 - has_commits=$(git log > /dev/null 2>&1 && echo "true" || echo "false") 10 - 11 - if [ "$has_commits" = "false" ]; then 12 - echo "${BOLD} Sorry, no commits yet inside this repo !"; 13 - return 0 14 - fi 15 - 16 - repo_name=$(basename "$(git rev-parse --show-toplevel)") 17 - current_branch=$(git branch | awk '/\*/ {print $2}'); 18 - commits_num=$(git log --oneline | wc -l); 19 - last_commit=$(git log --format="%H" -n 1); 20 - last_commit_message=$(git show --format=%B -s "$last_commit" | head -n 1); 21 - last_commit_author=$(git log --format='%an' -n 1) 22 - current_user=$(git config user.name) 23 - commits_done_today=$(git log --oneline --since="$(date +"%Y-%m-%d 00:00:00")" --author="$current_user" | wc -l) 24 - commits_contrib_today=$(git log --oneline --since="$(date +"%Y-%m-%d 00:00:00")" --author="$last_commit_author" | wc -l) 25 - 26 - [ $commits_num -le 1 ] && commit_text="commit" || commit_text="commits"; 27 - [ $commits_done_today -le 1 ] && commit_done_text="commit" || commit_done_text="commits"; 28 - [ $commits_contrib_today -le 1 ] && commit_contrib_text="commit" || commit_contrib_text="commits"; 29 - [ $commits_done_today -gt 0 ] && 30 - commit_done="${RESET_COLOR}Including ${LIGHT_BLUE}$commits_done_today $commit_done_text ${RESET_COLOR}by ${GREEN}$current_user ${RESET_COLOR}today" || 31 - commit_done="${RESET_COLOR}Including ${LIGHT_BLUE}$commits_contrib_today $commit_contrib_text ${RESET_COLOR}by ${GREEN}$last_commit_author ${RESET_COLOR}today" 32 - 33 - if [ "$1" = "show" ]; then 34 - git log --oneline --no-decorate; 35 - return 0 36 - fi 37 - 38 - echo "${BOLD}${LIGHT_BLUE} $repo_name ${RESET_COLOR}has ${LIGHT_BLUE}$commits_num $commit_text "; 39 - echo " $commit_done"; 40 - echo "${BOLD}${RESET_COLOR} Last Commit on ${GREEN}$current_branch ${RESET_COLOR}: $last_commit_message"; 41 - echo 42 - } 43 - 44 - # Resolve the full path to the script's directory 45 - REAL_PATH="$(dirname "$(readlink -f "$0")")" 46 - PARENT_DIR="$(dirname "$REAL_PATH")" 47 - CATEGORY="git_scripts" 48 - 49 - HELPS_DIR="$PARENT_DIR/helps/$CATEGORY" 50 - HELP_FILE="$(basename "$0" .sh)_help.sh" 51 - 52 - UTILS_DIR="$PARENT_DIR/utils" 53 - 54 - # Import necessary variables and functions 55 - source "$UTILS_DIR/check_git.sh" 56 - source "$UTILS_DIR/setup_git.sh" 57 - source "$UTILS_DIR/check_sudo.sh" 58 - source "$UTILS_DIR/colors.sh" 59 - source "$UTILS_DIR/usage.sh" 60 - 61 - # Import help file 62 - source "$HELPS_DIR/$HELP_FILE" 63 - 64 - # Usage function to display help 65 - function usage { 66 - show_help "Usage" "${glc_arguments[@]}" 67 - show_help "Description" "${glc_descriptions[@]}" 68 - show_help "Options" "${glc_options[@]}" 69 - show_extra "${glc_extras[@]}" 70 - exit 0 71 - } 72 - 73 - # Check if --help is the first argument 74 - [ "$1" = "--help" ] && usage 75 - 76 - # prompt for sudo 77 - # password if required 78 - allow_sudo 79 - 80 - # Setting up git 81 - setup_git 82 - 83 - # Call glc function 84 - glc "$@"
-71
git_scripts/gmb.sh
··· 1 - #!/bin/bash 2 - 3 - function gmb { 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 - if [ $# -eq 0 ]; then 10 - echo "${BOLD} Fatal ! Specify the Branch to merge to $current_branch" 11 - return 0 12 - fi 13 - 14 - current_branch=$(git branch | awk '/\*/ {print $2}') 15 - 16 - # check if the branch doesn't exist 17 - if ! is_a_git_branch "$1"; then 18 - echo "${BOLD} Fatal ! $1 is a Non Existing branch " 19 - return 0 20 - fi 21 - 22 - if [ "$current_branch" = "$1" ]; then 23 - echo "${BOLD} Fatal ! Cannot Merge Identical Branch " 24 - return 0 25 - fi 26 - 27 - git merge "$1" 28 - } 29 - 30 - # Resolve the full path to the script's directory 31 - REAL_PATH="$(dirname "$(readlink -f "$0")")" 32 - PARENT_DIR="$(dirname "$REAL_PATH")" 33 - CATEGORY="git_scripts" 34 - 35 - HELPS_DIR="$PARENT_DIR/helps/$CATEGORY" 36 - HELP_FILE="$(basename "$0" .sh)_help.sh" 37 - 38 - UTILS_DIR="$PARENT_DIR/utils" 39 - 40 - # Import necessary variables and functions 41 - source "$UTILS_DIR/check_git.sh" 42 - source "$UTILS_DIR/check_branch.sh" 43 - source "$UTILS_DIR/setup_git.sh" 44 - source "$UTILS_DIR/check_sudo.sh" 45 - source "$UTILS_DIR/colors.sh" 46 - source "$UTILS_DIR/usage.sh" 47 - 48 - # Import help file 49 - source "$HELPS_DIR/$HELP_FILE" 50 - 51 - # Usage function to display help 52 - function usage { 53 - show_help "Usage" "${gmb_arguments[@]}" 54 - show_help "Description" "${gmb_descriptions[@]}" 55 - show_help "Options" "${gmb_options[@]}" 56 - show_help "Examples" "${gmb_extras[@]}" 57 - exit 0 58 - } 59 - 60 - # Check if --help is the first argument 61 - [ "$1" = "--help" ] && usage 62 - 63 - # prompt for sudo 64 - # password if required 65 - allow_sudo 66 - 67 - # Setting up git 68 - setup_git 69 - 70 - # Call gmb function 71 - gmb "$@"
-64
git_scripts/gnm.sh
··· 1 - #!/bin/bash 2 - 3 - function gnm { 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 - echo "${BOLD}${RESET_COLOR} Please pass the new name of '$current_branch' branch as argument " 11 - return 0 12 - fi 13 - 14 - current_branch=$(git branch | awk '/\*/ {print $2}') 15 - 16 - if [ $# -eq 1 ]; then 17 - git branch -M $current_branch "$1" 18 - return 0 19 - fi 20 - 21 - echo "${BOLD}${RESET_COLOR} Usage : gnm new_name_of_the_branch" 22 - } 23 - 24 - # Resolve the full path to the script's directory 25 - REAL_PATH="$(dirname "$(readlink -f "$0")")" 26 - PARENT_DIR="$(dirname "$REAL_PATH")" 27 - CATEGORY="git_scripts" 28 - 29 - HELPS_DIR="$PARENT_DIR/helps/$CATEGORY" 30 - HELP_FILE="$(basename "$0" .sh)_help.sh" 31 - 32 - UTILS_DIR="$PARENT_DIR/utils" 33 - 34 - # Import necessary variables and functions 35 - source "$UTILS_DIR/check_git.sh" 36 - source "$UTILS_DIR/setup_git.sh" 37 - source "$UTILS_DIR/check_sudo.sh" 38 - source "$UTILS_DIR/colors.sh" 39 - source "$UTILS_DIR/usage.sh" 40 - 41 - # Import help file 42 - source "$HELPS_DIR/$HELP_FILE" 43 - 44 - # Usage function to display help 45 - function usage { 46 - show_help "Usage" "${gnm_arguments[@]}" 47 - show_help "Description" "${gnm_descriptions[@]}" 48 - show_help "Options" "${gnm_options[@]}" 49 - show_help "Examples" "${gnm_extras[@]}" 50 - exit 0 51 - } 52 - 53 - # Check if --help is the first argument 54 - [ "$1" = "--help" ] && usage 55 - 56 - # prompt for sudo 57 - # password if required 58 - allow_sudo 59 - 60 - # Setting up git 61 - setup_git 62 - 63 - # Call gnm function 64 - gnm "$@"
-77
git_scripts/gpl.sh
··· 1 - #!/bin/bash 2 - 3 - function gpl { 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 - # check if it has a remote to push 10 - if ! has_remote; then 11 - repo_name=$(basename "$(git rev-parse --show-toplevel)") 12 - echo "${BOLD} The repo ${LIGHT_BLUE}$repo_name ${RESET_COLOR}has ${RED}no remote" 13 - return 0 14 - fi 15 - 16 - repo_url=$(git config --get remote.origin.url) 17 - repo_name="$(echo "$repo_url" | awk -F '/' '{print $NF}' | sed 's/.git$//')" 18 - current_branch=$(git branch | awk '/\*/ {print $2}') 19 - is_remote_branch=$(git branch -r | grep "origin/$current_branch") 20 - 21 - # check if the current branch has remote 22 - if [ -z "$is_remote_branch" ]; then 23 - echo "${BOLD} The remote repo ${LIGHT_BLUE}$repo_name" \ 24 - "${RESET_COLOR}has no branch named ${GREEN}$current_branch ${RESET_COLOR}!" 25 - return 0 26 - fi 27 - 28 - # Pull changes from remote branch 29 - git pull origin $current_branch 30 - } 31 - 32 - # Resolve the full path to the script's directory 33 - REAL_PATH="$(dirname "$(readlink -f "$0")")" 34 - PARENT_DIR="$(dirname "$REAL_PATH")" 35 - CATEGORY="git_scripts" 36 - 37 - HELPS_DIR="$PARENT_DIR/helps/$CATEGORY" 38 - HELP_FILE="$(basename "$0" .sh)_help.sh" 39 - 40 - UTILS_DIR="$PARENT_DIR/utils" 41 - 42 - # Import necessary variables and functions 43 - source "$UTILS_DIR/check_connection.sh" 44 - source "$UTILS_DIR/check_remote.sh" 45 - source "$UTILS_DIR/check_git.sh" 46 - source "$UTILS_DIR/setup_git.sh" 47 - source "$UTILS_DIR/check_sudo.sh" 48 - source "$UTILS_DIR/colors.sh" 49 - source "$UTILS_DIR/usage.sh" 50 - 51 - # Import help file 52 - source "$HELPS_DIR/$HELP_FILE" 53 - 54 - # Usage function to display help 55 - function usage { 56 - show_help "Usage" "${gpl_arguments[@]}" 57 - show_help "Description" "${gpl_descriptions[@]}" 58 - show_help "Options" "${gpl_options[@]}" 59 - show_extra "${gpl_extras[@]}" 60 - exit 0 61 - } 62 - 63 - # Check if --help is the first argument 64 - [ "$1" = "--help" ] && usage 65 - 66 - # prompt for sudo 67 - # password if required 68 - allow_sudo 69 - 70 - # Setting up git 71 - setup_git 72 - 73 - # Check for internet connectivity to GitHub 74 - check_connection 75 - 76 - # Call gpl function 77 - gpl
-69
git_scripts/gpsh.sh
··· 1 - #!/bin/bash 2 - 3 - function gpsh { 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 - # Get the repo name 10 - repo_name=$(basename "$(git rev-parse --show-toplevel)") 11 - 12 - # check if it has a remote to push 13 - if ! has_remote; then 14 - echo "${BOLD} The repo ${LIGHT_BLUE}$repo_name ${RESET_COLOR}has ${RED}no remote" 15 - return 0 16 - fi 17 - 18 - current_branch=$(git branch | awk '/\*/ {print $2}') 19 - 20 - # Push changes to remote branch 21 - git push origin $current_branch 22 - } 23 - 24 - # Resolve the full path to the script's directory 25 - REAL_PATH="$(dirname "$(readlink -f "$0")")" 26 - PARENT_DIR="$(dirname "$REAL_PATH")" 27 - CATEGORY="git_scripts" 28 - 29 - HELPS_DIR="$PARENT_DIR/helps/$CATEGORY" 30 - HELP_FILE="$(basename "$0" .sh)_help.sh" 31 - 32 - UTILS_DIR="$PARENT_DIR/utils" 33 - 34 - # Import necessary variables and functions 35 - source "$UTILS_DIR/check_connection.sh" 36 - source "$UTILS_DIR/check_remote.sh" 37 - source "$UTILS_DIR/check_git.sh" 38 - source "$UTILS_DIR/setup_git.sh" 39 - source "$UTILS_DIR/check_sudo.sh" 40 - source "$UTILS_DIR/colors.sh" 41 - source "$UTILS_DIR/usage.sh" 42 - 43 - # Import help file 44 - source "$HELPS_DIR/$HELP_FILE" 45 - 46 - # Usage function to display help 47 - function usage { 48 - show_help "Usage" "${gpsh_arguments[@]}" 49 - show_help "Description" "${gpsh_descriptions[@]}" 50 - show_help "Options" "${gpsh_options[@]}" 51 - show_help "${gpsh_extras[@]}" 52 - exit 0 53 - } 54 - 55 - # Check if --help is the first argument 56 - [ "$1" = "--help" ] && usage 57 - 58 - # prompt for sudo 59 - # password if required 60 - allow_sudo 61 - 62 - # Setting up git 63 - setup_git 64 - 65 - # Check for internet connectivity to GitHub 66 - check_connection 67 - 68 - # Call gpsh function 69 - gpsh
-76
git_scripts/grst.sh
··· 1 - #!/bin/bash 2 - 3 - function grst { 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 - if [ -f "$1" ]; then 15 - git reset "$1" 16 - return 0 17 - fi 18 - 19 - if [ $1 = "cmt" ]; then 20 - git reset --soft HEAD~1 21 - return 0 22 - fi 23 - 24 - # Loop through each argument and check if it's a file 25 - for arg in "$@"; do 26 - if [ ! -f "$arg" ]; then 27 - echo "${BOLD}${RESET_COLOR} Sorry, only restore file(s). ${LIGHT_BLUE}'$arg'${RESET_COLOR} is not a valid file." 28 - exit 1 29 - fi 30 - done 31 - 32 - # If all arguments are valid files, restore them 33 - git restore "$@" 34 - } 35 - 36 - # Resolve the full path to the script's directory 37 - REAL_PATH="$(dirname "$(readlink -f "$0")")" 38 - PARENT_DIR="$(dirname "$REAL_PATH")" 39 - CATEGORY="git_scripts" 40 - 41 - HELPS_DIR="$PARENT_DIR/helps/$CATEGORY" 42 - HELP_FILE="$(basename "$0" .sh)_help.sh" 43 - 44 - UTILS_DIR="$PARENT_DIR/utils" 45 - 46 - # Import necessary variables and functions 47 - source "$UTILS_DIR/check_git.sh" 48 - source "$UTILS_DIR/setup_git.sh" 49 - source "$UTILS_DIR/check_sudo.sh" 50 - source "$UTILS_DIR/colors.sh" 51 - source "$UTILS_DIR/usage.sh" 52 - 53 - # Import help file 54 - source "$HELPS_DIR/$HELP_FILE" 55 - 56 - # Usage function to display help 57 - function usage { 58 - show_help "Usage" "${grst_arguments[@]}" 59 - show_help "Description" "${grst_descriptions[@]}" 60 - show_help "Options" "${grst_options[@]}" 61 - show_extra "${grst_extras[@]}" 62 - exit 0 63 - } 64 - 65 - # Check if --help is the first argument 66 - [ "$1" = "--help" ] && usage 67 - 68 - # prompt for sudo 69 - # password if required 70 - allow_sudo 71 - 72 - # Setting up git 73 - setup_git 74 - 75 - # Call grst function 76 - grst "$@"
-53
git_scripts/gst.sh
··· 1 - #!/bin/bash 2 - 3 - function gst { 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 - # Get the status 10 - git status -s 11 - } 12 - 13 - # Resolve the full path to the script's directory 14 - REAL_PATH="$(dirname "$(readlink -f "$0")")" 15 - PARENT_DIR="$(dirname "$REAL_PATH")" 16 - CATEGORY="git_scripts" 17 - 18 - HELPS_DIR="$PARENT_DIR/helps/$CATEGORY" 19 - HELP_FILE="$(basename "$0" .sh)_help.sh" 20 - 21 - UTILS_DIR="$PARENT_DIR/utils" 22 - 23 - # Import necessary variables and functions 24 - source "$UTILS_DIR/check_git.sh" 25 - source "$UTILS_DIR/setup_git.sh" 26 - source "$UTILS_DIR/check_sudo.sh" 27 - source "$UTILS_DIR/colors.sh" 28 - source "$UTILS_DIR/usage.sh" 29 - 30 - # Import help file 31 - source "$HELPS_DIR/$HELP_FILE" 32 - 33 - # Usage function to display help 34 - function usage { 35 - show_help "Usage" "${gst_arguments[@]}" 36 - show_help "Description" "${gst_descriptions[@]}" 37 - show_help "Options" "${gst_options[@]}" 38 - show_extra "${gst_extras[@]}" 39 - exit 0 40 - } 41 - 42 - # Check if --help is the first argument 43 - [ "$1" = "--help" ] && usage 44 - 45 - # prompt for sudo 46 - # password if required 47 - allow_sudo 48 - 49 - # Setting up git 50 - setup_git 51 - 52 - # Call gst function 53 - gst
helps/gh_scripts/gbd_help.sh helps/gh.scripts/gbd_help.sh
helps/gh_scripts/gck_help.sh helps/gh.scripts/gck_help.sh
helps/gh_scripts/gcln_help.sh helps/gh.scripts/gcln_help.sh
helps/gh_scripts/ghadd_help.sh helps/gh.scripts/ghadd_help.sh
helps/gh_scripts/ghc_help.sh helps/gh.scripts/ghc_help.sh
helps/gh_scripts/ghcls_help.sh helps/gh.scripts/ghcls_help.sh
helps/gh_scripts/ghd_help.sh helps/gh.scripts/ghd_help.sh
helps/gh_scripts/ghdel_help.sh helps/gh.scripts/ghdel_help.sh
helps/gh_scripts/ghf_help.sh helps/gh.scripts/ghf_help.sh
+2 -2
helps/gh_scripts/ghnm_help.sh helps/gh.scripts/ghnm_help.sh
··· 19 19 20 20 # Extra help 21 21 ghnm_extras=( 22 - "ghnm source_controller" 23 - "This will rename the current repo to ${LIGHT_BLUE}source_controller ${RESET}" 22 + "ghnm source.controller" 23 + "This will rename the current repo to ${LIGHT_BLUE}source.controller ${RESET}" 24 24 )
helps/gh_scripts/ghv_help.sh helps/gh.scripts/ghv_help.sh
helps/git_scripts/gad_help.sh helps/git.scripts/gad_help.sh
helps/git_scripts/gcb_help.sh helps/git.scripts/gcb_help.sh
helps/git_scripts/gdf_help.sh helps/git.scripts/gdf_help.sh
helps/git_scripts/glc_help.sh helps/git.scripts/glc_help.sh
helps/git_scripts/gmb_help.sh helps/git.scripts/gmb_help.sh
helps/git_scripts/gnm_help.sh helps/git.scripts/gnm_help.sh
helps/git_scripts/gpl_help.sh helps/git.scripts/gpl_help.sh
helps/git_scripts/gpsh_help.sh helps/git.scripts/gpsh_help.sh
helps/git_scripts/grst_help.sh helps/git.scripts/grst_help.sh
helps/git_scripts/gst_help.sh helps/git.scripts/gst_help.sh
+10 -10
setup/help.sh
··· 38 38 source "$UTILS_DIR/colors.sh" 39 39 40 40 # Directories for source and target 41 - GIT_SCRIPTS_DIR="$PARENT_DIR/git_scripts" 42 - GH_SCRIPTS_DIR="$PARENT_DIR/gh_scripts" 41 + git.scripts_DIR="$PARENT_DIR/git.scripts" 42 + gh.scripts_DIR="$PARENT_DIR/gh.scripts" 43 43 44 - HELP_GIT_SCRIPTS_DIR="$PARENT_DIR/helps/git_scripts" 45 - HELP_GH_SCRIPTS_DIR="$PARENT_DIR/helps/gh_scripts" 44 + HELP_git.scripts_DIR="$PARENT_DIR/helps/git.scripts" 45 + HELP_gh.scripts_DIR="$PARENT_DIR/helps/gh.scripts" 46 46 47 47 # Create the directories if they don't exist 48 - mkdir -p "$HELP_GIT_SCRIPTS_DIR" 49 - mkdir -p "$HELP_GH_SCRIPTS_DIR" 48 + mkdir -p "$HELP_git.scripts_DIR" 49 + mkdir -p "$HELP_gh.scripts_DIR" 50 50 51 51 # Function to write help file content 52 52 function write_help_file_content { ··· 78 78 EOL 79 79 } 80 80 81 - # Create help files for git_scripts 81 + # Create help files for git.scripts 82 82 printf "\n${BOLD} Git Scripts Helps...${RESET}\n" 83 - create_help_files "$GIT_SCRIPTS_DIR" "$HELP_GIT_SCRIPTS_DIR" 83 + create_help_files "$git.scripts_DIR" "$HELP_git.scripts_DIR" 84 84 85 85 echo 86 86 87 - # Create help files for gh_scripts 87 + # Create help files for gh.scripts 88 88 printf "${BOLD} Gh Scripts Helps...${RESET}\n" 89 - create_help_files "$GH_SCRIPTS_DIR" "$HELP_GH_SCRIPTS_DIR" 89 + create_help_files "$gh.scripts_DIR" "$HELP_gh.scripts_DIR"
+2 -2
setup/install.sh
··· 7 7 repo_source=$(git rev-parse --show-toplevel) 8 8 9 9 # Define paths to script directories 10 - git_scripts_path="$repo_source/git_scripts" 11 - gh_scripts_path="$repo_source/gh_scripts" 10 + git_scripts_path="$repo_source/git.scripts" 11 + gh_scripts_path="$repo_source/gh.scripts" 12 12 13 13 # Function to extract script name without the .sh extension 14 14 function get_script_name {
+2 -2
setup/uninstall.sh
··· 7 7 repo_source=$(git rev-parse --show-toplevel) 8 8 9 9 # Define paths to script directories 10 - git_scripts_path="$repo_source/git_scripts" 11 - gh_scripts_path="$repo_source/gh_scripts" 10 + git_scripts_path="$repo_source/git.scripts" 11 + gh_scripts_path="$repo_source/gh.scripts" 12 12 13 13 # Function to extract script name without the .sh extension 14 14 function get_script_name {