feat(dotfiles: install refactoring
This commit is contained in:
+80
-42
@@ -1,59 +1,97 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -eu
|
||||
set -euo pipefail
|
||||
|
||||
#Install dep
|
||||
echo '[*] Install apt requierements ...'
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
DOTFILES_DIR="$SCRIPT_DIR/../dotfiles"
|
||||
|
||||
log() { echo "[*] $*"; }
|
||||
err() { echo "Erreur: $*" >&2; }
|
||||
|
||||
# usage: stow_config <nom_package_dotfiles> <répertoire_cible>
|
||||
# Si le répertoire cible existe déjà, on ne touche à rien (idempotence
|
||||
# non-destructive) : on suppose que la config est déjà en place.
|
||||
stow_config() {
|
||||
local package="$1"
|
||||
local target="$2"
|
||||
|
||||
if [ -e "$target" ]; then
|
||||
log "Config déjà présente ($target), on ne touche à rien. Skip."
|
||||
return
|
||||
fi
|
||||
|
||||
mkdir -p "$target"
|
||||
|
||||
log "Stow du package '$package' vers $target ..."
|
||||
(cd "$DOTFILES_DIR" && stow -vSt "$target" "$package")
|
||||
}
|
||||
|
||||
# --- 1. Dépendances système ---
|
||||
log "Mise à jour des paquets apt ..."
|
||||
sudo apt update
|
||||
|
||||
log "Installation des dépendances apt ..."
|
||||
sudo apt -y install apt-transport-https curl gnupg stow zsh
|
||||
|
||||
# test if rust is installed
|
||||
if ! [ -x "$(command -v cargo)" ]; then
|
||||
echo 'Error: cargo is not installed.'
|
||||
echo '[*] Install rust ...'
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
|
||||
# --- 2. Rust / cargo ---
|
||||
if ! command -v cargo >/dev/null 2>&1; then
|
||||
log "cargo introuvable, installation de rustup ..."
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
||||
fi
|
||||
|
||||
#Install Zellij
|
||||
echo '[*] Install zellij'
|
||||
cargo install zellij
|
||||
if [ -f "$HOME/.cargo/env" ]; then
|
||||
# shellcheck disable=SC1091
|
||||
source "$HOME/.cargo/env"
|
||||
fi
|
||||
|
||||
echo '[*] Removing default configurations ...'
|
||||
rm -rf ~/.config/zellij
|
||||
if ! command -v cargo >/dev/null 2>&1; then
|
||||
err "cargo toujours introuvable après installation, abandon."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo '[*] Creating plugin directory'
|
||||
mkdir ~/.config/zellij
|
||||
# --- 3. Zellij + sa config ---
|
||||
log "Installation de zellij ..."
|
||||
cargo install --locked zellij
|
||||
|
||||
echo '[*] Stowing/Creating simlinks for zellij'
|
||||
cd ../dotfiles && stow -vSt ~/.config/zellij zellij && cd ../install
|
||||
stow_config "zellij" "$HOME/.config/zellij"
|
||||
|
||||
# --- 4. Zsh perso ---
|
||||
# Le fichier reste nommé "zshrc.perso" (sans point) dans le dépôt dotfiles,
|
||||
# mais on veut un symlink caché ~/.zshrc.perso. stow ne permet pas ce
|
||||
# renommage nativement (sauf convention "dot-" qu'on ne veut pas imposer
|
||||
# au dépôt), donc on crée le symlink manuellement.
|
||||
ZSHRC_PERSO_SRC="$DOTFILES_DIR/zsh/zshrc.perso"
|
||||
ZSHRC_PERSO_DEST="$HOME/.zshrc.perso"
|
||||
|
||||
#Zsh Perso
|
||||
echo '[*] Stowing/Creating simlinks for zellij'
|
||||
cd ../dotfiles && stow -vSt ~/.zshrc.perso zshrc.perso && cd ../install
|
||||
if [ -e "$ZSHRC_PERSO_DEST" ] || [ -L "$ZSHRC_PERSO_DEST" ]; then
|
||||
log "$ZSHRC_PERSO_DEST existe déjà, on ne touche à rien. Skip."
|
||||
else
|
||||
if [ ! -f "$ZSHRC_PERSO_SRC" ]; then
|
||||
err "Fichier source introuvable : $ZSHRC_PERSO_SRC"
|
||||
exit 1
|
||||
fi
|
||||
log "Création du symlink $ZSHRC_PERSO_DEST -> $ZSHRC_PERSO_SRC ..."
|
||||
ln -s "$ZSHRC_PERSO_SRC" "$ZSHRC_PERSO_DEST"
|
||||
fi
|
||||
|
||||
#Install Spaceship a zsh module
|
||||
mkdir -p "$HOME/.zsh"
|
||||
rm -rf "$HOME/.zsh/spaceship"
|
||||
git clone --depth=1 https://github.com/spaceship-prompt/spaceship-prompt.git "$HOME/.zsh/spaceship"
|
||||
# --- 5. Spaceship (prompt zsh) ---
|
||||
SPACESHIP_DIR="$HOME/.zsh/spaceship-prompt"
|
||||
|
||||
echo '[*] Removing default configurations ...'
|
||||
rm -rf ~/.config/spaceship
|
||||
if [ -d "$SPACESHIP_DIR/.git" ]; then
|
||||
log "Spaceship (upstream) déjà présent, mise à jour ..."
|
||||
git -C "$SPACESHIP_DIR" pull --ff-only
|
||||
elif [ -e "$SPACESHIP_DIR" ]; then
|
||||
log "$SPACESHIP_DIR existe mais n'est pas un dépôt git, on ne touche à rien. Skip."
|
||||
else
|
||||
log "Installation de spaceship (clone upstream) ..."
|
||||
mkdir -p "$HOME/.zsh"
|
||||
git clone --depth=1 https://github.com/spaceship-prompt/spaceship-prompt.git "$SPACESHIP_DIR"
|
||||
fi
|
||||
|
||||
echo '[*] Creating plugin directory'
|
||||
mkdir ~/.config/spaceship
|
||||
stow_config "spaceship" "$HOME/.config/spaceship"
|
||||
|
||||
echo '[*] Stowing/Creating simlinks for spaceship'
|
||||
cd ../dotfiles && stow -vSt ~/.config/spaceship spaceship && cd ../install
|
||||
# --- 6. Outils Rust additionnels ---
|
||||
log "Installation des outils Rust (bat, bottom, diskus, procs, cargo-update) ..."
|
||||
cargo install --locked bat bottom diskus procs cargo-update
|
||||
|
||||
##Installation de programme rust
|
||||
# Rust cool stuff
|
||||
echo '[*] Install bat'
|
||||
cargo install bat
|
||||
echo '[*] Install bottom'
|
||||
cargo install bottom
|
||||
echo '[*] Install diskus'
|
||||
cargo install diskus
|
||||
echo '[*] Install procs'
|
||||
cargo install procs
|
||||
echo '[*] Install cargo-update'
|
||||
cargo install cargo-update
|
||||
log "Installation terminée avec succès."
|
||||
|
||||
Reference in New Issue
Block a user