fix: ignore errors for fnm install
3 files changed, +55 -41
+44-27install.sh
| @@ -1,12 +1,5 @@ | ||
| 1 | 1 | #!/bin/bash |
| 2 | 2 | |
| 3 | -BLA_clock=(๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐) | |
| 4 | - | |
| 5 | -# Use $prefix for commands that might need sudo | |
| 6 | -prefix="$([[ $(whoami) == "root" ]] && echo "" || echo "sudo")" | |
| 7 | -LAST_OUTPUT=$(mktemp) | |
| 8 | -[ -d "$HOME" ] && echor "$HOME is not a directory. You are cancelled." && exit 1 | |
| 9 | - | |
| 10 | 3 | # Colored echos |
| 11 | 4 | echop() { |
| 12 | 5 | echo -e "\e[35m$1\e[0m" |
| @@ -21,21 +14,31 @@ echot() { | ||
| 21 | 14 | echo -e "\e[36m$1\e[0m" |
| 22 | 15 | } |
| 23 | 16 | echob() { |
| 24 | - echo -e "\e[34$1\e[0m" | |
| 17 | + echo -e "\e[34m$1\e[0m" | |
| 25 | 18 | } |
| 26 | 19 | echoy() { |
| 27 | 20 | echo -e "\e[33m$1\e[0m" |
| 28 | 21 | } |
| 29 | 22 | |
| 30 | -# Ensure sudo and run command in background with animation | |
| 23 | +# Clock animation | |
| 24 | +BLA_clock=(๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐) | |
| 25 | + | |
| 26 | +# Use $prefix for commands that might need sudo | |
| 27 | +prefix="$([[ $(whoami) == "root" ]] && echo "" || echo "sudo")" | |
| 28 | +LAST_OUTPUT=$(mktemp) | |
| 29 | +[ -d "$HOME" ] || { echor "$HOME is not a directory. You are cancelled." && exit 1; } | |
| 30 | +export PATH="$PATH:/usr/local/go/bin:/usr/local/go/bin:$HOME/go/bin:$HOME/.local/bin" | |
| 31 | + | |
| 32 | +# Ensure sudo and run command in background with animation, returns 1 if there was an issue | |
| 31 | 33 | # $1: command used to check if the 2nd command should be ran ("" is always true) |
| 32 | 34 | # $2: command to run in the background |
| 33 | 35 | # $3: text to append to animation |
| 34 | 36 | # $4: success message |
| 35 | 37 | # $5: failure message (after LAST_OUTPUT) |
| 38 | +# $6: Ignore output if set | |
| 36 | 39 | animate() { |
| 37 | 40 | # Return when check is success |
| 38 | - [[ -z "$1" ]] || eval "$1" && echog "โ $4" && return 1 | |
| 41 | + [[ -n "$1" ]] && eval "$1" && echob "โน๏ธ No action required. $4" && return 0 | |
| 39 | 42 | |
| 40 | 43 | # Ensure sudo |
| 41 | 44 | [[ "$(whoami)" == "root" ]] || sudo -v || exit 1 |
| @@ -54,7 +57,7 @@ animate() { | ||
| 54 | 57 | |
| 55 | 58 | # Clear and output error if needed |
| 56 | 59 | printf "\033[2K\r" |
| 57 | - { wait $pid && echog "โ $4"; } || { cat "$LAST_OUTPUT" && echor "\n๐ด $5" && exit 1; } | |
| 60 | + { { wait $pid || [[ -n "$6" ]]; } && echog "โ $4"; } || { cat "$LAST_OUTPUT" && echor "\n๐ด $5" && return 1; } | |
| 58 | 61 | } |
| 59 | 62 | |
| 60 | 63 | echo "Ensuring base tools are installed." |
| @@ -70,14 +73,14 @@ if [ -f /etc/debian_version ]; then | ||
| 70 | 73 | "$installer update && $installer upgrade" \ |
| 71 | 74 | "Updating system" \ |
| 72 | 75 | "System up to date!" \ |
| 73 | - "Failed to update system" | |
| 76 | + "Failed to update system" || exit 1 | |
| 74 | 77 | |
| 75 | 78 | # Install build essential |
| 76 | 79 | animate "dpkg -s build-essential &>/dev/null" \ |
| 77 | 80 | "$installer install build-essential" \ |
| 78 | 81 | "Installing build-essential" \ |
| 79 | 82 | "build-essential installed" \ |
| 80 | - "Failed to install build-essential" | |
| 83 | + "Failed to install build-essential" || exit 1 | |
| 81 | 84 | |
| 82 | 85 | # Install basic tools for arch |
| 83 | 86 | elif [ -f /etc/arch-release ]; then |
| @@ -112,35 +115,35 @@ animate "command -v zsh &>/dev/null" \ | ||
| 112 | 115 | "$installer install zsh" \ |
| 113 | 116 | "Installing zsh" \ |
| 114 | 117 | "zsh installed" \ |
| 115 | - "Failed to install zsh" | |
| 118 | + "Failed to install zsh" || exit 1 | |
| 116 | 119 | |
| 117 | 120 | # Install curl (crazy but this happens sometimes) |
| 118 | 121 | animate "command -v curl &>/dev/null" \ |
| 119 | 122 | "$installer install curl" \ |
| 120 | 123 | "Installing curl" \ |
| 121 | 124 | "curl installed" \ |
| 122 | - "Failed to install curl" | |
| 125 | + "Failed to install curl" || exit 1 | |
| 123 | 126 | |
| 124 | 127 | # Install unzip |
| 125 | 128 | animate "command -v unzip &>/dev/null" \ |
| 126 | 129 | "$installer install unzip" \ |
| 127 | 130 | "Installing unzip" \ |
| 128 | 131 | "unzip installed" \ |
| 129 | - "Failed to install unzip" | |
| 132 | + "Failed to install unzip" || exit 1 | |
| 130 | 133 | |
| 131 | 134 | # Install git |
| 132 | 135 | animate "command -v git &>/dev/null" \ |
| 133 | 136 | "$installer install git" \ |
| 134 | 137 | "Installing git" \ |
| 135 | 138 | "git installed" \ |
| 136 | - "Failed to install git" | |
| 139 | + "Failed to install git" || exit 1 | |
| 137 | 140 | |
| 138 | 141 | # Install cargo |
| 139 | 142 | animate "[ -f ~/.cargo/env ]" \ |
| 140 | - "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | $prefix sh -s -- -y" \ | |
| 143 | + "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y" \ | |
| 141 | 144 | "Installing cargo" \ |
| 142 | 145 | "cargo installed" \ |
| 143 | - "Failed to install cargo" | |
| 146 | + "Failed to install cargo" || exit 1 | |
| 144 | 147 | . ~/.cargo/env |
| 145 | 148 | |
| 146 | 149 | # Install lsd with cargo |
| @@ -148,24 +151,23 @@ animate "command -v lsd &>/dev/null" \ | ||
| 148 | 151 | "cargo install lsd" \ |
| 149 | 152 | "Installing lsd" \ |
| 150 | 153 | "lsd installed" \ |
| 151 | - "Failed to install cargo" | |
| 154 | + "Failed to install cargo" || exit 1 | |
| 152 | 155 | |
| 153 | 156 | # Install golang |
| 154 | -export PATH="$PATH:/usr/local/go/bin:/usr/local/go/bin:$HOME/go/bin" | |
| 155 | 157 | latest_go_version="$(curl -fsSL "https://go.dev/VERSION?m=text" | head -1)" |
| 156 | 158 | filename="$latest_go_version.$([[ "$(uname -m)" == "Linux" ]] && { printf "linux"; } || printf "darwin").$(uname -m).tar.gz" |
| 157 | 159 | animate "[[ \"$(go version 2>/dev/null | awk '{print $3}')\" == \"$latest_go_version\" ]]" \ |
| 158 | 160 | "curl -fsSL https://go.dev/dl/go1.26.1.linux-amd64.tar.gz | $prefix tar xvzf - -C /usr/local" \ |
| 159 | 161 | "Installing go" \ |
| 160 | 162 | "go installed" \ |
| 161 | - "Failed to install go" | |
| 163 | + "Failed to install go" || exit 1 | |
| 162 | 164 | |
| 163 | 165 | # Install lazygit with go |
| 164 | 166 | animate "command -v lazygit &>/dev/null" \ |
| 165 | 167 | "go install github.com/jesseduffield/lazygit@latest" \ |
| 166 | 168 | "Installing lazygit" \ |
| 167 | 169 | "lazygit installed" \ |
| 168 | - "Failed to install lazygit" | |
| 170 | + "Failed to install lazygit" || exit 1 | |
| 169 | 171 | |
| 170 | 172 | # Install yazi |
| 171 | 173 | filename="yazi-$(uname -m)-$( |
| @@ -177,13 +179,28 @@ animate "[ -d /usr/local/yazi ]" \ | ||
| 177 | 179 | unzip /tmp/yazi.zip -d /tmp && $prefix mv /tmp/yazi-x86_64-unknown-linux-gnu/ /usr/local/yazi/ && $prefix mv /usr/local/yazi/ya* /usr/local/bin" \ |
| 178 | 180 | "Installing yazi" \ |
| 179 | 181 | "yazi installed" \ |
| 180 | - "Failed to install yazi" | |
| 182 | + "Failed to install yazi" || exit 1 | |
| 183 | + | |
| 184 | +# Install fnm | |
| 185 | +animate "[ -d ~/.local/share/fnm ]" \ | |
| 186 | + "curl -fsSL https://fnm.vercel.app/install | bash" \ | |
| 187 | + "Installing fnm" \ | |
| 188 | + "fnm installed" \ | |
| 189 | + "Failed to install fnm" \ | |
| 190 | + "ignore fail" | |
| 191 | + | |
| 192 | +# Install uv | |
| 193 | +animate "[ -f ~/.local/bin/uv ]" \ | |
| 194 | + "curl -LsSf https://astral.sh/uv/install.sh | sh" \ | |
| 195 | + "Installing uv" \ | |
| 196 | + "uv installed" \ | |
| 197 | + "Failed to install fnm" || exit 1 | |
| 181 | 198 | |
| 182 | 199 | # Create backups |
| 183 | 200 | [ -d ~/.config ] || mkdir -p ~/.config |
| 184 | 201 | [ -f ~/.zshrc ] && mv ~/.zshrc ~/.zshrc.bak && echot "Backup ~/.zshrc -> ~/.zshrc.bak" |
| 185 | 202 | [ -f ~/.zshenv ] && mv ~/.zshenv ~/.zshenv.bak && echot "Backup ~/.zshenv -> ~/.zshenv.bak" |
| 186 | -[ -d ~/.config/zsh ] && rm -rf ~/.config/zsh.bak | |
| 203 | +[ -d ~/.config/zsh ] && rm -rf ~/.config/zsh.bak && mv ~/.config/zsh ~/.config/zsh.bak | |
| 187 | 204 | |
| 188 | 205 | # Clone config repo |
| 189 | 206 | echo 'export ZDOTDIR=$HOME/.config/zsh' >~/.zshenv |
| @@ -192,13 +209,13 @@ animate "" \ | ||
| 192 | 209 | "git clone https://github.com/huncholane/dotzsh ~/.config/zsh" \ |
| 193 | 210 | "Cloning dotzsh" \ |
| 194 | 211 | "dotzsh cloned. Just a few more things." \ |
| 195 | - "Failed to clone dotzsh" | |
| 212 | + "Failed to clone dotzsh" || exit 1 | |
| 196 | 213 | |
| 197 | 214 | # Install antidote |
| 198 | 215 | animate "[ -d ~/.config/zsh/.antidote ]" \ |
| 199 | 216 | "git clone --depth=1 https://github.com/mattmc3/antidote.git ${ZDOTDIR:-~}/.antidote" \ |
| 200 | 217 | "Installing antidote" \ |
| 201 | 218 | "antidote installed" \ |
| 202 | - "Failed to install antidote" | |
| 219 | + "Failed to install antidote" || exit 1 | |
| 203 | 220 | |
| 204 | 221 | echot "\nRun 'exec zsh' to see the magic" |
+1-1install_test.sh
| @@ -2,7 +2,7 @@ | ||
| 2 | 2 | |
| 3 | 3 | case "$1" in |
| 4 | 4 | "ubuntu") docker run --rm -v "$(pwd):/installer" -w /installer -it ubuntu bash -c " |
| 5 | - apt update -y && apt install sudo -y && useradd test -p test && usermod -aG sudo test && | |
| 5 | + apt update -y && apt install sudo -y && useradd test -m && echo test:test | chpasswd && usermod -aG sudo test && | |
| 6 | 6 | su - test" ;; |
| 7 | 7 | "arch") docker run --rm -v "$(pwd):/installer" -w /installer -it arch 'pacman -Syu --noconfirm && pacman -S && pacman -S --noconfirm && useradd test && bash' ;; |
| 8 | 8 | esac |
+10-13precomp.sh
| @@ -8,19 +8,16 @@ add_completions() { | ||
| 8 | 8 | fi |
| 9 | 9 | } |
| 10 | 10 | |
| 11 | +# Update PATH | |
| 12 | +export PATH="$PATH:$HOME/.local/bin:$HOME/go/bin:$HOME/.avm/bin:/usr/local/go/bin" | |
| 13 | +export PATH="$PATH:$HOME/.local/share/solana/install/active_release/bin" | |
| 14 | +export PATH="$HOME/.local/share/fnm:$PATH" | |
| 15 | + | |
| 16 | +# Add environments | |
| 17 | +[ -f ~/.fzf.zsh ] && . ~/.fzf.zsh | |
| 18 | +[ -f ~/.cargo/env ] && . "$HOME/.cargo/env" | |
| 19 | + | |
| 20 | +# Create completions now that path is updated | |
| 11 | 21 | add_completions _fnm 'fnm completions --shell zsh' |
| 12 | 22 | add_completions _rustup 'rustup completions zsh' |
| 13 | 23 | add_completions _uv 'uv generate-shell-completion zsh' |
| 14 | - | |
| 15 | -# Custom PATH additions | |
| 16 | -export PATH="$PATH:$HOME/.local/bin:$HOME/go/bin:$HOME/.local/share/solana/install/active_release/bin:$HOME/.avm/bin:/usr/local/go/bin" | |
| 17 | - | |
| 18 | -# Setup fzf env | |
| 19 | -[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh | |
| 20 | - | |
| 21 | -# Setup cargo env | |
| 22 | -. "$HOME/.cargo/env" | |
| 23 | - | |
| 24 | -# Setup fnm | |
| 25 | -export PATH="$HOME/.local/share/fnm:$PATH" | |
| 26 | -eval "$(fnm env --shell zsh)" |