From 5088da8a7522e7de38239cc91d9c80c72853c916 Mon Sep 17 00:00:00 2001 From: Frank Qing Date: Wed, 28 May 2025 15:11:24 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20(install.sh,=20install=5Fnvm.sh):?= =?UTF-8?q?=20refactor=20font=20installation=20logic=20to=20check=20for=20?= =?UTF-8?q?existing=20fonts=20before=20downloading,=20and=20remove=20redun?= =?UTF-8?q?dant=20echo=20statement=20in=20install=5Fnvm.sh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install.sh | 26 +++++++++++++++++++++++--- install_nvm.sh | 2 -- install_pyenv.sh | 28 ++++++++++++++++++++++++++++ zshrc/pyenv.zsh | 4 ++++ 4 files changed, 55 insertions(+), 5 deletions(-) create mode 100755 install_pyenv.sh create mode 100644 zshrc/pyenv.zsh diff --git a/install.sh b/install.sh index db86eb6..c4a29df 100755 --- a/install.sh +++ b/install.sh @@ -248,9 +248,29 @@ fi echo -e "Installing Nerd Fonts version of Hack, Roboto Mono, DejaVu Sans Mono\n" -wget -q --show-progress -N https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/Hack/Regular/HackNerdFont-Regular.ttf -P ~/.fonts/ -wget -q --show-progress -N https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/RobotoMono/Regular/RobotoMonoNerdFont-Regular.ttf -P ~/.fonts/ -wget -q --show-progress -N https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/DejaVuSansMono/Regular/DejaVuSansMNerdFont-Regular.ttf -P ~/.fonts/ +# Check and download Hack font if it doesn't exist +if [ ! -f ~/.fonts/HackNerdFont-Regular.ttf ]; then + echo "Downloading Hack Nerd Font..." + wget -q --show-progress -N https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/Hack/Regular/HackNerdFont-Regular.ttf -P ~/.fonts/ +else + echo "Hack Nerd Font already exists, skipping download." +fi + +# Check and download Roboto Mono font if it doesn't exist +if [ ! -f ~/.fonts/RobotoMonoNerdFont-Regular.ttf ]; then + echo "Downloading Roboto Mono Nerd Font..." + wget -q --show-progress -N https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/RobotoMono/Regular/RobotoMonoNerdFont-Regular.ttf -P ~/.fonts/ +else + echo "Roboto Mono Nerd Font already exists, skipping download." +fi + +# Check and download DejaVu Sans Mono font if it doesn't exist +if [ ! -f ~/.fonts/DejaVuSansMNerdFont-Regular.ttf ]; then + echo "Downloading DejaVu Sans Mono Nerd Font..." + wget -q --show-progress -N https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/DejaVuSansMono/Regular/DejaVuSansMNerdFont-Regular.ttf -P ~/.fonts/ +else + echo "DejaVu Sans Mono Nerd Font already exists, skipping download." +fi fc-cache -fv ~/.fonts diff --git a/install_nvm.sh b/install_nvm.sh index f357d7b..e3e7c29 100755 --- a/install_nvm.sh +++ b/install_nvm.sh @@ -25,5 +25,3 @@ curl -s https://git.miomio.moe/mio/easyzsh/raw/branch/master/patch.sh | bash -s # Restore original working directory cd "$ORIGINAL_DIR" - -echo -e "\nAll basic packages have been installed. Restart your terminal or run 'source ~/.zshrc' to start using them.\n" diff --git a/install_pyenv.sh b/install_pyenv.sh new file mode 100755 index 0000000..81e398e --- /dev/null +++ b/install_pyenv.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# Save the original working directory +ORIGINAL_DIR="$(pwd)" + +# Install pyenv (Python Version Manager) if it is not already installed +if command -v pyenv &> /dev/null; then + echo -e "pyenv is already installed\n" +else + echo -e "Installing pyenv (Python Version Manager)\n" + # Using the official pyenv installer (https://github.com/pyenv/pyenv-installer) + curl -fsSL https://pyenv.run | bash + + # Load pyenv for the remainder of this script + export PYENV_ROOT="$HOME/.pyenv" + [[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH" + eval "$(pyenv init - bash)" +fi + +# OPTIONAL: Install the latest stable version of Python +# Uncomment the following line if you would like to automatically install it +# pyenv install 3.12.0 && pyenv global 3.12.0 + +# Apply the pyenv zsh configuration patch (downloads zshrc/pyenv.zsh to ~/.config/zshrc/pyenv.zsh) +curl -s https://git.miomio.moe/mio/easyzsh/raw/branch/master/patch.sh | bash -s pyenv + +# Restore original working directory +cd "$ORIGINAL_DIR" diff --git a/zshrc/pyenv.zsh b/zshrc/pyenv.zsh new file mode 100644 index 0000000..df5c984 --- /dev/null +++ b/zshrc/pyenv.zsh @@ -0,0 +1,4 @@ +# Initialize pyenv (Python Version Manager) +export PYENV_ROOT="$HOME/.pyenv" +[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH" # Add pyenv to PATH +eval "$(pyenv init - zsh)" # This loads pyenv \ No newline at end of file