irongit

fix: ignore errors for fnm install

huncholanehuncholaneauthored
parent 1dace09commit a8cb23c1779458b6389a0f2b9a858ee47d70c52bBrowse files

3 files changed, +55 -41

+44-27install.sh
@@ -1,12 +1,5 @@
11 #!/bin/bash
22
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-
103 # Colored echos
114 echop() {
125 echo -e "\e[35m$1\e[0m"
@@ -21,21 +14,31 @@ echot() {
2114 echo -e "\e[36m$1\e[0m"
2215 }
2316 echob() {
24- echo -e "\e[34$1\e[0m"
17+ echo -e "\e[34m$1\e[0m"
2518 }
2619 echoy() {
2720 echo -e "\e[33m$1\e[0m"
2821 }
2922
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
3133 # $1: command used to check if the 2nd command should be ran ("" is always true)
3234 # $2: command to run in the background
3335 # $3: text to append to animation
3436 # $4: success message
3537 # $5: failure message (after LAST_OUTPUT)
38+# $6: Ignore output if set
3639 animate() {
3740 # 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
3942
4043 # Ensure sudo
4144 [[ "$(whoami)" == "root" ]] || sudo -v || exit 1
@@ -54,7 +57,7 @@ animate() {
5457
5558 # Clear and output error if needed
5659 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; }
5861 }
5962
6063 echo "Ensuring base tools are installed."
@@ -70,14 +73,14 @@ if [ -f /etc/debian_version ]; then
7073 "$installer update && $installer upgrade" \
7174 "Updating system" \
7275 "System up to date!" \
73- "Failed to update system"
76+ "Failed to update system" || exit 1
7477
7578 # Install build essential
7679 animate "dpkg -s build-essential &>/dev/null" \
7780 "$installer install build-essential" \
7881 "Installing build-essential" \
7982 "build-essential installed" \
80- "Failed to install build-essential"
83+ "Failed to install build-essential" || exit 1
8184
8285 # Install basic tools for arch
8386 elif [ -f /etc/arch-release ]; then
@@ -112,35 +115,35 @@ animate "command -v zsh &>/dev/null" \
112115 "$installer install zsh" \
113116 "Installing zsh" \
114117 "zsh installed" \
115- "Failed to install zsh"
118+ "Failed to install zsh" || exit 1
116119
117120 # Install curl (crazy but this happens sometimes)
118121 animate "command -v curl &>/dev/null" \
119122 "$installer install curl" \
120123 "Installing curl" \
121124 "curl installed" \
122- "Failed to install curl"
125+ "Failed to install curl" || exit 1
123126
124127 # Install unzip
125128 animate "command -v unzip &>/dev/null" \
126129 "$installer install unzip" \
127130 "Installing unzip" \
128131 "unzip installed" \
129- "Failed to install unzip"
132+ "Failed to install unzip" || exit 1
130133
131134 # Install git
132135 animate "command -v git &>/dev/null" \
133136 "$installer install git" \
134137 "Installing git" \
135138 "git installed" \
136- "Failed to install git"
139+ "Failed to install git" || exit 1
137140
138141 # Install cargo
139142 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" \
141144 "Installing cargo" \
142145 "cargo installed" \
143- "Failed to install cargo"
146+ "Failed to install cargo" || exit 1
144147 . ~/.cargo/env
145148
146149 # Install lsd with cargo
@@ -148,24 +151,23 @@ animate "command -v lsd &>/dev/null" \
148151 "cargo install lsd" \
149152 "Installing lsd" \
150153 "lsd installed" \
151- "Failed to install cargo"
154+ "Failed to install cargo" || exit 1
152155
153156 # Install golang
154-export PATH="$PATH:/usr/local/go/bin:/usr/local/go/bin:$HOME/go/bin"
155157 latest_go_version="$(curl -fsSL "https://go.dev/VERSION?m=text" | head -1)"
156158 filename="$latest_go_version.$([[ "$(uname -m)" == "Linux" ]] && { printf "linux"; } || printf "darwin").$(uname -m).tar.gz"
157159 animate "[[ \"$(go version 2>/dev/null | awk '{print $3}')\" == \"$latest_go_version\" ]]" \
158160 "curl -fsSL https://go.dev/dl/go1.26.1.linux-amd64.tar.gz | $prefix tar xvzf - -C /usr/local" \
159161 "Installing go" \
160162 "go installed" \
161- "Failed to install go"
163+ "Failed to install go" || exit 1
162164
163165 # Install lazygit with go
164166 animate "command -v lazygit &>/dev/null" \
165167 "go install github.com/jesseduffield/lazygit@latest" \
166168 "Installing lazygit" \
167169 "lazygit installed" \
168- "Failed to install lazygit"
170+ "Failed to install lazygit" || exit 1
169171
170172 # Install yazi
171173 filename="yazi-$(uname -m)-$(
@@ -177,13 +179,28 @@ animate "[ -d /usr/local/yazi ]" \
177179 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" \
178180 "Installing yazi" \
179181 "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
181198
182199 # Create backups
183200 [ -d ~/.config ] || mkdir -p ~/.config
184201 [ -f ~/.zshrc ] && mv ~/.zshrc ~/.zshrc.bak && echot "Backup ~/.zshrc -> ~/.zshrc.bak"
185202 [ -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
187204
188205 # Clone config repo
189206 echo 'export ZDOTDIR=$HOME/.config/zsh' >~/.zshenv
@@ -192,13 +209,13 @@ animate "" \
192209 "git clone https://github.com/huncholane/dotzsh ~/.config/zsh" \
193210 "Cloning dotzsh" \
194211 "dotzsh cloned. Just a few more things." \
195- "Failed to clone dotzsh"
212+ "Failed to clone dotzsh" || exit 1
196213
197214 # Install antidote
198215 animate "[ -d ~/.config/zsh/.antidote ]" \
199216 "git clone --depth=1 https://github.com/mattmc3/antidote.git ${ZDOTDIR:-~}/.antidote" \
200217 "Installing antidote" \
201218 "antidote installed" \
202- "Failed to install antidote"
219+ "Failed to install antidote" || exit 1
203220
204221 echot "\nRun 'exec zsh' to see the magic"
+1-1install_test.sh
@@ -2,7 +2,7 @@
22
33 case "$1" in
44 "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 &&
66 su - test" ;;
77 "arch") docker run --rm -v "$(pwd):/installer" -w /installer -it arch 'pacman -Syu --noconfirm && pacman -S && pacman -S --noconfirm && useradd test && bash' ;;
88 esac
+10-13precomp.sh
@@ -8,19 +8,16 @@ add_completions() {
88 fi
99 }
1010
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
1121 add_completions _fnm 'fnm completions --shell zsh'
1222 add_completions _rustup 'rustup completions zsh'
1323 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)"