Compare commits
30 Commits
4b401aa1cb
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9641876d43 | ||
|
|
d8238c545a | ||
|
|
76549f5438 | ||
|
|
a7dcd7c271 | ||
|
|
8c84b3dbf6 | ||
|
|
a8ed0f080a | ||
|
|
b017fb1592 | ||
|
|
d1537fa0a3 | ||
|
|
847ec3b650 | ||
|
|
f12bbb6ac1 | ||
|
|
6f34409205 | ||
|
|
3d5cf87929 | ||
|
|
3b820fce60 | ||
|
|
ad6d3fe8fc | ||
|
|
1043318893 | ||
|
|
5a66025db5 | ||
|
|
5e94ac33a6 | ||
|
|
5088da8a75 | ||
|
|
18a56766c6 | ||
|
|
bff631f971 | ||
|
|
4eb890e26a | ||
|
|
e3e219e55b | ||
|
|
1bd3a2dcb8 | ||
|
|
e515a8b4bc | ||
|
|
158a1388bc | ||
|
|
68625d2e21 | ||
|
|
0492b6a053 | ||
|
|
5f22fb4d7e | ||
|
|
d160d1795b | ||
|
|
4a063ea8d5 |
33
.zshrc
33
.zshrc
@@ -1,9 +1,14 @@
|
||||
# Homebrew initialization
|
||||
if [ -d '/opt/homebrew' ]; then
|
||||
eval "$(/opt/homebrew/bin/brew shellenv)"
|
||||
fi
|
||||
|
||||
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
|
||||
# Initialization code that may require console input (password prompts, [y/n]
|
||||
# confirmations, etc.) must go above this block; everything else may go below.
|
||||
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
|
||||
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
|
||||
fi
|
||||
# if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
|
||||
# source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
|
||||
# fi
|
||||
|
||||
export TERM="xterm-256color"
|
||||
# If you come from bash you might have to change your $PATH.
|
||||
@@ -64,12 +69,11 @@ plugins=(
|
||||
# zsh-completions INSTALL METHOD CHANGED https://github.com/zsh-users/zsh-completions/issues/603
|
||||
zsh-autosuggestions
|
||||
zsh-syntax-highlighting
|
||||
history-substring-search
|
||||
systemd
|
||||
k
|
||||
extract
|
||||
z
|
||||
sudo
|
||||
# history-substring-search
|
||||
# systemd
|
||||
# k
|
||||
# extract
|
||||
# sudo
|
||||
fzf-tab
|
||||
# web-search
|
||||
# httpie
|
||||
@@ -137,6 +141,12 @@ plugins=(
|
||||
|
||||
|
||||
fpath+=$ZSH/custom/plugins/zsh-completions/src
|
||||
|
||||
# Setup Homebrew completions for macOS
|
||||
if [[ "$OSTYPE" == "darwin"* ]] && command -v brew &> /dev/null; then
|
||||
FPATH="$(brew --prefix)/share/zsh/site-functions:${FPATH}"
|
||||
fi
|
||||
|
||||
autoload -U compinit && compinit -C -d ~/.cache/zsh/.zcompdump # zsh-completions
|
||||
# autoload bashcompinit # bash completions
|
||||
# bashcompinit
|
||||
@@ -150,7 +160,7 @@ alias myip="wget -qO- https://wtfismyip.com/text" # quickly show external ip add
|
||||
alias l="ls --hyperlink=auto -lAhrtF" # show all except . .. , sort by recent, / at the end of folders, clickable
|
||||
alias e="exit"
|
||||
alias ip="ip --color=auto"
|
||||
## Install EZA to use this. The better ls command
|
||||
## EZA - the better ls command
|
||||
alias a='eza -la --git --colour-scale all -g --smart-group --icons always --hyperlink' # the new ls; add --hyperlink if you like
|
||||
alias aa='eza -la --git --colour-scale all -g --smart-group --icons always -s modified -r --hyperlink' # sort by new
|
||||
|
||||
@@ -215,4 +225,7 @@ source $ZSH/oh-my-zsh.sh
|
||||
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
|
||||
export FZF_DEFAULT_OPS="--extended"
|
||||
|
||||
# Initialize zoxide (smarter cd command)
|
||||
eval "$(zoxide init zsh)"
|
||||
|
||||
alias k="k -h" # show human readable file sizes, in kb, mb etc
|
||||
166
install.sh
166
install.sh
@@ -1,5 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Save the original working directory
|
||||
ORIGINAL_DIR="$(pwd)"
|
||||
|
||||
# Flags to determine if the arguments were passed
|
||||
cp_hist_flag=false
|
||||
noninteractive_flag=false
|
||||
@@ -39,44 +42,133 @@ detect_os() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to install packages
|
||||
install_packages() {
|
||||
# Install eza using package manager or fallback methods
|
||||
install_eza() {
|
||||
local os=$(detect_os)
|
||||
echo "Installing eza..."
|
||||
|
||||
case $os in
|
||||
macos)
|
||||
if ! command -v brew &> /dev/null; then
|
||||
echo "Homebrew is not installed. Installing Homebrew..."
|
||||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
||||
fi
|
||||
brew install zsh git wget fontconfig
|
||||
brew install eza
|
||||
;;
|
||||
ubuntu|debian)
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y zsh git wget fontconfig
|
||||
if ! sudo apt-get install -y eza; then
|
||||
echo "Package manager installation failed, attempting fallback..."
|
||||
# Install cargo if it doesn't exist
|
||||
if ! command -v cargo &> /dev/null; then
|
||||
echo "Installing Rust and cargo..."
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y curl build-essential
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
||||
source ~/.cargo/env
|
||||
fi
|
||||
cargo install eza
|
||||
fi
|
||||
;;
|
||||
fedora)
|
||||
sudo dnf install -y zsh git wget fontconfig
|
||||
if ! sudo dnf install -y eza; then
|
||||
echo "Package manager installation failed, attempting fallback..."
|
||||
if command -v cargo &> /dev/null; then
|
||||
cargo install eza
|
||||
else
|
||||
wget -qO- https://github.com/eza-community/eza/releases/latest/download/eza_x86_64-unknown-linux-gnu.tar.gz | tar xz
|
||||
sudo install -m 755 eza /usr/local/bin/eza
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
centos|rhel)
|
||||
sudo yum install -y zsh git wget fontconfig
|
||||
if ! sudo yum install -y eza; then
|
||||
echo "Package manager installation failed, attempting fallback..."
|
||||
if command -v cargo &> /dev/null; then
|
||||
cargo install eza
|
||||
else
|
||||
wget -qO- https://github.com/eza-community/eza/releases/latest/download/eza_x86_64-unknown-linux-gnu.tar.gz | tar xz
|
||||
sudo install -m 755 eza /usr/local/bin/eza
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
arch|manjaro)
|
||||
sudo pacman -Syu --noconfirm zsh git wget fontconfig
|
||||
if ! sudo pacman -Syu --noconfirm eza; then
|
||||
echo "Package manager installation failed, attempting fallback..."
|
||||
wget -qO- https://github.com/eza-community/eza/releases/latest/download/eza_x86_64-unknown-linux-gnu.tar.gz | tar xz
|
||||
sudo install -m 755 eza /usr/local/bin/eza
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported operating system. Please install zsh, git, wget, and fontconfig manually."
|
||||
exit 1
|
||||
echo "Unsupported operating system for package manager installation, using fallback..."
|
||||
wget -qO- https://github.com/eza-community/eza/releases/latest/download/eza_x86_64-unknown-linux-gnu.tar.gz | tar xz
|
||||
sudo install -m 755 eza /usr/local/bin/eza
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Helper: install zoxide if the package manager couldn't provide it
|
||||
install_zoxide_fallback() {
|
||||
local os=$(detect_os)
|
||||
echo "Attempting fallback installation of zoxide..."
|
||||
case $os in
|
||||
fedora)
|
||||
sudo dnf install -y zoxide || curl -sSfL https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | sh
|
||||
;;
|
||||
centos|rhel)
|
||||
if command -v dnf &> /dev/null && sudo dnf install -y zoxide; then :; else
|
||||
curl -sSfL https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | sh
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
curl -sSfL https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | sh
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Core: install required packages via the preferred package manager, then fall back where needed
|
||||
install_packages() {
|
||||
local os=$(detect_os)
|
||||
local base_packages="zsh git wget fontconfig zoxide autoconf"
|
||||
|
||||
case $os in
|
||||
macos)
|
||||
if ! command -v brew &> /dev/null; then
|
||||
echo "Homebrew is not installed. Installing Homebrew..."
|
||||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
||||
fi
|
||||
brew install ${base_packages}
|
||||
;;
|
||||
ubuntu|debian)
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y ${base_packages}
|
||||
;;
|
||||
fedora)
|
||||
sudo dnf install -y ${base_packages}
|
||||
;;
|
||||
centos|rhel)
|
||||
sudo yum install -y ${base_packages}
|
||||
;;
|
||||
arch|manjaro)
|
||||
sudo pacman -Syu --noconfirm ${base_packages}
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported operating system. Please install ${base_packages} manually."
|
||||
;;
|
||||
esac
|
||||
|
||||
# Fallbacks for any tools that are still missing after the package-manager step
|
||||
command -v eza &> /dev/null || install_eza
|
||||
command -v zoxide &> /dev/null || install_zoxide_fallback
|
||||
}
|
||||
|
||||
# Check if required packages are installed, if not, install them
|
||||
if command -v zsh &> /dev/null && command -v git &> /dev/null && command -v wget &> /dev/null && command -v fc-cache &> /dev/null; then
|
||||
echo -e "ZSH, Git, wget, and fontconfig are already installed\n"
|
||||
if command -v zsh &> /dev/null && command -v git &> /dev/null && command -v wget &> /dev/null && command -v fc-cache &> /dev/null && command -v eza &> /dev/null && command -v zoxide &> /dev/null && command -v autoconf &> /dev/null; then
|
||||
echo -e "ZSH, Git, wget, fontconfig, eza, zoxide, and autoconf are already installed\n"
|
||||
else
|
||||
echo "Installing required packages..."
|
||||
install_packages
|
||||
echo -e "zsh, wget, git, and fontconfig Installed\n"
|
||||
echo -e "zsh, wget, git, fontconfig, eza, zoxide, and autoconf Installed\n"
|
||||
fi
|
||||
|
||||
if [ -f ~/.gitconfig.backup ]; then
|
||||
@@ -128,25 +220,25 @@ if [ -f ~/.zcompdump ]; then
|
||||
fi
|
||||
|
||||
if [ -d $ZSH/plugins/zsh-autosuggestions ]; then
|
||||
cd $ZSH/plugins/zsh-autosuggestions && git pull
|
||||
git -C $ZSH/plugins/zsh-autosuggestions pull
|
||||
else
|
||||
git clone --depth=1 https://github.com/zsh-users/zsh-autosuggestions $ZSH/plugins/zsh-autosuggestions
|
||||
fi
|
||||
|
||||
if [ -d $ZSH/custom/plugins/zsh-syntax-highlighting ]; then
|
||||
cd $ZSH/custom/plugins/zsh-syntax-highlighting && git pull
|
||||
git -C $ZSH/custom/plugins/zsh-syntax-highlighting pull
|
||||
else
|
||||
git clone --depth=1 https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH/custom/plugins/zsh-syntax-highlighting
|
||||
fi
|
||||
|
||||
if [ -d $ZSH/custom/plugins/zsh-completions ]; then
|
||||
cd $ZSH/custom/plugins/zsh-completions && git pull
|
||||
git -C $ZSH/custom/plugins/zsh-completions pull
|
||||
else
|
||||
git clone --depth=1 https://github.com/zsh-users/zsh-completions $ZSH/custom/plugins/zsh-completions
|
||||
fi
|
||||
|
||||
if [ -d $ZSH/custom/plugins/zsh-history-substring-search ]; then
|
||||
cd $ZSH/custom/plugins/zsh-history-substring-search && git pull
|
||||
git -C $ZSH/custom/plugins/zsh-history-substring-search pull
|
||||
else
|
||||
git clone --depth=1 https://github.com/zsh-users/zsh-history-substring-search $ZSH/custom/plugins/zsh-history-substring-search
|
||||
fi
|
||||
@@ -156,21 +248,41 @@ fi
|
||||
|
||||
echo -e "Installing Nerd Fonts version of Hack, Roboto Mono, DejaVu Sans Mono\n"
|
||||
|
||||
# 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
|
||||
|
||||
if [ -d $ZSH/custom/themes/powerlevel10k ]; then
|
||||
cd $ZSH/custom/themes/powerlevel10k && git pull
|
||||
git -C $ZSH/custom/themes/powerlevel10k pull
|
||||
else
|
||||
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git $ZSH/custom/themes/powerlevel10k
|
||||
fi
|
||||
curl -s https://git.miomio.moe/mio/easyzsh/raw/branch/master/patch.sh | bash -s p10k
|
||||
|
||||
if [ -d ~/.fzf ]; then
|
||||
cd ~/.fzf && git pull
|
||||
git -C ~/.fzf pull
|
||||
~/.fzf/install --all --key-bindings --completion --no-update-rc
|
||||
else
|
||||
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
|
||||
@@ -178,17 +290,28 @@ else
|
||||
fi
|
||||
|
||||
if [ -d $ZSH/custom/plugins/k ]; then
|
||||
cd $ZSH/custom/plugins/k && git pull
|
||||
git -C $ZSH/custom/plugins/k pull
|
||||
else
|
||||
git clone --depth 1 https://github.com/supercrabtree/k $ZSH/custom/plugins/k
|
||||
fi
|
||||
|
||||
if [ -d $ZSH/custom/plugins/fzf-tab ]; then
|
||||
cd $ZSH/custom/plugins/fzf-tab && git pull
|
||||
git -C $ZSH/custom/plugins/fzf-tab pull
|
||||
else
|
||||
git clone --depth 1 https://github.com/Aloxaf/fzf-tab $ZSH/custom/plugins/fzf-tab
|
||||
fi
|
||||
|
||||
# Import existing z data into zoxide if available
|
||||
if command -v zoxide &> /dev/null; then
|
||||
for z_file in ~/.z ~/.local/share/z/data ~/.zlua ~/.fasd; do
|
||||
if [ -f "$z_file" ]; then
|
||||
echo -e "Importing existing z data from $z_file into zoxide\n"
|
||||
zoxide import --from=z "$z_file" 2>/dev/null || echo "Failed to import $z_file, continuing..."
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
|
||||
# if git clone --depth 1 https://github.com/todotxt/todo.txt-cli.git ~/.config/ezsh/todo; then :
|
||||
@@ -242,4 +365,7 @@ else
|
||||
|
||||
fi
|
||||
fi
|
||||
|
||||
# Restore original working directory
|
||||
cd "$ORIGINAL_DIR"
|
||||
exit
|
||||
230
install/fnm.sh
Normal file
230
install/fnm.sh
Normal file
@@ -0,0 +1,230 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
RELEASE="latest"
|
||||
OS="$(uname -s)"
|
||||
|
||||
case "${OS}" in
|
||||
MINGW* | Win*) OS="Windows" ;;
|
||||
esac
|
||||
|
||||
if [ -d "$HOME/.fnm" ]; then
|
||||
INSTALL_DIR="$HOME/.fnm"
|
||||
elif [ -n "$XDG_DATA_HOME" ]; then
|
||||
INSTALL_DIR="$XDG_DATA_HOME/fnm"
|
||||
elif [ "$OS" = "Darwin" ]; then
|
||||
INSTALL_DIR="$HOME/Library/Application Support/fnm"
|
||||
else
|
||||
INSTALL_DIR="$HOME/.local/share/fnm"
|
||||
fi
|
||||
|
||||
# Parse Flags
|
||||
parse_args() {
|
||||
while [[ $# -gt 0 ]]; do
|
||||
key="$1"
|
||||
|
||||
case $key in
|
||||
-d | --install-dir)
|
||||
INSTALL_DIR="$2"
|
||||
shift # past argument
|
||||
shift # past value
|
||||
;;
|
||||
-s | --skip-shell)
|
||||
SKIP_SHELL="true"
|
||||
shift # past argument
|
||||
;;
|
||||
--force-install | --force-no-brew)
|
||||
echo "\`--force-install\`: I hope you know what you're doing." >&2
|
||||
FORCE_INSTALL="true"
|
||||
shift
|
||||
;;
|
||||
-r | --release)
|
||||
RELEASE="$2"
|
||||
shift # past release argument
|
||||
shift # past release value
|
||||
;;
|
||||
*)
|
||||
echo "Unrecognized argument $key"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
set_filename() {
|
||||
if [ "$OS" = "Linux" ]; then
|
||||
# Based on https://stackoverflow.com/a/45125525
|
||||
case "$(uname -m)" in
|
||||
arm | armv7*)
|
||||
FILENAME="fnm-arm32"
|
||||
;;
|
||||
aarch* | armv8*)
|
||||
FILENAME="fnm-arm64"
|
||||
;;
|
||||
*)
|
||||
FILENAME="fnm-linux"
|
||||
esac
|
||||
elif [ "$OS" = "Darwin" ] && [ "$FORCE_INSTALL" = "true" ]; then
|
||||
FILENAME="fnm-macos"
|
||||
USE_HOMEBREW="false"
|
||||
echo "Downloading the latest fnm binary from GitHub..."
|
||||
echo " Pro tip: it's easier to use Homebrew for managing fnm in macOS."
|
||||
echo " Remove the \`--force-no-brew\` so it will be easy to upgrade."
|
||||
elif [ "$OS" = "Darwin" ]; then
|
||||
USE_HOMEBREW="true"
|
||||
echo "Downloading fnm using Homebrew..."
|
||||
elif [ "$OS" = "Windows" ] ; then
|
||||
FILENAME="fnm-windows"
|
||||
echo "Downloading the latest fnm binary from GitHub..."
|
||||
else
|
||||
echo "OS $OS is not supported."
|
||||
echo "If you think that's a bug - please file an issue to https://github.com/Schniz/fnm/issues"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
download_fnm() {
|
||||
if [ "$USE_HOMEBREW" = "true" ]; then
|
||||
brew install fnm
|
||||
else
|
||||
if [ "$RELEASE" = "latest" ]; then
|
||||
URL="https://github.com/Schniz/fnm/releases/latest/download/$FILENAME.zip"
|
||||
else
|
||||
URL="https://github.com/Schniz/fnm/releases/download/$RELEASE/$FILENAME.zip"
|
||||
fi
|
||||
|
||||
DOWNLOAD_DIR=$(mktemp -d)
|
||||
|
||||
echo "Downloading $URL..."
|
||||
|
||||
mkdir -p "$INSTALL_DIR" &>/dev/null
|
||||
|
||||
if ! curl --progress-bar --fail -L "$URL" -o "$DOWNLOAD_DIR/$FILENAME.zip"; then
|
||||
echo "Download failed. Check that the release/filename are correct."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
unzip -q "$DOWNLOAD_DIR/$FILENAME.zip" -d "$DOWNLOAD_DIR"
|
||||
|
||||
if [ -f "$DOWNLOAD_DIR/fnm" ]; then
|
||||
mv "$DOWNLOAD_DIR/fnm" "$INSTALL_DIR/fnm"
|
||||
else
|
||||
mv "$DOWNLOAD_DIR/$FILENAME/fnm" "$INSTALL_DIR/fnm"
|
||||
fi
|
||||
|
||||
chmod u+x "$INSTALL_DIR/fnm"
|
||||
fi
|
||||
}
|
||||
|
||||
check_dependencies() {
|
||||
echo "Checking dependencies for the installation script..."
|
||||
|
||||
echo -n "Checking availability of curl... "
|
||||
if hash curl 2>/dev/null; then
|
||||
echo "OK!"
|
||||
else
|
||||
echo "Missing!"
|
||||
SHOULD_EXIT="true"
|
||||
fi
|
||||
|
||||
echo -n "Checking availability of unzip... "
|
||||
if hash unzip 2>/dev/null; then
|
||||
echo "OK!"
|
||||
else
|
||||
echo "Missing!"
|
||||
SHOULD_EXIT="true"
|
||||
fi
|
||||
|
||||
if [ "$USE_HOMEBREW" = "true" ]; then
|
||||
echo -n "Checking availability of Homebrew (brew)... "
|
||||
if hash brew 2>/dev/null; then
|
||||
echo "OK!"
|
||||
else
|
||||
echo "Missing!"
|
||||
SHOULD_EXIT="true"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$SHOULD_EXIT" = "true" ]; then
|
||||
echo "Not installing fnm due to missing dependencies."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
ensure_containing_dir_exists() {
|
||||
local CONTAINING_DIR
|
||||
CONTAINING_DIR="$(dirname "$1")"
|
||||
if [ ! -d "$CONTAINING_DIR" ]; then
|
||||
echo " >> Creating directory $CONTAINING_DIR"
|
||||
mkdir -p "$CONTAINING_DIR"
|
||||
fi
|
||||
}
|
||||
|
||||
setup_shell() {
|
||||
CURRENT_SHELL="$(basename "$SHELL")"
|
||||
|
||||
if [ "$CURRENT_SHELL" = "zsh" ]; then
|
||||
CONF_FILE=${ZDOTDIR:-$HOME}/.zshrc
|
||||
ensure_containing_dir_exists "$CONF_FILE"
|
||||
echo "Installing for Zsh. Appending the following to $CONF_FILE:"
|
||||
{
|
||||
echo ''
|
||||
echo '# fnm'
|
||||
echo 'FNM_PATH="'"$INSTALL_DIR"'"'
|
||||
echo 'if [ -d "$FNM_PATH" ]; then'
|
||||
echo ' export PATH="'$INSTALL_DIR':$PATH"'
|
||||
echo ' eval "`fnm env`"'
|
||||
echo 'fi'
|
||||
} | tee -a "$CONF_FILE"
|
||||
|
||||
elif [ "$CURRENT_SHELL" = "fish" ]; then
|
||||
CONF_FILE=$HOME/.config/fish/conf.d/fnm.fish
|
||||
ensure_containing_dir_exists "$CONF_FILE"
|
||||
echo "Installing for Fish. Appending the following to $CONF_FILE:"
|
||||
{
|
||||
echo ''
|
||||
echo '# fnm'
|
||||
echo 'set FNM_PATH "'"$INSTALL_DIR"'"'
|
||||
echo 'if [ -d "$FNM_PATH" ]'
|
||||
echo ' set PATH "$FNM_PATH" $PATH'
|
||||
echo ' fnm env | source'
|
||||
echo 'end'
|
||||
} | tee -a "$CONF_FILE"
|
||||
|
||||
elif [ "$CURRENT_SHELL" = "bash" ]; then
|
||||
if [ "$OS" = "Darwin" ]; then
|
||||
CONF_FILE=$HOME/.profile
|
||||
else
|
||||
CONF_FILE=$HOME/.bashrc
|
||||
fi
|
||||
ensure_containing_dir_exists "$CONF_FILE"
|
||||
echo "Installing for Bash. Appending the following to $CONF_FILE:"
|
||||
{
|
||||
echo ''
|
||||
echo '# fnm'
|
||||
echo 'FNM_PATH="'"$INSTALL_DIR"'"'
|
||||
echo 'if [ -d "$FNM_PATH" ]; then'
|
||||
echo ' export PATH="$FNM_PATH:$PATH"'
|
||||
echo ' eval "`fnm env`"'
|
||||
echo 'fi'
|
||||
} | tee -a "$CONF_FILE"
|
||||
|
||||
else
|
||||
echo "Could not infer shell type. Please set up manually."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "In order to apply the changes, open a new terminal or run the following command:"
|
||||
echo ""
|
||||
echo " source $CONF_FILE"
|
||||
}
|
||||
|
||||
parse_args "$@"
|
||||
set_filename
|
||||
check_dependencies
|
||||
download_fnm
|
||||
if [ "$SKIP_SHELL" != "true" ]; then
|
||||
setup_shell
|
||||
fi
|
||||
85
install_fnm.sh
Executable file
85
install_fnm.sh
Executable file
@@ -0,0 +1,85 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Save the original working directory
|
||||
ORIGINAL_DIR="$(pwd)"
|
||||
|
||||
# Function to detect the operating system
|
||||
detect_os() {
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
echo "macos"
|
||||
elif [[ -f /etc/os-release ]]; then
|
||||
. /etc/os-release
|
||||
echo "$ID"
|
||||
else
|
||||
echo "unknown"
|
||||
fi
|
||||
}
|
||||
|
||||
# Install fnm (Fast Node Manager) if it is not already installed
|
||||
if command -v fnm &> /dev/null; then
|
||||
echo -e "fnm is already installed\n"
|
||||
fnm --version
|
||||
else
|
||||
echo -e "Installing fnm (Fast Node Manager)\n"
|
||||
|
||||
os=$(detect_os)
|
||||
|
||||
case $os in
|
||||
macos)
|
||||
# Try homebrew first on macOS
|
||||
if command -v brew &> /dev/null; then
|
||||
echo "Installing fnm via Homebrew..."
|
||||
brew install fnm
|
||||
else
|
||||
echo "Installing fnm via official installer..."
|
||||
curl -fsSL https://git.miomio.moe/mio/easyzsh/raw/branch/master/install/fnm.sh | bash
|
||||
fi
|
||||
;;
|
||||
ubuntu|debian)
|
||||
# Use the official installer for Linux
|
||||
echo "Installing fnm via official installer..."
|
||||
curl -fsSL https://git.miomio.moe/mio/easyzsh/raw/branch/master/install/fnm.sh | bash
|
||||
;;
|
||||
fedora|centos|rhel)
|
||||
# Use the official installer for RHEL-based distros
|
||||
echo "Installing fnm via official installer..."
|
||||
curl -fsSL https://git.miomio.moe/mio/easyzsh/raw/branch/master/install/fnm.sh | bash
|
||||
;;
|
||||
arch|manjaro)
|
||||
# Use the official installer for Arch-based distros
|
||||
echo "Installing fnm via official installer..."
|
||||
curl -fsSL https://git.miomio.moe/mio/easyzsh/raw/branch/master/install/fnm.sh | bash
|
||||
;;
|
||||
*)
|
||||
echo "Using official installer for unknown OS..."
|
||||
curl -fsSL https://git.miomio.moe/mio/easyzsh/raw/branch/master/install/fnm.sh | bash
|
||||
;;
|
||||
esac
|
||||
|
||||
# Load fnm for the remainder of this script
|
||||
export PATH="$HOME/.local/share/fnm:$PATH"
|
||||
eval "$(fnm env --use-on-cd)"
|
||||
fi
|
||||
|
||||
# OPTIONAL: Install the latest LTS version of Node.js
|
||||
# Uncomment the following lines if you would like to automatically install it
|
||||
# echo "Installing latest LTS Node.js version..."
|
||||
# fnm install --lts
|
||||
# fnm use lts-latest
|
||||
# fnm default lts-latest
|
||||
|
||||
# Apply the fnm zsh configuration patch (downloads zshrc/fnm.zsh to ~/.config/zshrc/fnm.zsh)
|
||||
curl -fsSL https://git.miomio.moe/mio/easyzsh/raw/branch/master/patch.sh | bash -s fnm
|
||||
|
||||
echo -e "\nfnm installation completed!"
|
||||
echo -e "To start using fnm, restart your terminal or run: source ~/.zshrc"
|
||||
echo -e "\nUseful fnm commands:"
|
||||
echo -e " fnm install --lts # Install latest LTS Node.js"
|
||||
echo -e " fnm install 18 # Install Node.js v18"
|
||||
echo -e " fnm use 18 # Use Node.js v18"
|
||||
echo -e " fnm default 18 # Set Node.js v18 as default"
|
||||
echo -e " fnm list # List installed versions"
|
||||
echo -e " fnm list-remote # List available versions"
|
||||
|
||||
# Restore original working directory
|
||||
cd "$ORIGINAL_DIR"
|
||||
50
install_merlin_worker.sh
Executable file
50
install_merlin_worker.sh
Executable file
@@ -0,0 +1,50 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Exit on any error
|
||||
set -e
|
||||
|
||||
# Download and execute the patch script
|
||||
if ! curl -s https://git.miomio.moe/mio/easyzsh/raw/branch/master/patch.sh | bash -s merlin_worker; then
|
||||
echo "Error: Failed to download or execute patch script"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if ~/.bashrc exists and contains PYTHONPATH export
|
||||
if [ -f "$HOME/.bashrc" ]; then
|
||||
# Extract PYTHONPATH from ~/.bashrc (look for export PYTHONPATH=...)
|
||||
BASHRC_PYTHONPATH=$(grep -E "^export PYTHONPATH=" "$HOME/.bashrc" | tail -1)
|
||||
|
||||
if [ -n "$BASHRC_PYTHONPATH" ]; then
|
||||
echo "Found PYTHONPATH in ~/.bashrc: $BASHRC_PYTHONPATH"
|
||||
|
||||
# Path to the merlin_worker.zsh file
|
||||
MERLIN_CONFIG="$HOME/.config/zshrc/merlin_worker.zsh"
|
||||
|
||||
# Create directory if it doesn't exist
|
||||
mkdir -p "$(dirname "$MERLIN_CONFIG")"
|
||||
|
||||
if [ -f "$MERLIN_CONFIG" ]; then
|
||||
# Cross-platform sed: remove existing PYTHONPATH lines
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
# macOS
|
||||
sed -i '' '/^export PYTHONPATH=/d' "$MERLIN_CONFIG"
|
||||
else
|
||||
# Linux/Ubuntu and others
|
||||
sed -i '/^export PYTHONPATH=/d' "$MERLIN_CONFIG"
|
||||
fi
|
||||
|
||||
# Then append the PYTHONPATH from ~/.bashrc
|
||||
echo "$BASHRC_PYTHONPATH" >> "$MERLIN_CONFIG"
|
||||
|
||||
echo "Updated PYTHONPATH in $MERLIN_CONFIG with value from ~/.bashrc"
|
||||
else
|
||||
# Create the file with just the PYTHONPATH
|
||||
echo "$BASHRC_PYTHONPATH" > "$MERLIN_CONFIG"
|
||||
echo "Created $MERLIN_CONFIG with PYTHONPATH from ~/.bashrc"
|
||||
fi
|
||||
else
|
||||
echo "No PYTHONPATH export found in ~/.bashrc"
|
||||
fi
|
||||
else
|
||||
echo "~/.bashrc not found"
|
||||
fi
|
||||
27
install_nvm.sh
Executable file
27
install_nvm.sh
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Save the original working directory
|
||||
ORIGINAL_DIR="$(pwd)"
|
||||
|
||||
# Install nvm (Node Version Manager) if it is not already installed
|
||||
if command -v nvm &> /dev/null; then
|
||||
echo -e "nvm is already installed\n"
|
||||
else
|
||||
echo -e "Installing nvm (Node Version Manager)\n"
|
||||
# Using the official install script (https://github.com/nvm-sh/nvm)
|
||||
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
|
||||
|
||||
# Load nvm for the remainder of this script
|
||||
export NVM_DIR="${XDG_CONFIG_HOME:-$HOME/.nvm}"
|
||||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
||||
fi
|
||||
|
||||
# OPTIONAL: Install the latest LTS version of Node.js
|
||||
# Uncomment the following line if you would like to automatically install it
|
||||
nvm install --lts
|
||||
|
||||
# Apply the "basic" zsh configuration patch (downloads zshrc/basic.zsh to ~/.config/zshrc/basic.zsh)
|
||||
curl -s https://git.miomio.moe/mio/easyzsh/raw/branch/master/patch.sh | bash -s nvm
|
||||
|
||||
# Restore original working directory
|
||||
cd "$ORIGINAL_DIR"
|
||||
28
install_pyenv.sh
Executable file
28
install_pyenv.sh
Executable file
@@ -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"
|
||||
8
zshrc/fnm.zsh
Normal file
8
zshrc/fnm.zsh
Normal file
@@ -0,0 +1,8 @@
|
||||
# fnm (Fast Node Manager) configuration
|
||||
# https://github.com/Schniz/fnm
|
||||
|
||||
FNM_PATH="$HOME/.local/share/fnm"
|
||||
if [ -d "$FNM_PATH" ]; then
|
||||
export PATH="$HOME/.local/share/fnm:$PATH"
|
||||
eval "$(fnm env --use-on-cd --shell zsh)"
|
||||
fi
|
||||
56
zshrc/merlin_devbox.zsh
Normal file
56
zshrc/merlin_devbox.zsh
Normal file
@@ -0,0 +1,56 @@
|
||||
# # Patch prep_env.sh for zsh compatibility (only if not already patched)
|
||||
# _prep_env="/workspace/vscode/prep_env.sh"
|
||||
# if [[ -f "$_prep_env" ]] && ! grep -q '# PATCHED_FOR_ZSH' "$_prep_env" 2>/dev/null; then
|
||||
# sed -i \
|
||||
# -e '1a# PATCHED_FOR_ZSH' \
|
||||
# -e 's/^shopt -s histappend$/[[ -n "${BASH_VERSION}" ]] \&\& shopt -s histappend/' \
|
||||
# -e 's/\${!\([^}]*\)}/\$( [[ -n "\${ZSH_VERSION}" ]] \&\& echo "\${(P)\1}" || echo "\${!\1}" )/g' \
|
||||
# -e 's/cur_dir="\$(cd "\$(dirname "\$0")" && pwd)"/cur_dir="\/workspace\/vscode"/' \
|
||||
# "$_prep_env"
|
||||
# fi
|
||||
|
||||
# # Now source the patched script directly
|
||||
# source "$_prep_env"
|
||||
|
||||
|
||||
|
||||
# Set cur_dir before sourcing so prep_env.sh uses the correct path
|
||||
export cur_dir="/workspace/vscode"
|
||||
|
||||
# Patch prep_env.sh for zsh compatibility before sourcing
|
||||
source <(sed -e 's/^shopt -s histappend$/[[ -n "${BASH_VERSION}" ]] \&\& shopt -s histappend/' \
|
||||
-e 's/\${!\([^}]*\)}/${(P)\1}/g' \
|
||||
-e 's/cur_dir="\$(cd "\$(dirname "\$0")" && pwd)"/# cur_dir already set/g' \
|
||||
/workspace/mlx/../vscode/prep_env.sh)
|
||||
|
||||
# sh -c /opt/tiger/mlx_deploy/greeting.sh
|
||||
|
||||
if [ -f "/opt/tiger/mlx_deploy/pythonpath_rc" ]; then
|
||||
source /opt/tiger/mlx_deploy/pythonpath_rc
|
||||
fi
|
||||
|
||||
if [ -f "/opt/tiger/rh2_bashrc" ]; then
|
||||
source /opt/tiger/rh2_bashrc
|
||||
fi
|
||||
|
||||
. "$HOME/.cargo/env"
|
||||
|
||||
# huggingface proxy
|
||||
export HF_NETWORK_PROXY=http://huggingface-proxy-sg.byted.org
|
||||
export HF_MIRROR_INTERNAL=http://huggingface-mirror.bytedance.net
|
||||
export HF_MIRROR_EXTERNAL=https://hf-mirror.com
|
||||
export HF_ENDPOINT=$HF_NETWORK_PROXY
|
||||
alias hf_network_proxy='export HF_ENDPOINT=$HF_NETWORK_PROXY'
|
||||
alias hf_mirror_internal='export HF_ENDPOINT=$HF_MIRROR_INTERNAL'
|
||||
alias hf_mirror_external='export HF_ENDPOINT=$HF_MIRROR_EXTERNAL'
|
||||
|
||||
# http proxy
|
||||
export HTTP_PROXY=http://sys-proxy-rd-relay.byted.org:8118
|
||||
export HTTPS_PROXY=http://sys-proxy-rd-relay.byted.org:8118
|
||||
export NO_PROXY=byted.org,bytedance.net,10.*.*.*,127.*.*.*
|
||||
export http_proxy=http://sys-proxy-rd-relay.byted.org:8118
|
||||
export https_proxy=http://sys-proxy-rd-relay.byted.org:8118
|
||||
export no_proxy=byted.org,bytedance.net,10.*.*.*,127.*.*.*
|
||||
|
||||
alias proxy_on='export http_proxy=http://sys-proxy-rd-relay.byted.org:8118; export https_proxy=http://sys-proxy-rd-relay.byted.org:8118; export no_proxy=byted.org,bytedance.net,10.*.*.*,127.*.*.*; export HTTP_PROXY=http://sys-proxy-rd-relay.byted.org:8118; export HTTPS_PROXY=http://sys-proxy-rd-relay.byted.org:8118; export NO_PROXY=byted.org,bytedance.net,10.*.*.*,127.*.*.*'
|
||||
alias proxy_off='unset http_proxy; unset https_proxy; unset no_proxy; unset HTTP_PROXY; unset HTTPS_PROXY; unset NO_PROXY'
|
||||
38
zshrc/merlin_worker.zsh
Normal file
38
zshrc/merlin_worker.zsh
Normal file
@@ -0,0 +1,38 @@
|
||||
# specific aliases
|
||||
alias save_log=/opt/tiger/rh2/rh2/init/log.sh
|
||||
alias stdout='tail -f /var/log/tiger/stdout'
|
||||
alias stderr='tail -f /var/log/tiger/stderr'
|
||||
|
||||
# Essential environment variables
|
||||
export MERLIN_PROFILING_HDFS_DIR='hdfs://haruna/home/byte_merlin_profiling/'
|
||||
export RH2_ENV_JSON=/opt/tiger/rh2/env_json
|
||||
export MLX_USER_TOKEN=bd2a3f1b71d54ab497f13f2eefc4f5bc
|
||||
export RH2_TENSORBOARD_HDFS=hdfs://haruna/home/byte_aml_platform/public/rh2_prod/8b6d8490dc2904e0/tensorboard/20250527/903e5003c90ff1dc/arnold_trial/46714689
|
||||
export SPARK_HOME=/opt/tiger/spark_deploy/spark-3.2/spark-stable
|
||||
export PATH=/opt/common_tools:/opt/tiger/typhoon-blade:/usr/lib/x86_64-linux-gnu/openmpi/bin:/usr/local/cuda/bin:/home/tiger/system_op/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/tiger/arnold/arnold_entrypoint/tools:/opt/tiger/arnold/hdfs_client:/opt/tiger/yarn_deploy/hadoop/bin:/opt/tiger/yarn_deploy/hive/bin:/home/tiger/.local/bin:/opt/tiger/nastk/bin:/python:/opt/tiger/mlx_deploy/bin
|
||||
export PYSPARK_DRIVER_PYTHON=/usr/bin/python3
|
||||
export PYSPARK_PYTHON=/usr/bin/python3
|
||||
export PYTHONPATH=::/opt/tiger/arnold_toolbox:/opt/tiger/rh2:/opt/tiger/rh2:/opt/tiger/pyutil:/python:/python/lib/py4j-0.10.9-src.zip
|
||||
export PATH=/opt/tiger/arnold/arnold_entrypoint/debugger/cloudide/release-standalone/bin/remote-cli:$PATH
|
||||
export PYTHONPATH=$PYTHONPATH:/opt/tiger/pyutil:/opt/tiger/rh2:/opt/tiger/arnold_toolbox
|
||||
|
||||
# huggingface proxy
|
||||
export HF_NETWORK_PROXY=http://huggingface-proxy-sg.byted.org
|
||||
export HF_MIRROR_INTERNAL=http://huggingface-mirror.bytedance.net
|
||||
export HF_MIRROR_EXTERNAL=https://hf-mirror.com
|
||||
export HF_ENDPOINT=$HF_NETWORK_PROXY
|
||||
alias hf_network_proxy='export HF_ENDPOINT=$HF_NETWORK_PROXY'
|
||||
alias hf_mirror_internal='export HF_ENDPOINT=$HF_MIRROR_INTERNAL'
|
||||
alias hf_mirror_external='export HF_ENDPOINT=$HF_MIRROR_EXTERNAL'
|
||||
|
||||
# http proxy
|
||||
export HF_ENDPOINT=http://huggingface-proxy-sg.byted.org
|
||||
export HTTP_PROXY=http://sys-proxy-rd-relay.byted.org:8118
|
||||
export HTTPS_PROXY=http://sys-proxy-rd-relay.byted.org:8118
|
||||
export NO_PROXY=byted.org,bytedance.net,10.*.*.*,127.*.*.*
|
||||
export http_proxy=http://sys-proxy-rd-relay.byted.org:8118
|
||||
export https_proxy=http://sys-proxy-rd-relay.byted.org:8118
|
||||
export no_proxy=byted.org,bytedance.net,10.*.*.*,127.*.*.*
|
||||
|
||||
alias proxy_on='export http_proxy=http://sys-proxy-rd-relay.byted.org:8118; export https_proxy=http://sys-proxy-rd-relay.byted.org:8118; export no_proxy=byted.org,bytedance.net,10.*.*.*,127.*.*.*; export HTTP_PROXY=http://sys-proxy-rd-relay.byted.org:8118; export HTTPS_PROXY=http://sys-proxy-rd-relay.byted.org:8118; export NO_PROXY=byted.org,bytedance.net,10.*.*.*,127.*.*.*'
|
||||
alias proxy_off='unset http_proxy; unset https_proxy; unset no_proxy; unset HTTP_PROXY; unset HTTPS_PROXY; unset NO_PROXY'
|
||||
7
zshrc/nvm.zsh
Normal file
7
zshrc/nvm.zsh
Normal file
@@ -0,0 +1,7 @@
|
||||
export NVM_DIR="$HOME/.nvm"
|
||||
nvm() {
|
||||
unset -f nvm
|
||||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
||||
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
|
||||
nvm "$@"
|
||||
}
|
||||
@@ -242,7 +242,7 @@
|
||||
# - verbose: Enable instant prompt and print a warning when detecting console output during
|
||||
# zsh initialization. Choose this if you've never tried instant prompt, haven't
|
||||
# seen the warning, or if you are unsure what this all means.
|
||||
typeset -g POWERLEVEL9K_INSTANT_PROMPT=verbose
|
||||
typeset -g POWERLEVEL9K_INSTANT_PROMPT=off
|
||||
|
||||
# Hot reload allows you to change POWERLEVEL9K options after Powerlevel10k has been initialized.
|
||||
# For example, you can type POWERLEVEL9K_BACKGROUND=red and see your prompt turn red. Hot reload
|
||||
|
||||
11
zshrc/personal.zsh
Normal file
11
zshrc/personal.zsh
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
# This my personal zshrc configs. Feel free to use it and modify according to your needs
|
||||
# Place all your .zshrc configurations (including this one) in a single or multiple files under ~/.config/ezsh/zshrc/ folder
|
||||
|
||||
# Additional OH-MY-ZSH plugins to enable
|
||||
plugins+=(lol httpie docker docker-compose pyenv pip)
|
||||
|
||||
# Remove OH-MY-ZSH plugins from the default config
|
||||
plugins=(${plugins:#(zsh-autosuggestions|lol)})
|
||||
|
||||
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(virtualenv status command_execution_time background_jobs todo ram load rvm time)
|
||||
315
zshrc/prep_env.sh
Normal file
315
zshrc/prep_env.sh
Normal file
@@ -0,0 +1,315 @@
|
||||
#!/bin/bash
|
||||
|
||||
############################################################
|
||||
# alias
|
||||
############################################################
|
||||
alias launch='mlx worker launch'
|
||||
alias run='launch'
|
||||
|
||||
##################
|
||||
# history
|
||||
##################
|
||||
export HISTSIZE=100000
|
||||
export HISTFILESIZE=200000
|
||||
|
||||
# 2. 在关闭终端时追加历史记录,而不是覆盖
|
||||
[[ -n "${BASH_VERSION}" ]] && shopt -s histappend
|
||||
|
||||
# 3. 忽略重复及以空格开头的命令
|
||||
export HISTCONTROL=ignoreboth
|
||||
|
||||
# 4. 忽略特定的常用命令
|
||||
# export HISTIGNORE="&:[bf]g:exit:pwd:clear:history"
|
||||
|
||||
# 5. 为命令添加时间戳
|
||||
export HISTTIMEFORMAT="%F %T "
|
||||
|
||||
# 6. 在每次命令后立即写入历史,实现多终端实时共享
|
||||
# 注意:这可能会对性能有轻微影响,但对于大多数现代计算机来说可以忽略不计
|
||||
# export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"
|
||||
|
||||
##################
|
||||
# set ulimit
|
||||
##################
|
||||
ulimit -n 1024768
|
||||
|
||||
############################################################
|
||||
# 兼容 IGNOREEOF
|
||||
############################################################
|
||||
# bash: 连续两次 Ctrl-D 才退出
|
||||
export IGNOREEOF=2
|
||||
# zsh: 对应的 setopt
|
||||
if [[ -n "${ZSH_VERSION}" ]]; then
|
||||
setopt IGNORE_EOF 2>/dev/null || true
|
||||
fi
|
||||
|
||||
############################################################
|
||||
# MLX / Merlin 相关环境(从 mlxrc & start_devbox 合并)
|
||||
############################################################
|
||||
|
||||
# Kerberos cache 位置
|
||||
export KRB5CCNAME="${KRB5CCNAME:-FILE:/opt/tiger/.krb5cc_${UID}}"
|
||||
|
||||
# MLX / Notebook 相关 PYTHONPATH
|
||||
# 在已有 PYTHONPATH 前追加 /mlx/workspace:/tmp/mlx/workspace:/opt/tiger:/opt/tiger/lite_sdk
|
||||
# 并确保 mlx_notebook_pysdk 路径存在
|
||||
if [[ -z "${PYTHONPATH}" ]]; then
|
||||
export PYTHONPATH="/mlx/workspace:/tmp/mlx/workspace:/opt/tiger:/opt/tiger/lite_sdk:/opt/tiger/mlx_notebook_pysdk/mlx-pysdk"
|
||||
else
|
||||
export PYTHONPATH="/mlx/workspace:/tmp/mlx/workspace:/opt/tiger:/opt/tiger/lite_sdk:${PYTHONPATH}:/opt/tiger/mlx_notebook_pysdk/mlx-pysdk"
|
||||
fi
|
||||
|
||||
# pyspark 相关
|
||||
export PYSPARK_PYTHON="${PYSPARK_PYTHON:-/usr/bin/python3}"
|
||||
export PYSPARK_DRIVER_PYTHON="${PYSPARK_DRIVER_PYTHON:-/usr/bin/python3}"
|
||||
# 默认 local[2],和原 mlxrc 保持一致
|
||||
export PYSPARK_SUBMIT_ARGS="${PYSPARK_SUBMIT_ARGS:---master local[2] pyspark-shell}"
|
||||
|
||||
# MLXLAB devbox code disk 标记(如果启动脚本已经设置,就不要覆盖)
|
||||
if [[ -n "${MLXLAB_DEVBOX_CODE_DISK}" ]]; then
|
||||
export MLXLAB_DEVBOX_CODE_DISK=''
|
||||
fi
|
||||
|
||||
# MLX / Merlin 相关变量(假设在容器启动时已经由 start_devbox.sh 导出)
|
||||
# 这里统一再 export 一遍,保证交互 shell 也能继承
|
||||
export MLX_USER_TOKEN='bd2a3f1b71d54ab497f13f2eefc4f5bc'
|
||||
export MLX_USER='qingyuhao'
|
||||
export MLX_IMAGE_VID='d51qjdbc77u9kebl603g'
|
||||
export MLX_IMAGE_URL='hub.byted.org/reckon/data.reckon.mlx.image_10786:4aa09c59c9cbb1fcde50526696177c84'
|
||||
export MLX_ENGINE_SID='bgi0zldy6943b7db'
|
||||
export MLX_DEVBOX_ID='132783'
|
||||
export MLX_HOST_URL='https://ml.bytedance.net/'
|
||||
export MERLIN_HOST_URL='https://ml.bytedance.net'
|
||||
export TCC_CDN_HOST='//lf6-config.bytetcc.com/obj/tcc-config-web'
|
||||
export ZTI_ENV='cn'
|
||||
export IS_SEED='true'
|
||||
export MLXLAB_DEVBOX_CODE_DISK=''
|
||||
|
||||
# DOAS_ZONE(从 BYTE_REGION 推导)
|
||||
if [[ "${BYTE_REGION}" == "CN" ]]; then
|
||||
export DOAS_ZONE="cn"
|
||||
else
|
||||
export DOAS_ZONE="row"
|
||||
fi
|
||||
|
||||
# SEC_KV_AUTH
|
||||
export SEC_KV_AUTH=1
|
||||
|
||||
# 统一补全 NO_PROXY / no_proxy
|
||||
# 基础域名列表
|
||||
_base_no_proxy=".byted.org,byted.org,.bytedance.net,bytedance.net"
|
||||
|
||||
for _v in NO_PROXY no_proxy; do
|
||||
if [[ -n "${BASH_VERSION}" ]]; then
|
||||
_cur="${!_v}"
|
||||
else
|
||||
_cur="${(P)_v}"
|
||||
fi
|
||||
if [[ -z "${_cur}" ]]; then
|
||||
export ${_v}="${_base_no_proxy}"
|
||||
else
|
||||
# 如果已经包含基础域名,就不重复追加
|
||||
if [[ "${_cur}" == *".byted.org"* || "${_cur}" == *".bytedance.net"* ]]; then
|
||||
export ${_v}="${_cur}"
|
||||
else
|
||||
export ${_v}="${_base_no_proxy},${_cur}"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
unset _v _cur _base_no_proxy
|
||||
|
||||
# IS_SEED: 禁用代理(和原来写进 mlxrc 的逻辑保持一致)
|
||||
if [[ "${IS_SEED}" == "true" ]]; then
|
||||
unset http_proxy HTTP_PROXY https_proxy HTTPS_PROXY
|
||||
fi
|
||||
|
||||
############################################################
|
||||
# /tmp/krb5cc_0 软链(从 mlxrc 挪过来)
|
||||
############################################################
|
||||
if [[ ! -e /tmp/krb5cc_0 && ! -L /tmp/krb5cc_0 ]]; then
|
||||
ln -s /opt/tiger/.krb5cc_0 /tmp/krb5cc_0 2>/dev/null || true
|
||||
fi
|
||||
|
||||
############################################################
|
||||
# for hdfs(原 prep_env.sh 中的逻辑)
|
||||
############################################################
|
||||
if ! grep -q "source import_hdfs_envs.sh" ~/.bashrc 2>/dev/null
|
||||
then
|
||||
if command -v import_hdfs_envs.sh > /dev/null 2>&1 && [[ $(which import_hdfs_envs.sh) != *"pyenv/"* ]]; then
|
||||
source import_hdfs_envs.sh
|
||||
else
|
||||
echo "pyenv env, skip hdfs init, please refer to: https://bytedance.larkoffice.com/docx/T9IrdzKRSomwOOxqbUOcRZyLnqh to do hdfs init manually"
|
||||
fi
|
||||
fi
|
||||
|
||||
############################################################
|
||||
# 代理相关
|
||||
############################################################
|
||||
unset HTTPS_PROXY
|
||||
|
||||
############################################################
|
||||
# 一次性加载 workspace 级别 env
|
||||
############################################################
|
||||
if [[ "$WORKSPACE_ENVS_SET" != "1" ]]; then
|
||||
envfile="/etc/.container_env"
|
||||
if [[ -f $envfile ]]; then
|
||||
while IFS= read -r line; do
|
||||
_varname="${line%%=*}"
|
||||
if eval "[[ -z \"\${${_varname}+x}\" ]]"; then # env is not set
|
||||
export "${_varname}=${line#*=}"
|
||||
fi
|
||||
done <"$envfile"
|
||||
unset _varname
|
||||
fi
|
||||
|
||||
if [[ -n "${ZSH_VERSION}" ]]; then
|
||||
cur_dir="$(cd "$(dirname "$0")" && pwd)"
|
||||
if [[ "$ARNOLD_WORKSPACE_BUILD_ENV" != "dev" ]]; then
|
||||
source "$cur_dir"/zsh_hadoop.sh
|
||||
fi
|
||||
else
|
||||
cur_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
if [[ "$ARNOLD_WORKSPACE_BUILD_ENV" != "dev" ]]; then
|
||||
source "$cur_dir"/bash_hadoop.sh
|
||||
fi
|
||||
fi
|
||||
|
||||
source "$cur_dir"/common_env.sh
|
||||
|
||||
# 原来这里设置 PATH=/workspace:$PATH,下面会统一 double-check PATH,再保证 /workspace 在 PATH 里
|
||||
export PATH=/workspace:$PATH
|
||||
|
||||
# 从 code-server 进来的 WORKSPACE_PASSWORD
|
||||
if [[ -z "${WORKSPACE_PASSWORD}" ]]; then
|
||||
export WORKSPACE_PASSWORD="$(ps -ef | grep -oP 'vscode-token\ \K.*' | head -n 1)"
|
||||
fi
|
||||
|
||||
export WORKSPACE_ENVS_SET=1
|
||||
fi
|
||||
|
||||
############################################################
|
||||
# Double check PATH
|
||||
# 保证以下目录全部在 PATH 中(合并了原 prep_env.sh + mlxrc 的目录)
|
||||
############################################################
|
||||
for i in \
|
||||
"$HOME/.local/bin" \
|
||||
"$HOME/bin" \
|
||||
"/workspace" \
|
||||
"/usr/local/bvc/bin" \
|
||||
"/opt/tiger/arnold/bin" \
|
||||
"/opt/tiger/consul_deploy/bin/go" \
|
||||
"/opt/tiger/spark_deploy/spark-3.2/spark-stable/bin" \
|
||||
"/opt/mlx_deploy/miniconda3/envs/mlx/bin" \
|
||||
"/opt/tiger/mlx_deploy" \
|
||||
"/opt/tiger/ss_bin" \
|
||||
"/opt/tiger/ss_lib/bin" \
|
||||
"/opt/common_tools" \
|
||||
"/opt/tiger/yarn_deploy/hadoop/bin" \
|
||||
"/opt/tiger/yarn_deploy/hive/bin"
|
||||
do
|
||||
if [[ ":$PATH:" != *":$i:"* ]]; then
|
||||
PATH="$i:$PATH"
|
||||
fi
|
||||
done
|
||||
|
||||
# DEVBOX_PATH 单独处理一下(可能是一个长路径)
|
||||
if [[ -n "${DEVBOX_PATH}" && ":$PATH:" != *":$DEVBOX_PATH:"* ]]; then
|
||||
PATH="${DEVBOX_PATH}:$PATH"
|
||||
fi
|
||||
|
||||
export PATH
|
||||
|
||||
############################################################
|
||||
# worker 级别 env(原 prep_env.sh)
|
||||
############################################################
|
||||
worker_envfile="/etc/worker_envs_$ARNOLD_WORKER_ID"
|
||||
user_worker_envfile="$HOME/.worker_envs/worker_envs_$ARNOLD_WORKER_ID"
|
||||
if [[ -f $user_worker_envfile ]]; then
|
||||
while IFS= read -r line; do
|
||||
_varname="${line%%=*}"
|
||||
if eval "[[ -z \"\${${_varname}+x}\" ]]"; then # env is not set
|
||||
export "${_varname}=${line#*=}"
|
||||
fi
|
||||
done <"$user_worker_envfile"
|
||||
unset _varname
|
||||
elif [[ -f $worker_envfile ]]; then
|
||||
while IFS= read -r line; do
|
||||
_varname="${line%%=*}"
|
||||
if eval "[[ -z \"\${${_varname}+x}\" ]]"; then # env is not set
|
||||
export "${_varname}=${line#*=}"
|
||||
fi
|
||||
done <"$worker_envfile"
|
||||
unset _varname
|
||||
fi
|
||||
|
||||
############################################################
|
||||
# PS1(原 prep_env.sh)
|
||||
############################################################
|
||||
if [[ -z "${ZSH_VERSION}" ]]; then
|
||||
if [[ -n "${ARNOLD_WORKER_ID}" ]]; then
|
||||
export PS1='\[\033[01;32m\]\u@$ARNOLD_WORKER_ID.worker:\W\[\033[00m\]\$ \[\]'
|
||||
elif [[ -n "${ARNOLD_WORKSPACE_ID}" ]]; then
|
||||
export PS1='\[\033[01;34m\]\u@$ARNOLD_WORKSPACE_ID.master:\W\[\033[00m\]\$ \[\]'
|
||||
else
|
||||
export PS1='\u@\h:\W\$ '
|
||||
fi
|
||||
fi
|
||||
|
||||
############################################################
|
||||
# 从 镜像中继承 PYTHONPATH、PATH、LD_LIBRARY_PATH 等关键环境变量
|
||||
############################################################
|
||||
|
||||
envfile="/etc/.env"
|
||||
env_white_list="PYTHONPATH PATH LD_LIBRARY_PATH" # 需要去重的环境变量列表
|
||||
|
||||
# 定义一个函数,用于对冒号分隔的环境变量去重
|
||||
deduplicate_env() {
|
||||
local var_value="$1"
|
||||
echo "$var_value" | awk -v RS=':' '!a[$0]++ {
|
||||
if (NR > 1) printf(":");
|
||||
printf("%s", $0)
|
||||
}'
|
||||
}
|
||||
|
||||
if [[ -f "$envfile" ]]; then
|
||||
while IFS= read -r line || [[ -n "$line" ]]; do
|
||||
# 跳过注释行和空行
|
||||
[[ "$line" =~ ^[[:space:]]*# ]] && continue
|
||||
[[ "$line" =~ ^[[:space:]]*$ ]] && continue
|
||||
|
||||
# 提取变量名和值
|
||||
var_name="${line%%=*}"
|
||||
var_value="${line#*=}"
|
||||
|
||||
# 检查变量名是否有效
|
||||
[[ "$var_name" =~ ^[a-zA-Z_][a-zA-Z0-9_]*$ ]] || continue
|
||||
|
||||
if [[ " $env_white_list " == *" $var_name "* ]]; then
|
||||
# 变量已设置且在白名单中,追加新值并去重
|
||||
if [[ -n "${BASH_VERSION}" ]]; then
|
||||
existing_value="${!var_name}"
|
||||
else
|
||||
existing_value="${(P)var_name}"
|
||||
fi
|
||||
if [[ -n "$existing_value" ]]; then
|
||||
new_value="$var_value:$existing_value"
|
||||
dedup_value=$(deduplicate_env "$new_value")
|
||||
export "$var_name=$dedup_value"
|
||||
else
|
||||
export "$var_name=$var_value"
|
||||
fi
|
||||
fi
|
||||
done <"$envfile"
|
||||
fi
|
||||
|
||||
############################################################
|
||||
# GPU 相关(原 prep_env.sh)
|
||||
############################################################
|
||||
if [[ -n $NVIDIA_VISIBLE_DEVICES && $NVIDIA_VISIBLE_DEVICES != 'none' ]]; then
|
||||
if [[ -n "${ZSH_VERSION}" ]]; then
|
||||
cur_dir="$(cd "$(dirname "$0")" && pwd)"
|
||||
else
|
||||
cur_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
fi
|
||||
source "$cur_dir"/nvidia.sh
|
||||
fi
|
||||
4
zshrc/pyenv.zsh
Normal file
4
zshrc/pyenv.zsh
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user