confOS/wsl.sh

170 lines
7.6 KiB
Bash
Raw Normal View History

2022-03-30 19:30:07 +02:00
#!/usr/bin/env bash
if grep "WSL" /proc/version > /dev/null;
then
sudo apt update
2022-03-30 19:30:07 +02:00
which git &> /dev/null || sudo apt install git -y # install git if not already installed
which curl &> /dev/null || sudo apt install apt-transport-https curl -y # install curl (along with apt-transport-https) if not already installed
which wget &> /dev/null || sudo apt install wget -y # install wget if not already installed
2022-03-30 19:30:07 +02:00
2022-04-04 00:28:40 +02:00
# === Upgrade and clean already installed packages ==
2022-03-30 22:47:38 +02:00
sudo apt full-upgrade -y
2022-03-30 19:30:07 +02:00
2022-04-04 00:28:40 +02:00
# === Basic dev ==
2022-03-31 00:05:44 +02:00
sudo apt install build-essential valgrind -y
2022-03-30 19:30:07 +02:00
2022-04-04 00:28:40 +02:00
# === Fish ==
2022-03-30 19:30:07 +02:00
sudo apt-add-repository ppa:fish-shell/release-3 -y
sudo apt install fish fzf bat procps exa micro -y
cd /usr/local/bin || exit
curl https://getmic.ro | sudo GETMICRO_PLATFORM=linux64 bash
cd - || exit
2022-03-30 19:30:07 +02:00
# 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"
# SSH
rm "$HOME"/.config/fish/functions/fish_ssh_agent.fish 2>/dev/null
wget -q https://gitlab.com/kyb/fish_ssh_agent/raw/master/functions/fish_ssh_agent.fish -P "$HOME"/.config/fish/functions/
2022-03-30 19:30:07 +02:00
mkdir "$HOME"/.ssh
# Custom config.fish
rm "$HOME"/.config/fish/config.fish 2>/dev/null
2022-03-31 00:47:03 +02:00
wget -q https://git.kennel.ml/Anri/confOS/raw/branch/main/.config/fish/config_wsl.fish -O "$HOME"/.config/fish/config.fish
2022-03-30 19:30:07 +02:00
# Custom prompt shell (based on Base16 Eighties)
rm "$HOME"/.config/fish/functions/fish_prompt.fish 2>/dev/null
wget -q https://git.kennel.ml/Anri/confOS/raw/branch/main/.config/fish/functions/fish_prompt.fish -P "$HOME"/.config/fish/functions/
2022-03-30 19:30:07 +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 ffcc66'
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'
# Adding aliases
fish -c "abbr ls 'exa -glh'"
fish -c "abbr cp 'cp -rv'"
fish -c "abbr rm 'rm -rf'"
2022-04-01 22:37:22 +02:00
fish -c "abbr gcc 'clear; gcc -Wall -Wextra -fanalyzer -O3 main.c && ./a.out; rm a.out 2> /dev/null'"
fish -c "abbr vgcc 'clear; gcc -Wall -Wextra -fanalyzer -O3 main.c && valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes -s ./a.out; rm a.out 2> /dev/null'"
2022-04-01 22:37:22 +02:00
fish -c "abbr g++ 'clear; g++ -Wall -Wextra -fanalyzer -O3 main.cpp && ./a.out; rm a.out 2> /dev/null'"
fish -c "abbr vg++ 'clear; g++ -Wall -Wextra -fanalyzer -O3 main.cpp && valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes -s ./a.out; rm a.out 2> /dev/null'"
2022-03-30 19:30:07 +02:00
fish -c "abbr make 'clear; make && ./main; make clean 2> /dev/null'"
fish -c "abbr vmake 'clear; make && valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes -s ./main; make clean 2> /dev/null'"
2022-03-30 19:30:07 +02:00
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 - 'cd -'"
fish -c "abbr cat 'batcat'"
fish -c "abbr nano 'micro'"
2022-03-30 22:47:38 +02:00
fish -c "abbr bigupdate 'sudo apt update && sudo apt full-upgrade -y && tldr --update'"
fish -c "abbr d 'explorer.exe .'"
2022-03-30 19:30:07 +02:00
2022-04-04 00:28:40 +02:00
# === GL4D ==
2022-03-30 19:30:07 +02:00
# Installing depedencies
sudo apt install libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev pkg-config automake make autoconf libtool -y # libsdl2-ttf-dev
2022-03-30 19:30:07 +02:00
# Download and build
git clone https://github.com/noalien/GL4Dummies.git
cd GL4Dummies || exit
make -f Makefile.autotools
./configure
make
# Installing it
sudo make install
# Removing folder
cd ..
rm -rf GL4Dummies
# Fix for shared libraries (https://stackoverflow.com/a/9395355)
sudo ldconfig
# Add to path
if [ -f "$HOME"/.bashrc ] ; then
echo -e "\n# GL4Dummies\nexport PATH=/usr/local/bin:\$PATH\nexport LD_LIBRARY_PATH=/usr/local/lib:\$LD_LIBRARY_PATH\n" >> "$HOME"/.bashrc
fi
if [ -f "$HOME"/.config/fish/config.fish ] ; then
echo -e "\n# GL4Dummies\nset -gx LD_LIBRARY_PATH /usr/local/lib \$LD_LIBRARY_PATH\n" >> "$HOME"/.config/fish/config.fish
fi
2022-04-04 00:28:40 +02:00
# === Latex ==
2022-03-30 19:30:07 +02:00
sudo apt install texlive-full python3-pygments -y
2022-04-04 00:28:40 +02:00
# === Python stuff ==
2022-03-30 19:30:07 +02:00
sudo apt install python3-virtualenv python3-tk -y
2022-04-04 00:28:40 +02:00
# === Sign commits ==
2022-03-30 19:30:07 +02:00
git config --global commit.gpgsign true
2022-04-04 00:28:40 +02:00
# === Rust ==
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
2022-03-30 19:30:07 +02:00
source "$HOME"/.cargo/env
fish -c "set -Up fish_user_paths ~/.cargo/bin"
2022-03-30 19:30:07 +02:00
# Dev tools
rustup component add rust-analysis
rustup component add rls
2022-04-04 00:28:40 +02:00
# === tldr ==
2022-03-30 19:30:07 +02:00
cargo install tealdeer
tldr --update
# Fish completion
latest=$(wget -qO- https://api.github.com/repos/dbrgn/tealdeer/releases/latest)
url=$(grep 'browser_download_url": ".*/completions_fish"' <<< "$latest" | awk '{ print substr ($0, 32 ) }' | awk '{ print substr( $0, 1, length($0)-1 ) }')
wget -q --show-progress "$url" -O completions_fish
mv completions_fish ~/.config/fish/completions/tldr.fish
2022-04-04 00:28:40 +02:00
# === Git LFS ==
2022-03-30 19:30:07 +02:00
sudo apt install git-lfs -y
2022-04-04 00:28:40 +02:00
# === Java ==
2022-03-31 00:48:12 +02:00
sudo apt install zip unzip sed -y # sed probably installed but it doesn't cost anything to double-check
2022-03-30 19:30:07 +02:00
curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"
# Adding Fish support if fish is installed
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'
fi
fish -c 'fisher install reitzig/sdkman-for-fish'
fi
sdk install java 17.0.2-tem # https://whichjdk.com/#adoptium-eclipse-temurin
echo "y" | sdk upgrade java
2022-04-04 00:28:40 +02:00
# === Shared folders ==
2022-03-30 19:30:07 +02:00
sudo mkdir /mnt/z && sudo mkdir /mnt/y
2022-04-04 00:28:40 +02:00
# === Remove SU password ==
2022-03-30 19:30:07 +02:00
sudo sed -i "26s#.*#%sudo ALL=(ALL:ALL) NOPASSWD: ALL#" /etc/sudoers
2022-04-04 00:28:40 +02:00
# === Update Debian ==
# sudo sed -i "s/bullseye/bullseye/g" /etc/apt/sources.list
# sudo sed -i "s/bullseye/bullseye/g" /etc/apt/sources.list.d/*.list
2022-03-30 19:30:07 +02:00
# Make the update
# sudo apt update
# sudo apt full-upgrade -y
2022-03-30 19:30:07 +02:00
echo -e "\nInstallation terminée.\nIl faut redémarrer WSL (dans Powershell : wsl -t Debian)."
echo -e "---\nPense bien à paramétrer ton terminal, exemple avec Windows Terminal :"
printf "%s\n%s%s%s\n" "Ligne de commande : wsl.exe -d Debian fish" "Répertoire de démarrage : \\" "\wsl.localhost\Debian\home\\" "$USER"
echo "Jeu de couleur : One Half Dark"
2022-03-30 19:30:07 +02:00
else
echo "Ce script ne fonctionne que sur WSL (Debian)."
2022-03-30 19:30:07 +02:00
fi