Fixed all colors.. (changed echo -> printf..)

This commit is contained in:
pika 2025-07-07 23:01:17 +02:00
parent f45bc46aa8
commit c842184f95

View file

@ -285,12 +285,10 @@ setup-alias() {
alias gm='git checkout main && git merge' alias gm='git checkout main && git merge'
alias gc="git clone --recurse-submodule" alias gc="git clone --recurse-submodule"
alias gd="git diff" alias gd="git diff"
# alias ga="gd $1 && git add" alias gp='printf "${CYAN}Updating submodules..${NC}\n" && git submodule update --init --recursive && printf "${CYAN}Pulling down submodules..${NC}\n" && git pull --recurse-submodule'
alias gp='echo "${CYAN}Updating submodules..${NC}" && git submodule update --init --recursive && echo "${CYAN}Pulling down submodules..${NC}" && git pull --recurse-submodule'
alias gms='git maintenance start' alias gms='git maintenance start'
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"
# ╭──────────────────────────────────────╮ # ╭──────────────────────────────────────╮
# │ git add with commit like.. │ # │ git add with commit like.. │
# │ `git add "<file>" "<commitmessage>"` │ # │ `git add "<file>" "<commitmessage>"` │
@ -343,49 +341,49 @@ setup-alias() {
# where you JUST want to fetch all the latest changes from all submodules of # where you JUST want to fetch all the latest changes from all submodules of
# one `big` repo # one `big` repo
gsu() { gsu() {
echo "${CYAN}Updating submodules recursively with -> ${YELLOW}${BOLD}git submodule update --init --recursive${NC}" printf "${CYAN}Updating submodules recursively with -> ${YELLOW}${BOLD}git submodule update --init --recursive${NC}\n"
git submodule update --init --recursive && git submodule update --init --recursive &&
echo "${CYAN}${BOLD}-- Updated submodules recursively --${NC}" printf "${CYAN}${BOLD}-- Updated submodules recursively --${NC}\n"
echo "${CYAN}${BOLD}-- Checking submodule branches... --${NC}" printf "${CYAN}${BOLD}-- Checking submodule branches... --${NC}\n"
git submodule foreach ' git submodule foreach '
echo "${RED}Submodule: $name ${NC}" printf "${RED}Submodule: $name ${NC}\n"
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}${BOLD}Submodule $name is detached. Checking out ${YELLOW} $default_branch${RED}...${NC}" printf "${RED}${BOLD}Submodule $name is detached. Checking out ${YELLOW} $default_branch${RED}...${NC}\n"
git checkout $default_branch git checkout $default_branch
else else
echo "${GREEN}${BOLD}Submodule $name is on branch $branch.${NC}" printf "${GREEN}${BOLD}Submodule $name is on branch $branch.${NC}\n"
fi fi
' '
echo "${CYAN}Pulling down updates recursively with -> ${YELLOW}${BOLD}git submodule foreach git pull --recurse-submodule${NC}" printf "${CYAN}Pulling down updates recursively with -> ${YELLOW}${BOLD}git submodule foreach git pull --recurse-submodule${NC}\n"
git submodule foreach git pull --recurse-submodule && git submodule foreach git pull --recurse-submodule &&
echo "${GREEN}${BOLD}-- pulled down submodules recursively --${NC}" printf "${GREEN}${BOLD}-- pulled down submodules recursively --${NC}\n"
gUpdateModules() { gUpdateModules() {
if ! git diff --exit-code .; then if ! git diff --exit-code .; then
echo "${CYAN}${BOLD}Staging changes...${NC}" printf "${CYAN}${BOLD}Staging changes...${NC}\n"
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}${BOLD}commit message ${RED}' update: submodules'${GREEN} successfully commited${NC}" printf "${GREEN}${BOLD}commit message ${RED}' update: submodules'${GREEN} successfully commited${NC}\n"
else else
echo "${RED}${BOLD}Failed to commit changes.${NC}" printf "${RED}${BOLD}Failed to commit changes.${NC}\n"
return 1 return 1
fi fi
else else
echo "${GREEN}${BOLD}No changes to commit.${NC}" printf "${GREEN}${BOLD}No changes to commit.${NC}\n"
return 1 return 1
fi fi
} }
if gUpdateModules; then if gUpdateModules; then
if git push; then if git push; then
echo "${GREEN}${BOLD}Push successful.${NC}" printf "${GREEN}${BOLD}Push successful.${NC}\n"
else else
echo "${RED}${BOLD}Failed to push changes.${NC}" printf "${RED}${BOLD}Failed to push changes.${NC}\n"
return 1 return 1
fi fi
fi fi
@ -401,10 +399,10 @@ setup-alias() {
# $> gwip 'files and folders' 'commit message' # $> gwip 'files and folders' 'commit message'
gwip() { gwip() {
local BOLD GREEN YELLOW NC local BOLD GREEN YELLOW NC
BOLD=$'\e[1m' BOLD='\e[1m'
GREEN=$'\e[92m' GREEN='\e[92m'
YELLOW=$'\e[93m' YELLOW='\e[93m'
NC=$'\e[0m' NC='\e[1m'
# Fetch the latest changes from the remote # Fetch the latest changes from the remote
git fetch git fetch
@ -428,8 +426,8 @@ setup-alias() {
fi fi
done done
else else
echo "${BOLD}${YELLOW}You have to provide the command like..:" printf "${BOLD}${YELLOW}You have to provide the command like..:\n"
echo "${GREEN}'gwip <list of files> <commit message>' or like 'gwip .'${NC}" printf "${GREEN}'gwip <list of files> <commit message>' or like 'gwip .'${NC}\n"
return return
fi fi
@ -443,7 +441,7 @@ setup-alias() {
trimmed_files+=("${f#./}") trimmed_files+=("${f#./}")
done done
echo "${GREEN}Committed files/folders: ${BOLD}${trimmed_files[*]}${NC}" printf "${GREEN}Committed files/folders: ${BOLD}${trimmed_files[*]}${NC}\n"
;; ;;
esac esac
@ -451,7 +449,7 @@ setup-alias() {
[[ -z "$commit_files" ]] && commit_files=. [[ -z "$commit_files" ]] && commit_files=.
[[ -z "$commit_message" ]] && commit_message=wip [[ -z "$commit_message" ]] && commit_message=wip
echo "${CYAN}No changes on the remote branch. Adding changes and pushing with ${RED}${BOLD}'$commit_message'${NC}${CYAN} commit.${NC}" printf "${CYAN}No changes on the remote branch. Adding changes and pushing with ${RED}${BOLD}'$commit_message'${NC}${CYAN} commit.${NC}\n"
if (("${#commit_files}" <= 1)); then if (("${#commit_files}" <= 1)); then
git add $commit_files git add $commit_files
@ -463,13 +461,13 @@ setup-alias() {
git commit -m "${commit_message:-wip}" git commit -m "${commit_message:-wip}"
git push git push
else else
echo "${RED}${BOLD}There was something wrong with:${NC}" printf "${RED}${BOLD}There was something wrong with:${NC}\n"
echo "${YELLOW}- commit-files '$commit_files'" printf "${YELLOW}- commit-files '$commit_files'\n"
echo "or.." echo "or.."
echo "${YELLOW}- commit-message '$commit_message'${NC}" printf "${YELLOW}- commit-message '$commit_message'${NC}\n"
fi fi
else else
echo "${RED}${BOLD}There are changes on the remote branch. Please pull the latest changes first.${NC}" printf "${RED}${BOLD}There are changes on the remote branch. Please pull the latest changes first.${NC}\n"
fi fi
} }
;; ;;