#!/bin/bash echo "Initializing dotfiles..." SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" FAKE_HOME="$SCRIPT_DIR/fake_home" export f="$FAKE_HOME" if ! command -v wget &> /dev/null; then echo "wget must be installed!" exit 1 fi if ! command -v sofi &> /dev/null && ! test -f /usr/bin/sofi; then echo -e '#!/bin/bash\n$HOME/.sofi.sh --launch' | sudo tee /usr/bin/sofi sudo chmod +x /usr/bin/sofi fi git submodule init git submodule update dotdirs="$(find $FAKE_HOME -mindepth 1 -type d)" echo "$dotdirs" | while read -r dotdir; do new="$HOME${dotdir:${#FAKE_HOME}}" if test -d "$new"; then continue fi echo "mkdir -p $new" mkdir -p "$new" done dotfiles="$(find $FAKE_HOME -mindepth 1 -type f)" echo "$dotfiles" | while read -r dotfile; do new="$HOME${dotfile:${#FAKE_HOME}}" if [[ "$(realpath $dotfile)" == "$(realpath $new)" ]]; then continue fi echo "$dotfile => $new" ln -sf "$dotfile" "$new" done function add-export { local final="$1\"$2\"" if grep "$final" "$HOME/.zsh_local" &> /dev/null; then return fi if grep "$1" "$HOME/.zsh_local" &> /dev/null; then echo "Replacing '$(grep "$1" "$HOME/.zsh_local")' with '$final'" local escaped="$(echo "$1" | sed 's@/@\\/@g')" sed -i "/$escaped/d" "$HOME/.zsh_local" fi echo "$final" >> "$HOME/.zsh_local" } add-export "export DOT_DIR=" "$SCRIPT_DIR" add-export "export f=" "$FAKE_HOME" if [[ "$1" == "--files-only" ]]; then exit 0 fi if ! command -v cargo &> /dev/null; then echo "Rust is not installed. Installing..." curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh fi . "$HOME/.cargo/env" if command -v cargo &> /dev/null && ! command -v bat &> /dev/null; then echo "Bat is not installed. Installing..." cargo install bat fi if ! test -d "$HOME/.nvm"; then echo "nvm is not installed. Installing..." curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion nvm install 14 nvm install 18 nvm install node nvm use node fi if ! command -v dotnet &> /dev/null; then echo "dotnet is not installed. Installing..." wget https://dot.net/v1/dotnet-install.sh -O /tmp/dotnet-install.sh chmod +x /tmp/dotnet-install.sh /tmp/dotnet-install.sh --version latest rm /tmp/dotnet-install.sh fi if ! command -v starship &> /dev/null; then echo "starship is not installed. Installing..." curl -sS https://starship.rs/install.sh | sh fi if ! test -d $HOME/.config/JetBrains/; then echo "JetBrains toolbox is not installed. Installing..." ARCHIVE_URL="$(curl -s 'https://data.services.jetbrains.com/products/releases?code=TBA&latest=true&type=release' | grep -Po '"linux":.*?[^\\]",' | awk -F ':' '{print $3,":"$4}'| sed 's/[", ]//g')" wget -q --show-progress -cO "/tmp/jetbrains-toolbox-latest.tar.gz" "$ARCHIVE_URL" cd /tmp/ tar -xvf jetbrains-toolbox-latest.tar.gz --strip-components=1 chmod +x jetbrains-toolbox ./jetbrains-toolbox fi mkdir -p "$HOME/.local/share/fonts" if ! test -f "$HOME/.local/share/fonts/FiraCodeNerdFontMono-Medium.ttf"; then echo "FiraCode is not installed. Installing..." wget -O /tmp/firacode.zip "https://github.com/ryanoasis/nerd-fonts/releases/download/v3.1.1/FiraCode.zip" unzip -d "$HOME/.local/share/fonts" /tmp/firacode.zip rm /tmp/firacode.zip fc-cache -f -v fi if ! command -v fzf &> /dev/null; then echo "You may wish to install fzf for sofi and other search" fi