#!/bin/bash cd "$HOME" || exit dry_run_operation() { shopt -s nullglob echo -e "\x1b[;4;1mFiles that would be added to the commit:\033[m" echo -e "\x1b[32;4mTracked:\033[m" for files in $(cat "$HOME/.config/rcman/files") do for file in $files do # [ -f $file ] && git add "$file" git ls-files $file #git ls-files --others --exclude-standard --ignored $file done #[ -f $file ] && git add "$file" done echo -e "\x1b[31;4mUntracked:\033[m" for files in $(cat "$HOME/.config/rcman/files") do for file in $files do # [ -f $file ] && git add "$file" git ls-files --others $file #git ls-files --others --exclude-standard --ignored $file done #[ -f $file ] && git add "$file" done } push_operation() { shopt -s nullglob for files in $(cat "$HOME/.config/rcman/files") do for file in $files do [ -f $file ] && git add "$file" done #[ -f $file ] && git add "$file" done git commit -m "Commited by rcman-git." git push } pull_operation() { git pull } init_operation() { [ ! -d "$HOME/.git" ] && git init --initial-branch=main } case $1 in init) init_operation ;; pull) pull_operation ;; push) push_operation ;; dry-run) dry_run_operation ;; *) git "$@" ;; esac