reconstruct dir

This commit is contained in:
2026-01-21 22:50:39 +08:00
parent 429f8fc2d6
commit c5be794640
7 changed files with 263 additions and 193 deletions

24
zsh/functions/brew.sh Normal file
View File

@@ -0,0 +1,24 @@
# Homebrew Tsinghua mirror for macOS
if [[ $OS != "Darwin" ]]; then
return
fi
function brewthu() {
if [[ $HOMEBREW_BOTTLE_DOMAIN = "" ]]; then
export HOMEBREW_API_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api"
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles"
export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"
export HOMEBREW_PIP_INDEX_URL="https://pypi.tuna.tsinghua.edu.cn/simple"
# Bottles
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles"
else
unset HOMEBREW_API_DOMAIN
unset HOMEBREW_BOTTLE_DOMAIN
unset HOMEBREW_BREW_GIT_REMOTE
unset HOMEBREW_CORE_GIT_REMOTE
unset HOMEBREW_PIP_INDEX_URL
# Bottles
unset HOMEBREW_BOTTLE_DOMAIN
fi
}

View File

@@ -1,36 +1,86 @@
#!/bin/bash
# check for git
if ! command -v git >/dev/null 2>&1; then
echo "Git is not installed."
fi
function check_zsh_polyjuice() {
# check for zsh-autosuggestions
if [[ ! -f $ZSH_PLUGINS_PATH/zsh-autosuggestions/zsh-autosuggestions.zsh ]]; then
echo "zsh-autosuggestions is not installed."
fi
# check for python
if ! command -v python >/dev/null 2>&1; then
echo "Python is not installed."
fi
# check for zsh-syntax-highlighting
if [[ ! -f $ZSH_PLUGINS_PATH/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ]]; then
echo "zsh-syntax-highlighting is not installed."
fi
# check for rust
if ! command -v cargo >/dev/null 2>&1; then
echo "Rust is not installed."
fi
# check for zsh-autocomplete
if [[ ! -f $ZSH_PLUGINS_PATH/zsh-autocomplete/zsh-autocomplete.plugin.zsh ]]; then
echo "zsh-autocomplete is not installed."
fi
# check for verilator
if ! command -v verilator >/dev/null 2>&1; then
echo "Verilator is not installed."
fi
# check for fzf-tab
if [[ ! -f $ZSH_PLUGINS_PATH/fzf-tab/fzf-tab.zsh ]]; then
echo "fzf-tab is not installed."
fi
# check for iverilog
if ! command -v iverilog >/dev/null 2>&1; then
echo "iverilog is not installed."
fi
# check for oh-my-zsh
if [[ ! -d $ZSH_PLUGINS_PATH/ohmyzsh ]]; then
echo "oh-my-zsh is not installed."
fi
# check for OpenJDK
if ! command -v javac >/dev/null 2>&1; then
echo "OpenJDK is not installed."
fi
# check for zoxide
if (( ! $+commands[zoxide] )); then
echo "zoxide is not installed."
fi
# check for sbt
if ! command -v sbt >/dev/null 2>&1; then
echo "sbt is not installed."
fi
# check for fzf
if (( ! $+commands[fzf] )); then
echo "fzf is not installed."
fi
# check for starship
if (( ! $+commands[starship] )); then
echo "starship is not installed."
fi
# check for python
if (( ! $+commands[python3] )); then
echo "python3 is not installed."
fi
}
function check_tools() {
# check for git
if ! command -v git >/dev/null 2>&1; then
echo "Git is not installed."
fi
# check for python
if ! command -v python >/dev/null 2>&1; then
echo "Python is not installed."
fi
# check for rust
if ! command -v cargo >/dev/null 2>&1; then
echo "Rust is not installed."
fi
# check for verilator
if ! command -v verilator >/dev/null 2>&1; then
echo "Verilator is not installed."
fi
# check for iverilog
if ! command -v iverilog >/dev/null 2>&1; then
echo "iverilog is not installed."
fi
# check for OpenJDK
if ! command -v javac >/dev/null 2>&1; then
echo "OpenJDK is not installed."
fi
# check for sbt
if ! command -v sbt >/dev/null 2>&1; then
echo "sbt is not installed."
fi
}

View File

