confOS/arch_wsl.sh

274 lines
12 KiB
Bash
Raw Normal View History

2022-09-30 03:23:30 +02:00
#!/usr/bin/env bash
set -o errexit # crash the script when a command crash
2023-03-12 21:05:37 +01:00
set -o pipefail # same as above for piped command
set -o nounset # crash when a variable doesnt exist
# TRACE=1 for debug
if [[ "${TRACE-0}" == "1" ]]; then
set -o xtrace
fi
cd "$(dirname "$0")" # change script directory
main() {
2022-09-30 03:23:30 +02:00
# === Init pacman ==
2023-03-12 18:39:57 +01:00
sudo pacman-key --init
sudo pacman-key --populate
2023-03-12 21:05:37 +01:00
sudo pacman -Sy --noconfirm archlinux-keyring
# === Update Arch mirrors ==
sudo pacman -S --noconfirm pacman-contrib
curl -s "https://archlinux.org/mirrorlist/?country=FR&country=GB&protocol=https&use_mirror_status=on" | \
sed -e "s/^#Server/Server/" -e "/^#/d" | sudo bash -c "rankmirrors -n 7 - > /etc/pacman.d/mirrorlist"
2022-09-30 03:23:30 +02:00
# === Update Arch ==
2023-03-12 21:05:37 +01:00
sudo pacman -Syyuu --noconfirm
2022-09-30 03:23:30 +02:00
# === Install packages ==
2023-03-12 18:39:57 +01:00
sudo pacman -S --noconfirm git wget zip openssh bat base-devel make \
2022-11-15 20:05:20 +01:00
python-pygments micro git-lfs npm sdl2_image nodejs \
fish autoconf valgrind automake python-virtualenv gdb \
tk sdl2_mixer exa texlive-most fzf glu man-pages-fr \
2023-03-12 21:05:37 +01:00
uwufetch python-pip opam cpanminus unison \
rebuild-detector git-delta sdl2_ttf rustup
2022-09-30 03:23:30 +02:00
2023-03-12 21:15:38 +01:00
# === Rustup ==
# init rustup
rustup default stable
2022-09-30 03:23:30 +02:00
# === Colors package manager ==
2023-03-12 21:05:37 +01:00
sudo sed -i "s/#Color/Color/g" /etc/pacman.conf
sudo sed -i "s/#ParallelDownloads = 5/ParallelDownloads = 3/g" /etc/pacman.conf
2022-09-30 03:23:30 +02:00
# === Remove SU password ==
2023-03-12 21:05:37 +01:00
echo -e "# Disable password for specific user\nanri ALL=(ALL) NOPASSWD:ALL" | sudo tee -a /etc/sudoers > /dev/null
2022-09-30 03:23:30 +02:00
# === Yay ==
git clone https://aur.archlinux.org/yay.git
cd yay || exit
makepkg -si --noconfirm
# Remove folder
cd ..
rm -rf yay
# Enable *-git package updates
yay -Y --devel --save
# === AUR packages ==
2023-03-12 21:05:37 +01:00
yay -S --noconfirm spim-svn cal8tor
2022-09-30 03:23:30 +02:00
# === Rust ==
# Dev tools
rustup component add rust-analysis rls
# Add Cargo packages from Rust
2023-03-12 21:05:37 +01:00
mkdir -p "$HOME"/.cargo/bin
fish -c "fish_add_path $HOME/.cargo/bin"
2022-09-30 03:23:30 +02:00
# === Set-up systemd
mkdir subsystemctl
cd subsystemctl || exit
curl -so PKGBUILD https://raw.githubusercontent.com/sorah/arch.sorah.jp/master/aur-sorah/PKGBUILDs/subsystemctl/PKGBUILD
makepkg -si --noconfirm
cd ..
2023-03-12 21:05:37 +01:00
rm -rf subsystemctl
sudo subsystemctl start
2022-09-30 03:23:30 +02:00
# === Locales ==
2023-03-12 21:05:37 +01:00
sudo sed -i "s/#fr_FR.UTF-8 UTF-8/fr_FR.UTF8 UTF-8/g" /etc/locale.gen
sudo locale-gen
2022-09-30 03:23:30 +02:00
subsystemctl exec sudo localectl set-locale fr_FR.UTF-8
2023-03-12 21:05:37 +01:00
# === Shared folders ==
sudo mkdir /mnt/y
2022-09-30 03:23:30 +02:00
# === Fish ==
# Remove motd
fish -c "set -U fish_greeting"
# Reversed search
curl -sL https://git.io/fisher | fish -c "source && fisher install jorgebucaran/fisher"
fish -c "fisher install jethrokuan/fzf"
2022-10-18 13:52:10 +02:00
fish -c "fisher install jorgebucaran/autopair.fish"
2022-09-30 03:23:30 +02:00
# SSH
wget -q https://gitlab.com/kyb/fish_ssh_agent/raw/master/functions/fish_ssh_agent.fish -P "$HOME"/.config/fish/functions/
mkdir "$HOME"/.ssh
# Custom config.fish
rm "$HOME"/.config/fish/config.fish 2> /dev/null
2023-02-05 12:23:37 +01:00
wget -q https://git.mylloon.fr/Anri/confOS/raw/branch/main/.config/fish/config_wsl.fish -O "$HOME"/.config/fish/config.fish
2022-09-30 03:23:30 +02:00
# Custom prompt shell (based on https://github.com/fish-shell/fish-shell/blob/master/share/tools/web_config/themes/Base16%20Eighties.theme)
# Modifications: Changed comment color
2023-02-05 12:23:37 +01:00
wget -q https://git.mylloon.fr/Anri/confOS/raw/branch/main/.config/fish/functions/fish_prompt.fish -P "$HOME"/.config/fish/functions/
2022-09-30 03:23:30 +02:00
fish -c "set -U fish_color_normal normal"
fish -c "set -U fish_color_command 99cc99"
fish -c "set -U fish_color_quote ffcc66"
fish -c "set -U fish_color_redirection d3d0c8"
fish -c "set -U fish_color_end cc99cc"
fish -c "set -U fish_color_error f2777a"
fish -c "set -U fish_color_param d3d0c8"
fish -c "set -U fish_color_comment 5c6773"
fish -c "set -U fish_color_match 6699cc"
fish -c "set -U fish_color_selection white --bold --background=brblack"
fish -c "set -U fish_color_search_match bryellow --background=brblack"
fish -c "set -U fish_color_history_current --bold"
fish -c "set -U fish_color_operator 6699cc"
fish -c "set -U fish_color_escape 66cccc"
fish -c "set -U fish_color_cwd green"
fish -c "set -U fish_color_cwd_root red"
fish -c "set -U fish_color_valid_path --underline"
fish -c "set -U fish_color_autosuggestion 747369"
fish -c "set -U fish_color_user brgreen"
fish -c "set -U fish_color_host normal"
fish -c "set -U fish_color_cancel -r"
fish -c "set -U fish_pager_color_completion normal"
fish -c "set -U fish_pager_color_description B3A06D yellow"
fish -c "set -U fish_pager_color_prefix normal --bold --underline"
fish -c "set -U fish_pager_color_progress brwhite --background=cyan"
fish -c "set -U fish_pager_color_selected_background --background=brblack"
fish -c "set -U fish_color_option d3d0c8"
fish -c "set -U fish_color_keyword 99cc99"
# EXA colors
fish -c "set -Ux EXA_COLORS 'di=1;36:da=35'"
# Add aliases
fish -c "abbr ls 'exa --git --icons -gl'"
fish -c "abbr cp 'cp -rv'"
fish -c "abbr rm 'rm -rf'"
fish -c "abbr mgcc 'clear; gcc -Wall -Wextra -Wshadow -Wcast-align -Wstrict-prototypes -fanalyzer -fsanitize=undefined -g main.c && ./a.out; rm a.out 2> /dev/null'"
2022-09-30 03:23:30 +02:00
fish -c "abbr vgcc 'clear; gcc -Wall -Wextra -Wshadow -Wcast-align -Wstrict-prototypes -fanalyzer -fsanitize=undefined -g main.c && valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes -s ./a.out; rm a.out 2> /dev/null'"
fish -c "abbr mg++ 'clear; g++ -Wall -Wextra -Wshadow -Wnon-virtual-dtor -pedantic -g -Wold-style-cast -Wsign-conversion main.cpp && ./a.out; rm a.out 2> /dev/null'"
2022-09-30 03:23:30 +02:00
fish -c "abbr vg++ 'clear; g++ -Wall -Wextra -Wshadow -Wnon-virtual-dtor -pedantic -g -Wold-style-cast -Wsign-conversion main.cpp && valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes -s ./a.out; rm a.out 2> /dev/null'"
fish -c "abbr mmake 'clear; make && ./main; make clean 2> /dev/null'"
2022-09-30 03:23:30 +02:00
fish -c "abbr vmake 'clear; make && valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes -s ./main; make clean 2> /dev/null'"
fish -c "abbr activate 'source bin/activate.fish'"
fish -c "abbr c 'command'"
fish -c "abbr vs 'code .'"
fish -c "abbr untgz 'tar xvzf'"
fish -c "abbr tgz 'tar czf \"Archive.tar.gz\"'"
fish -c "abbr - 'cd -'"
fish -c "abbr cd.. 'cd ..'"
2023-02-26 15:39:07 +01:00
fish -c "abbr ..2 'cd ../..'"
fish -c "abbr ..3 'cd ../../..'"
fish -c "abbr ..4 'cd ../../../..'"
fish -c "abbr ..5 'cd ../../../../..'"
2022-09-30 03:23:30 +02:00
fish -c "abbr cat 'bat'"
fish -c "abbr nano 'micro'"
2022-10-09 19:13:53 +02:00
fish -c "abbr bigupdate 'yay -Syu --noconfirm && tldr --update && yes | sdk update && yes | sdk upgrade java'"
2022-09-30 03:23:30 +02:00
fish -c "abbr d 'explorer.exe .'"
fish -c "abbr gc 'git clone'"
fish -c "abbr cl 'cat src/**.* | sed \'/^\s*$/d\' | wc -l'"
2022-10-01 00:54:28 +02:00
fish -c "abbr mirrors_update \"curl -s 'https://archlinux.org/mirrorlist/?country=FR&country=GB&protocol=https&use_mirror_status=on' | sed -e 's/^#Server/Server/' -e '/^#/d' | sudo bash -c 'rankmirrors -n 7 - > /etc/pacman.d/mirrorlist' && sudo pacman -Syy\""
2022-10-11 15:30:37 +02:00
fish -c "abbr ocamlbuild 'ocamlbuild -no-hygiene'"
2022-11-04 20:21:49 +01:00
fish -c "abbr opamupdate 'opam update && opam upgrade -y'"
2022-11-06 15:12:38 +01:00
fish -c "abbr yay-rebuild 'checkrebuild | awk \'{print \$2}\' | xargs -r yay -S --rebuildtree --noconfirm'"
2022-11-06 15:20:42 +01:00
fish -c "abbr pacman-clean 'sudo pacman -Rsn \$(pacman -Qqtd) --noconfirm'"
2022-11-15 20:58:16 +01:00
fish -c "abbr diff 'delta'"
fish -c "abbr grep 'grep -Irni \'txt\' .'"
2022-12-11 21:37:48 +01:00
fish -c "abbr unison 'unison ~/src ~/u_dest'"
2023-02-16 20:21:41 +01:00
fish -c "abbr zip 'zip -r \"archive.zip\" dossier'"
2022-09-30 03:23:30 +02:00
# === Micro configuration ==
git config --global core.editor "micro"
fish -c "set -Ux EDITOR micro"
mkdir "$HOME"/.config/micro
2023-02-05 12:23:37 +01:00
wget -q --show-progress https://git.mylloon.fr/Anri/confOS/raw/branch/main/.config/micro/settings.json -O "$HOME"/.config/micro/settings.json
2022-09-30 03:23:30 +02:00
micro -plugin install detectindent
# === GL4D ==
# Download, build and installation
git clone https://github.com/noalien/GL4Dummies.git
cd GL4Dummies || exit
make -f Makefile.autotools
./configure
make
2023-03-12 21:05:37 +01:00
sudo make install
2022-09-30 03:23:30 +02:00
cd ..
rm -rf GL4Dummies
# Fix for shared libraries (https://stackoverflow.com/a/9395355)
2023-03-12 21:05:37 +01:00
sudo ldconfig
2022-09-30 03:23:30 +02:00
# Add to path
2022-11-06 01:00:11 +01:00
fish -c "set -Ua LD_LIBRARY_PATH /usr/local/lib"
2022-09-30 03:23:30 +02:00
# === Sign commits ==
git config --global commit.gpgsign true
# === tldr ==
cargo install tealdeer
2023-03-12 21:05:37 +01:00
fish -c "tldr --update"
2022-09-30 03:23:30 +02:00
# Fish completion
2023-03-12 21:05:37 +01:00
local url_tldr
url_tldr=$(curl -s https://api.github.com/repos/dbrgn/tealdeer/releases/latest \
| grep 'browser_download_url": ".*/completions_fish"' \
| cut --delimiter=":" --field=2,3 \
| tr -d \" )
wget -q --show-progress "${url_tldr:1}" -O completions_fish
2022-09-30 03:23:30 +02:00
mv completions_fish ~/.config/fish/completions/tldr.fish
# === Java ==
curl -s "https://get.sdkman.io" | bash
2023-03-12 21:05:37 +01:00
# temp disable nounset for SDK
set +o nounset
# shellcheck source=/dev/null
2022-09-30 03:23:30 +02:00
source "$HOME/.sdkman/bin/sdkman-init.sh"
if [ -x "$HOME"/.config/fish ] ; then
if [ ! -f "$HOME"/.config/fish/functions/fisher.fish ] ; then # install fisher if not already installed
curl -sL https://git.io/fisher | fish -c "source && fisher install jorgebucaran/fisher"
2022-09-30 03:23:30 +02:00
fi
fish -c "fisher install reitzig/sdkman-for-fish"
2022-09-30 03:23:30 +02:00
fi
sdk install java 17.0.4.1-tem # https://whichjdk.com/#adoptium-eclipse-temurin
2023-03-12 21:05:37 +01:00
# renable nounset
set -o nounset
2022-09-30 03:23:30 +02:00
# === Manual color ==
fish -c "set -Ux MANPAGER \"sh -c 'col -bx | bat -l man -p'\""
# === Git ==
2023-02-05 12:23:37 +01:00
wget -q https://git.mylloon.fr/Anri/confOS/raw/branch/main/dotfiles/.gitconfig -O "$HOME"/.gitconfig
2022-09-30 03:23:30 +02:00
# === Python ==
2022-09-30 13:00:53 +02:00
# Add PIP packages from Python
fish -c "fish_add_path $HOME/.local/bin"
2022-09-30 03:23:30 +02:00
# === OCaml ==
# Init Opam and install stuff
echo | opam init
2023-03-12 21:05:37 +01:00
fish -c "yes | opam init"
2022-11-29 16:59:35 +01:00
opam install -y utop ocaml-lsp-server ocamlformat ocamlformat-rpc menhir
2023-02-05 12:23:37 +01:00
wget -q https://git.mylloon.fr/Anri/confOS/raw/branch/main/dotfiles/.ocamlformat -O "$HOME"/.ocamlformat
# Add Opam packages from OCaml
2023-03-12 21:05:37 +01:00
mkdir -p "$HOME"/.opam/default/bin
2022-11-06 14:24:36 +01:00
fish -c "fish_add_path $HOME/.opam/default/bin"
# Fix dlllwt_unix_stubs.so shared object file
fish -c "set -Ux CAML_LD_LIBRARY_PATH $(opam var stublibs)"
2022-09-30 03:23:30 +02:00
2022-10-02 01:17:46 +02:00
# === Clang ==
2023-02-05 12:23:37 +01:00
wget -q https://git.mylloon.fr/Anri/confOS/raw/branch/main/dotfiles/.clang-format -O "$HOME"/.clang-format
2022-10-02 01:17:46 +02:00
2022-10-06 17:37:50 +02:00
# === LaTeX ==
# Pour latexindent
sudo cpanm YAML::Tiny File::HomeDir
2022-10-14 17:48:53 +02:00
# === Valgrind ==
fish -c "set -Ux DEBUGINFOD_URLS https://debuginfod.archlinux.org"
2022-10-18 17:41:32 +02:00
# === Unison ==
2023-03-12 21:05:37 +01:00
mkdir "$HOME"/.unison
2023-02-05 12:23:37 +01:00
wget -q https://git.mylloon.fr/Anri/confOS/raw/branch/main/.unison/default.prf -O "$HOME"/.unison/default.prf
2022-10-18 17:41:32 +02:00
2022-09-30 03:23:30 +02:00
# === Clear useless packages
2023-03-12 21:05:37 +01:00
pacman -Qqtd | sudo pacman --noconfirm -Rsn - 2> /dev/null || true
2022-09-30 03:23:30 +02:00
echo -e "\nInstallation terminée !\nIl faut redémarrer WSL (dans Powershell = wsl --shutdown)."
echo -e "---\nPense bien à paramétrer ton terminal, exemple avec Windows Terminal :"
echo "- Ligne de commande = wsl.exe -d Arch fish"
echo "- Profils par défaut => Apparence :"
echo " - Jeu de couleur = One Half Dark"
echo " - Type de police = Caskaydia Cove Nerd Font Complete Mono Windows Compatible"
echo " (à télécharger ici : https://www.nerdfonts.com/font-downloads)"
}
2022-09-30 03:23:30 +02:00
if grep "WSL2" /proc/version > /dev/null;
then
main "$@"
2022-09-30 03:23:30 +02:00
else
echo "Ce script ne fonctionne que sur ArchWSL." >&2
2022-09-30 03:23:30 +02:00
fi