Fixed all colors.. (changed echo -> printf..)
This commit is contained in:
parent
f45bc46aa8
commit
c842184f95
1 changed files with 27 additions and 29 deletions
|
@ -285,12 +285,10 @@ setup-alias() {
|
|||
alias gm='git checkout main && git merge'
|
||||
alias gc="git clone --recurse-submodule"
|
||||
alias gd="git diff"
|
||||
# alias ga="gd $1 && git add"
|
||||
alias gp='echo "${CYAN}Updating submodules..${NC}" && git submodule update --init --recursive && echo "${CYAN}Pulling down submodules..${NC}" && git pull --recurse-submodule'
|
||||
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 gms='git maintenance start'
|
||||
alias gcm="git commit -m"
|
||||
alias gpu="git push --recurse-submodule=on-demand"
|
||||
|
||||
# ╭──────────────────────────────────────╮
|
||||
# │ git add with commit like.. │
|
||||
# │ `git add "<file>" "<commitmessage>"` │
|
||||
|
@ -343,49 +341,49 @@ setup-alias() {
|
|||
# where you JUST want to fetch all the latest changes from all submodules of
|
||||
# one `big` repo
|
||||
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 &&
|
||||
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 '
|
||||
echo "${RED}Submodule: $name ${NC}"
|
||||
printf "${RED}Submodule: $name ${NC}\n"
|
||||
branch=$(git symbolic-ref --short HEAD 2>/dev/null || echo "detached")
|
||||
if [ "$branch" = "detached" ]; then
|
||||
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
|
||||
else
|
||||
echo "${GREEN}${BOLD}Submodule $name is on branch $branch.${NC}"
|
||||
printf "${GREEN}${BOLD}Submodule $name is on branch $branch.${NC}\n"
|
||||
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 &&
|
||||
echo "${GREEN}${BOLD}-- pulled down submodules recursively --${NC}"
|
||||
printf "${GREEN}${BOLD}-- pulled down submodules recursively --${NC}\n"
|
||||
|
||||
gUpdateModules() {
|
||||
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"
|
||||
sleep 0.3
|
||||
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
|
||||
echo "${RED}${BOLD}Failed to commit changes.${NC}"
|
||||
printf "${RED}${BOLD}Failed to commit changes.${NC}\n"
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
echo "${GREEN}${BOLD}No changes to commit.${NC}"
|
||||
printf "${GREEN}${BOLD}No changes to commit.${NC}\n"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
if gUpdateModules; then
|
||||
if git push; then
|
||||
echo "${GREEN}${BOLD}Push successful.${NC}"
|
||||
printf "${GREEN}${BOLD}Push successful.${NC}\n"
|
||||
else
|
||||
echo "${RED}${BOLD}Failed to push changes.${NC}"
|
||||
printf "${RED}${BOLD}Failed to push changes.${NC}\n"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
@ -401,10 +399,10 @@ setup-alias() {
|
|||
# $> gwip 'files and folders' 'commit message'
|
||||
gwip() {
|
||||
local BOLD GREEN YELLOW NC
|
||||
BOLD=$'\e[1m'
|
||||
GREEN=$'\e[92m'
|
||||
YELLOW=$'\e[93m'
|
||||
NC=$'\e[0m'
|
||||
BOLD='\e[1m'
|
||||
GREEN='\e[92m'
|
||||
YELLOW='\e[93m'
|
||||
NC='\e[1m'
|
||||
|
||||
# Fetch the latest changes from the remote
|
||||
git fetch
|
||||
|
@ -428,8 +426,8 @@ setup-alias() {
|
|||
fi
|
||||
done
|
||||
else
|
||||
echo "${BOLD}${YELLOW}You have to provide the command like..:"
|
||||
echo "${GREEN}'gwip <list of files> <commit message>' or like 'gwip .'${NC}"
|
||||
printf "${BOLD}${YELLOW}You have to provide the command like..:\n"
|
||||
printf "${GREEN}'gwip <list of files> <commit message>' or like 'gwip .'${NC}\n"
|
||||
|
||||
return
|
||||
fi
|
||||
|
@ -443,7 +441,7 @@ setup-alias() {
|
|||
trimmed_files+=("${f#./}")
|
||||
done
|
||||
|
||||
echo "${GREEN}Committed files/folders: ${BOLD}${trimmed_files[*]}${NC}"
|
||||
printf "${GREEN}Committed files/folders: ${BOLD}${trimmed_files[*]}${NC}\n"
|
||||
;;
|
||||
esac
|
||||
|
||||
|
@ -451,7 +449,7 @@ setup-alias() {
|
|||
[[ -z "$commit_files" ]] && commit_files=.
|
||||
[[ -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
|
||||
git add $commit_files
|
||||
|
@ -463,13 +461,13 @@ setup-alias() {
|
|||
git commit -m "${commit_message:-wip}"
|
||||
git push
|
||||
else
|
||||
echo "${RED}${BOLD}There was something wrong with:${NC}"
|
||||
echo "${YELLOW}- commit-files '$commit_files'"
|
||||
printf "${RED}${BOLD}There was something wrong with:${NC}\n"
|
||||
printf "${YELLOW}- commit-files '$commit_files'\n"
|
||||
echo "or.."
|
||||
echo "${YELLOW}- commit-message '$commit_message'${NC}"
|
||||
printf "${YELLOW}- commit-message '$commit_message'${NC}\n"
|
||||
fi
|
||||
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
|
||||
}
|
||||
;;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue