dotfiles/bin/dotf
2024-11-02 17:45:43 +01:00

77 lines
1.8 KiB
Bash
Executable File

#!/usr/bin/env bash
source $HOME/dotfiles/bin/helpers/functions.sh
export DOTFILES_CONFIG=$HOME/dotfiles/config/config.yaml
status() {
$HOME/dotfiles/bin/actions/status.sh $@
}
update() {
$HOME/dotfiles/bin/actions/update.sh $@
}
help() {
$HOME/dotfiles/bin/actions/help.sh $@
}
secrets() {
$HOME/dotfiles/bin/actions/secrets.sh $@
}
push() {
$HOME/dotfiles/bin/actions/push.sh $@
}
ensure_git_hooks() {
# If ~/dotfiles/.git/hooks is a symlink, skip this
if [[ -L ~/dotfiles/.git/hooks ]]; then
# Let's make sure the symlink is correct
if [[ $(readlink ~/dotfiles/.git/hooks) != $HOME/dotfiles/bin/actions/git ]]; then
printfe "%s\n" "yellow" "The ~/dotfiles/.git/hooks symlink is incorrect. Please remove it and run this script again."
fi
return
fi
if [[ -d ~/dotfiles/.git/hooks ]]; then
rm -rf ~/dotfiles/.git/hooks
printfe "%s\n" "yellow" "The ~/dotfiles/.git/hooks directory already exists. We're removing it!"
fi
ln -s $HOME/dotfiles/bin/actions/git ~/dotfiles/.git/hooks
printfe "%s\n" "green" "Git hooks are now set up!"
}
ensure_git_hooks
# switch case for parameters
case $1 in
"update")
logo
update $@
;;
"push")
logo continue
push $@
;;
"help"|"--help"|"")
help $@
;;
"secrets")
secrets $@
;;
"term")
$HOME/dotfiles/bin/actions/term.sh $@
;;
"auto-start"|"-a"|"-auto-start"|"as")
$HOME/dotfiles/bin/actions/auto-start.sh $@
;;
"hotkey-daemon")
x-terminal-emulator -e $HOME/dotfiles/bin/actions/hotkey-daemon.sh $@
;;
*)
printfe "%s\n" "red" "Unknown command $1"
help $@
;;
esac