Files
dotfiles/.functions/dotfiles.sh

43 lines
1.4 KiB
Bash

#!/bin/bash
function dotf(){
/usr/bin/git --git-dir="$HOME"/.dotfiles --work-tree="$HOME" "$@"
}
status_dotfiles(){
case $1 in
check_error)
result="$(/usr/bin/git --git-dir="$HOME"/.dotfiles --work-tree="$HOME" status --short 2> /dev/null)"
# shellcheck disable=SC2181
if [[ $? -ne 0 ]]; then
echo YES
fi
;;
check_status)
result="$(/usr/bin/git --git-dir="$HOME"/.dotfiles --work-tree="$HOME" status --short 2> /dev/null)"
if [[ -n "$result" ]]; then
echo YES
fi
;;
check_push)
result="$(/usr/bin/git --git-dir="$HOME"/.dotfiles --work-tree="$HOME" status --short 2> /dev/null)"
if [[ -z "$result" ]]; then
result="$(/usr/bin/git --git-dir="$HOME"/.dotfiles --work-tree="$HOME" cherry -v )"
if [[ -n "$result" ]]; then
echo YES
fi
fi
;;
esac
}
# Load git completion explicitly
if command -v git >/dev/null 2>&1; then
# Source completion script (adjust path for your system)
if [ -f /usr/share/bash-completion/completions/git ]; then
# shellcheck disable=1091
source /usr/share/bash-completion/completions/git
fi
# Now __git_complete should exist
[[ $(type -t __git_complete) == "function" ]] && __git_complete dotf __git_main
fi