changed echo coloring for git functions

This commit is contained in:
pika 2025-03-27 12:16:53 +01:00
parent 230877740a
commit 5530994c56
2 changed files with 14 additions and 15 deletions

View file

@ -124,7 +124,7 @@ proxy() {
# ────────────< check network availability and set proxy if in correct network >──────────── # ────────────< check network availability and set proxy if in correct network >────────────
noproxy noproxy
if ping -w2 -q swu.dom; then if ping -c 1 -W 2 swu.dom &>/dev/null; then
proxy --set proxy --set
else else
noproxy noproxy

27
.zshrc
View file

@ -351,50 +351,49 @@ __alias__() {
alias ga="gd $1 && git add" alias ga="gd $1 && git add"
alias gp="git submodule update --init --recursive && git pull --recurse-submodule" alias gp="git submodule update --init --recursive && git pull --recurse-submodule"
alias gms='git maintenance start' alias gms='git maintenance start'
# alias gsu="git submodule foreach git pull && git submodule update --init --recursive && git add . && git commit -m ' update: submodules' && echo '-- Committed changes, pushing now..' && sleep 1 && git push"
alias gcm="git commit -m" alias gcm="git commit -m"
alias gpu="git push --recurse-submodule=on-demand" alias gpu="git push --recurse-submodule=on-demand"
gsu() { gsu() {
echo "${YELLOW}| git submodule update --init --recursive |${NC}" echo "${YELLOW}${BOLD}| git submodule update --init --recursive |${NC}"
git submodule update --init --recursive && git submodule update --init --recursive &&
echo "${CYAN}-- updated submodules recursively${NC}" echo "${CYAN}${BOLD}-- updated submodules recursively${NC}"
echo "${YELLOW}-- Checking submodule branches... --${NC}" echo "${YELLOW}${BOLD}-- Checking submodule branches... --${NC}"
git submodule foreach ' git submodule foreach '
branch=$(git symbolic-ref --short HEAD 2>/dev/null || echo "detached") branch=$(git symbolic-ref --short HEAD 2>/dev/null || echo "detached")
if [ "$branch" = "detached" ]; then if [ "$branch" = "detached" ]; then
default_branch=$(git config -f $toplevel/.gitmodules submodule.$name.branch || echo "main") default_branch=$(git config -f $toplevel/.gitmodules submodule.$name.branch || echo "main")
echo "${RED}Submodule $name is detached. Checking out ${YELLOW} $default_branch${RED}...${NC}" echo "${RED}${BOLD}Submodule $name is detached. Checking out ${YELLOW} $default_branch${RED}...${NC}"
git checkout $default_branch git checkout $default_branch
else else
echo "${GREEN}Submodule $name is on branch $branch.${NC}" echo "${GREEN}${BOLD}Submodule $name is on branch $branch.${NC}"
fi fi
' '
echo "${YELLOW}git submodule foreach git pull --recurse-submodule${NC}" echo "${YELLOW}${BOLD}git submodule foreach git pull --recurse-submodule${NC}"
git submodule foreach git pull --recurse-submodule && git submodule foreach git pull --recurse-submodule &&
echo "${GREEN}-- pulled down submodules recursively --${NC}" echo "${GREEN}${BOLD}-- pulled down submodules recursively --${NC}"
gUpdateModules() { gUpdateModules() {
if ! git diff --exit-code .; then if ! git diff --exit-code .; then
echo "${CYAN}Staging changes...${NC}" echo "${CYAN}${BOLD}Staging changes...${NC}"
git add . || echo "GIT ADD MISSFUNCTION" git add . || echo "GIT ADD MISSFUNCTION"
sleep 0.3 sleep 0.3
if git commit -m " update: submodules"; then if git commit -m " update: submodules"; then
echo "${GREEN}Changes committed successfully.${NC}" echo "${GREEN}${BOLD}Changes committed successfully.${NC}"
else else
echo "${RED}${BOLD}Failed to commit changes.${NC}" echo "${RED}${BOLD}Failed to commit changes.${NC}"
return 1 return 1
fi fi
else else
echo "${GREEN}No changes to commit.${NC}" echo "${GREEN}${BOLD}No changes to commit.${NC}"
return 1 return 1
fi fi
} }
if gUpdateModules; then if gUpdateModules; then
if git push; then if git push; then
echo "${GREEN}Push successful.${NC}" echo "${GREEN}${BOLD}Push successful.${NC}"
else else
echo "${RED}${BOLD}Failed to push changes.${NC}" echo "${RED}${BOLD}Failed to push changes.${NC}"
return 1 return 1
@ -413,12 +412,12 @@ __alias__() {
# Check if there are any changes on the remote branch # Check if there are any changes on the remote branch
if git diff --quiet "$branch" "origin/$branch"; then if git diff --quiet "$branch" "origin/$branch"; then
local commit_message="${1:-wip}" local commit_message="${1:-wip}"
echo "No changes on the remote branch. Adding changes and pushing with '$commit_message' commit." echo "${CYAN}No changes on the remote branch. Adding changes and pushing with ${RED}${BOLD}'$commit_message'${NC}${CYAN} commit.${NC}"
git add . git add .
git commit -m "$commit_message" git commit -m "$commit_message"
git push git push
else else
echo "There are changes on the remote branch. Please pull the latest changes first." echo "${RED}${BOLD}There are changes on the remote branch. Please pull the latest changes first.${NC}"
fi fi
} }