@@ -1,118 +1,91 @@
#! /bin/bash
echo "$SHELL" | grep -q zsh
if [ $? -ne 0 ]; then
echo "Please run this script in zsh shell."
exit 1
fi
# git, fzf, zoxide are required
if ! command -v git >/dev/null 2>&1; then
echo "Git is not installed."
exit 1
fi
if ! command -v fzf >/dev/null 2>&1; then
echo "FZF is not installed."
exit 1
fi
if ! command -v zoxide >/dev/null 2>&1; then
echo "Zoxide is not installed."
exit 1
fi
if ! command -v python >/dev/null 2>&1; then
if ! command -v python3 >/dev/null 2>&1; then
echo "Python is not installed."
exit 1
function install_plugins() {
if ! command -v git >/dev/null 2>&1; then
echo "Git is not installed."
return
fi
fi
if ! command -v starship >/dev/null 2>&1; then
echo "Starship is not installed."
exit 1
fi
if [ ! -n "${ZSH_PLUGINS_PATH}" ]; then
echo "ZSH_PLUGINS_PATH is not set. Please set it and try again."
return
fi
ZSH_POLYJUICE_PATH="$HOME/.TerminalPolyjuice"
PLUGINS_PATH="$ZSH_POLYJUICE_PATH/zsh/plugins"
# git clone zsh-autosuggestions
if [ ! -d "$PLUGINS_PATH"/zsh-autosuggestions ]; then
echo "Zsh Autosuggestions is not downloaded. Downloading..."
# git clone https://github.com/zsh-users/zsh-autosuggestions.git "$PLUGINS_PATH"/zsh-autosuggestions
git clone https://gitee.com/mirrors/zsh-autosuggestions.git "$PLUGINS_PATH"/zsh-autosuggestions
else
cd "$PLUGINS_PATH"/zsh-autosuggestions || exit 1
if [ ! -d .git ]; then
echo "Zsh Autosuggestions is not a git repository. Please remove $PLUGINS_PATH/zsh-autosuggestions and try again."
exit 1
# git clone zsh-autosuggestions
if [ ! -d "$ZSH_PLUGINS_PATH"/zsh-autosuggestions ]; then
echo "Zsh Autosuggestions is not downloaded. Downloading..."
# git clone https://github.com/zsh-users/zsh-autosuggestions.git "$ZSH_PLUGINS_PATH"/zsh-autosuggestions
git clone https://gitee.com/mirrors/zsh-autosuggestions.git "$ZSH_PLUGINS_PATH"/zsh-autosuggestions
else
echo "Zsh Autosuggestions is already exist. Updating..."
git pull
cd "$ZSH_PLUGINS_PATH"/zsh-autosuggestions || return
if [ ! -d .git ]; then
echo "Zsh Autosuggestions is not a git repository. Please remove $ZSH_PLUGINS_PATH/zsh-autosuggestions and try again."
return
else
echo "Zsh Autosuggestions is already exist. Updating..."
git pull
fi
fi
fi
# git clone zsh-syntax-highlighting
if [ ! -d "$PLUGINS_PATH"/zsh-syntax-highlighting ]; then
echo "Zsh Syntax Highlighting is not downloaded. Downloading..."
# git clone https://github.com/zsh-users/zsh-syntax-highlighting.git "$PLUGINS_PATH"/zsh-syntax-highlighting
git clone https://gitee.com/mirrors/zsh-syntax-highlighting.git "$PLUGINS_PATH"/zsh-syntax-highlighting
else
cd "$PLUGINS_PATH"/zsh-syntax-highlighting || exit 1
if [ ! -d .git ]; then
echo "Zsh Syntax Highlighting is not a git repository. Please remove $PLUGINS_PATH/zsh-syntax-highlighting and try again."
exit 1
# git clone zsh-syntax-highlighting
if [ ! -d "$ZSH_PLUGINS_PATH"/zsh-syntax-highlighting ]; then
echo "Zsh Syntax Highlighting is not downloaded. Downloading..."
# git clone https://github.com/zsh-users/zsh-syntax-highlighting.git "$ZSH_PLUGINS_PATH"/zsh-syntax-highlighting
git clone https://gitee.com/mirrors/zsh-syntax-highlighting.git "$ZSH_PLUGINS_PATH"/zsh-syntax-highlighting
else
echo "Zsh Syntax Highlighting is already exist. Updating..."
git pull
cd "$ZSH_PLUGINS_PATH"/zsh-syntax-highlighting || return
if [ ! -d .git ]; then
echo "Zsh Syntax Highlighting is not a git repository. Please remove $ZSH_PLUGINS_PATH/zsh-syntax-highlighting and try again."
return
else
echo "Zsh Syntax Highlighting is already exist. Updating..."
git pull
fi
fi
fi
# git clone zsh-autocomplete
if [ ! -d "$PLUGINS_PATH"/zsh-autocomplete ]; then
echo "Zsh Autocomplete is not downloaded. Downloading..."
# git clone https://github.com/marlonrichert/zsh-autocomplete.git "$PLUGINS_PATH"/zsh-autocomplete
git clone https://gitee.com/mirrors/zsh-autocomplete.git "$PLUGINS_PATH"/zsh-autocomplete
# git clone zsh-autocomplete
if [ ! -d "$ZSH_PLUGINS_PATH"/zsh-autocomplete ]; then
echo "Zsh Autocomplete is not downloaded. Downloading..."
# git clone https://github.com/marlonrichert/zsh-autocomplete.git "$ZSH_PLUGINS_PATH"/zsh-autocomplete
git clone https://gitee.com/mirrors/zsh-autocomplete.git "$ZSH_PLUGINS_PATH"/zsh-autocomplete
else
cd "$PLUGINS_PATH"/zsh-autocomplete || exit 1
if [ ! -d .git ]; then
echo "Zsh Autocomplete is not a git repository. Please remove $PLUGINS_PATH/zsh-autocomplete and try again."
exit 1
else
echo "Zsh Autocomplete is already exist. Updating..."
git pull
cd "$ZSH_PLUGINS_PATH"/zsh-autocomplete || return
if [ ! -d .git ]; then
echo "Zsh Autocomplete is not a git repository. Please remove $ZSH_PLUGINS_PATH/zsh-autocomplete and try again."
return
else
echo "Zsh Autocomplete is already exist. Updating..."
git pull
fi
fi
fi
# git clone powerlevel10k
if [ ! -d "$PLUGINS_PATH"/fzf-tab ]; then
echo "fzf-tab is not downloaded. Downloading..."
git clone https://github.com/Aloxaf/fzf-tab.git "$PLUGINS_PATH"/fzf-tab
else
cd "$PLUGINS_PATH"/fzf-tab || exit 1
if [ ! -d .git ]; then
echo "fzf-tab is not a git repository. Please remove $PLUGINS_PATH/fzf-tab and try again."
exit 1
# git clone powerlevel10k
if [ ! -d "$ZSH_PLUGINS_PATH"/fzf-tab ]; then
echo "fzf-tab is not downloaded. Downloading..."
git clone https://github.com/Aloxaf/fzf-tab.git "$ZSH_PLUGINS_PATH"/fzf-tab
else
echo "fzf-tab is already exist. Updating..."
git pull
cd "$ZSH_PLUGINS_PATH"/fzf-tab || return
if [ ! -d .git ]; then
echo "fzf-tab is not a git repository. Please remove $ZSH_PLUGINS_PATH/fzf-tab and try again."
return
else
echo "fzf-tab is already exist. Updating..."
git pull
fi
fi
fi
# git clone oh-my-zsh
if [ ! -d "$PLUGINS_PATH"/ohmyzsh ]; then
echo "Oh My Zsh is not downloaded. Downloading..."
# git clone https://github.com/ohmyzsh/ohmyzsh.git "$PATH_OHMYZSH"
git clone https://gitee.com/mirrors/ohmyzsh.git "$PLUGINS_PATH"/ohmyzsh
else
cd "$PLUGINS_PATH"/ohmyzsh || exit 2
if [ ! -d .git ]; then
echo "Oh My Zsh is not a git repository. Please remove $PLUGINS_PATH/ohmyzsh and try again."
exit 1
# git clone oh-my-zsh
if [ ! -d "$ZSH_PLUGINS_PATH"/ohmyzsh ]; then
echo "Oh My Zsh is not downloaded. Downloading..."
# git clone https://github.com/ohmyzsh/ohmyzsh.git "$PATH_OHMYZSH"
git clone https://gitee.com/mirrors/ohmyzsh.git "$ZSH_PLUGINS_PATH"/ohmyzsh
else
echo "Oh My Zsh is already exist. Updating..."
git pull
cd "$ZSH_PLUGINS_PATH"/ohmyzsh || return
if [ ! -d .git ]; then
echo "Oh My Zsh is not a git repository. Please remove $ZSH_PLUGINS_PATH/ohmyzsh and try again."
return
else
echo "Oh My Zsh is already exist. Updating..."
git pull
fi
fi
fi
}