Last active
March 30, 2025 03:14
-
-
Save alexdelprete/decceb3f4cf2c1b209d65ab15f34cf7b to your computer and use it in GitHub Desktop.
Dotfiles Installation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
clear | |
echo_task() { | |
printf "\033[0;34m--> %s\033[0m\n" "$*" | |
} | |
error() { | |
printf "\033[0;31m%s\033[0m\n" "$*" >&2 | |
exit 1 | |
} | |
# remove chezmoi | |
rm -rf $HOME/.local/share/chezmoi $HOME/.config/chezmoi &> /dev/null | |
# remove flox | |
echo "Removing Flox..." | |
apt-get -y autoremove --purge flox &> /dev/null ─╯ | |
systemctl stop nix-daemon.service &> /dev/null | |
systemctl disable nix-daemon.socket nix-daemon.service &> /dev/null | |
systemctl daemon-reload &> /dev/null | |
echo "- removing Nix files/folders" &> /dev/null | |
rm -f /etc/systemd/system/nix-daemon.service /etc/systemd/system/nix-daemon.socket /etc/tmpfiles.d/nix-daemon.conf &> /dev/null | |
rm -rf /nix /etc/nix /etc/profile/nix.sh /usr/share/nix $HOME/.nix-profile $HOME/.nix-defexpr $HOME/.nix-channels &> /dev/null | |
rm -rf $HOME/.nix-profile $HOME/.nix-defexpr $HOME/.nix-channels $HOME/.local/share/flox $HOME/.config/flox &> /dev/null | |
# set locales | |
echo "Configure locales" | |
distro_id="$( (grep '^ID=' /etc/os-release | cut -d= -f2) )" | |
distro_list="debian ubuntu raspbian" | |
if [[ " ${distro_list[*]} " =~ " ${distro_id} " ]]; then | |
echo_task "Debian OS detected: setting locales" | |
locale-gen en_US.UTF-8 &> /dev/null | |
locale-gen it_IT.UTF-8 &> /dev/null | |
update-locale &> /dev/null | |
localectl set-locale LANG=en_US.UTF-8 &> /dev/null | |
localectl set-locale LANGUAGE=en_US.UTF-8 &> /dev/null | |
localectl set-locale LC_NUMERIC=it_IT.UTF-8 &> /dev/null | |
localectl set-locale LC_TIME=it_IT.UTF-8 &> /dev/null | |
localectl set-locale LC_MEASUREMENT=it_IT.UTF-8 &> /dev/null | |
else | |
error "Debian OS not detected: can't set locales properly" | |
fi | |
# updating package list | |
echo_task "Updating package list" | |
apt-get update &> /dev/null | |
# ensure age is installed | |
if ! command -v age > /dev/null; then | |
echo_task "Installing age encryption tool" | |
apt-get install -y age &> /dev/null | |
fi | |
# ensure git is installed | |
if ! command -v git > /dev/null; then | |
echo_task "Installing git tool" | |
apt-get install -y git &> /dev/null | |
fi | |
echo_task "Running chezmoi init" | |
# Set github repo's username | |
DOTFILES_USER=${DOTFILES_USER:-"alexdelprete"} | |
# Install chezmoi in $HOME/bin and install dotfiles locally | |
cd $HOME | |
bash -c "$(curl -fsLS get.chezmoi.io)" -- init --apply --force ${DOTFILES_USER} | |
echo_task "dotfiles installed. Enjoy!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment