# /bin/bash function install_zellij() { set -e # 启用错误检查 # 检查依赖项 if ! command -v wget &> /dev/null; then echo "Error: wget is required. Please install it first." exit 1 fi # 安装 Zellij if [ ! -f /usr/local/bin/zellij ]; then echo "Downloading Zellij..." temp_dir=$(mktemp -d) trap "rm -rf $temp_dir" EXIT # 退出时清理临时目录 if ! wget -qO "$temp_dir/zellij.tar.gz" "https://fs.n1.tianyunperfect.cn:10086/2025/zellij-x86_64-unknown-linux-musl.tar.gz"; then echo "Download failed. Exiting." exit 1 fi tar -zxvf "$temp_dir/zellij.tar.gz" -C "$temp_dir" sudo mv "$temp_dir/zellij" /usr/local/bin/ fi # 配置 Shell local shell_rc if [ -n "$ZSH_VERSION" ]; then shell_rc=~/.zshrc elif [ -n "$BASH_VERSION" ]; then shell_rc=~/.bashrc else echo "Unsupported shell. Manual configuration required." exit 1 fi # 避免重复追加 if ! grep -q "zin()" "$shell_rc"; then cat <<'EOF' >>"$shell_rc" function zin() { export ZELLIJ_AUTO_ATTACH=true eval "$(zellij setup --generate-auto-start $(basename $SHELL))" } EOF fi source "$shell_rc" echo "Installation complete. Run 'zin' to start Zellij." } install_zellij