diff --git a/.zsh/.aliases.zsh b/.zsh/.aliases.zsh index b40f8ec..d720594 100644 --- a/.zsh/.aliases.zsh +++ b/.zsh/.aliases.zsh @@ -530,21 +530,24 @@ __git__() { ;; esac - [[ -z "$commit_files" ]] && commit_files=. - [[ -z "$commit_message" ]] && commit_message=wip + if [ -n "$commit_files" ] || [ -n "$commit_message" ]; then + echo "${CYAN}No changes on the remote branch. Adding changes and pushing with ${RED}${BOLD}'$commit_message'${NC}${CYAN} commit.${NC}" - echo "${CYAN}No changes on the remote branch. Adding changes and pushing with ${RED}${BOLD}'$commit_message'${NC}${CYAN} commit.${NC}" + [[ -z "$commit_files" ]] && commit_files=. + [[ -z "$commit_message" ]] && commit_message=wip + + if (("${#commit_files}" <= 1)); then + git add $commit_files + else + for f in "${commit_files[@]}"; do + git add $f + done + fi + + git commit -m "${commit_message:-wip}" + git push - if (("${#commit_files}" <= 1)); then - git add $commit_files - else - for f in "${commit_files[@]}"; do - git add $f - done fi - - git commit -m "${commit_message:-wip}" - git push else echo "${RED}${BOLD}There are changes on the remote branch. Please pull the latest changes first.${NC}" fi