mirror of
https://github.com/vhaudiquet/mymachine.git
synced 2025-12-18 20:16:05 +00:00
32 lines
1.3 KiB
Bash
32 lines
1.3 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
install_dotfile_ifnot() {
|
|
sudo -u ${USERNAME} mkdir -p $(dirname -- /home/${USERNAME}/${1})
|
|
sudo -u ${USERNAME} cp --update=none ${script_dir}/dotfiles/${1} /home/${USERNAME}/${1}
|
|
}
|
|
|
|
echo "Installing dotfiles..."
|
|
sudo -u ${USERNAME} mkdir -p /home/${USERNAME}/.config/git
|
|
cat ${script_dir}/dotfiles/.config/git/config | envsubst '$GIT_USER $EMAIL' >/home/${USERNAME}/.config/git/config
|
|
chown ${USERNAME}:${USERNAME} /home/${USERNAME}/.config/git/config
|
|
|
|
# Install bashrc if not mymachine-installed
|
|
if ! [[ "$(head -n 1 /home/${USERNAME}/.bashrc)" = "# mymachine" ]]; then
|
|
sudo -u ${USERNAME} cp "${script_dir}/dotfiles/.bashrc" "/home/${USERNAME}/.bashrc"
|
|
fi
|
|
install_dotfile_ifnot .config/prompt.sh
|
|
|
|
# Install code settings depending on which code is installed
|
|
CODE_NAME="Code - OSS"
|
|
if [ "${ID}" = "ubuntu" ]; then
|
|
# On Ubuntu, we install official code snap
|
|
CODE_NAME="Code"
|
|
fi
|
|
sudo -u ${USERNAME} mkdir -p /home/${USERNAME}/.config/${CODE_NAME}/User
|
|
sudo -u ${USERNAME} cp "${script_dir}/dotfiles/.config/Code - OSS/User/settings.json" "/home/${USERNAME}/.config/${CODE_NAME}/User/settings.json"
|
|
|
|
# Install ghostty, git, gh settings if not present
|
|
install_dotfile_ifnot .config/ghostty/config
|
|
install_dotfile_ifnot .config/git/config
|
|
install_dotfile_ifnot .config/gh/config.yml
|