dotfiles/bin/dotf
2024-08-25 05:00:05 +02:00

78 lines
1.7 KiB
Bash
Executable File

#!/usr/bin/env zsh
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 $@
}
exports() {
$HOME/dotfiles/bin/actions/export.sh $@
}
secrets() {
$HOME/dotfiles/bin/actions/secrets.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 $@
;;
"status")
logo continue
status $@
;;
"export")
logo
exports $@
;;
"help"|"--help"|"")
help $@
;;
"secrets")
secrets $@
;;
term)
$HOME/dotfiles/bin/actions/term.sh $@
;;
hotkey-daemon)
bash -c "swhks & pkexec swhkd -c ~/.config/swhkdrc" &
;;
*)
printfe "%s\n" "red" "Unknown command $1"
help $@
;;
esac