Files
dotfiles/zsh/zshrc
2025-04-08 08:33:07 +08:00

141 lines
4.8 KiB
Bash

export ZSH="$HOME/.oh-my-zsh"
ZSH_THEME="powerlevel10k/powerlevel10k"
plugins=(git zsh-autosuggestions zsh-syntax-highlighting zsh-vi-mode fzf-tab)
source $ZSH/oh-my-zsh.sh
alias icat="kitty +kitten icat"
alias kssh="kitty +kitten ssh"
# alias ll="ls -lhtr"
alias ll="lsd -AlhtrF"
alias vi="/usr/bin/vim"
alias vim="nvim"
alias vim-update='nvim --headless "+Lazy! update" +qa'
# alias nvim-update='nvim --headless "+Lazy! sync" +qa'
alias x86="env /usr/bin/arch -x86_64 /bin/zsh --login"
alias arm="env /usr/bin/arch -arm64 /bin/zsh --login"
alias dur="du -h -d 1 2>/dev/null | sort -hr"
if command -v fzf &> /dev/null; then
eval "$(fzf --zsh)"
fi
if command -v zoxide &> /dev/null; then
eval "$(zoxide init zsh)"
fi
# Environmental variables
export EDITOR="nvim"
# node
export NVM_NODEJS_ORG_MIRROR=https://npmmirror.com/mirrors/node/
if command -v fnm >/dev/null 2>&1; then
eval "$(fnm env --use-on-cd --shell zsh)"
fi
export NODEJS_ORG_MIRROR=https://npmmirror.com/mirrors/node/
# rust
export RUSTUP_DIST_SERVER=https://mirrors.tuna.tsinghua.edu.cn/rustup
export RUSTUP_UPDATE_ROOT=https://mirrors.tuna.tsinghua.edu.cn/rustup/rustup
# lazygit config location and theme
# export CONFIG_DIR="$HOME/.config/lazygit"
# export LG_CONFIG_FILE="$CONFIG_DIR/config.yml,$CONFIG_DIR/mocha-pink.yml"
# pyenv
export PATH="${HOME}/.pyenv/shims:${PATH}"
export PYENV_ROOT="$HOME/.pyenv"
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
if command -v pyenv &> /dev/null; then
eval "$(pyenv init -)"
fi
# bun completions
[ -s "~/.bun/_bun" ] && source "~/.bun/_bun"
# bun
export BUN_INSTALL="$HOME/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"
# golang
export GOENV_ROOT="$HOME/.goenv"
export PATH="$GOENV_ROOT/bin:$PATH"
export PATH="$GOROOT/bin:$PATH"
export PATH="$PATH:$GOPATH/bin"
export GPG_TTY=$(tty)
if command -v goenv &> /dev/null; then
eval "$(goenv init -)"
fi
# disbale powerlevel10k configuration
POWERLEVEL9K_DISABLE_CONFIGURATION_WIZARD=true
export RUA_SCRIPT_DIR=~/.config/rua-scripts/
if [ -d $RUA_SCRIPT_DIR ]; then
for script in $RUA_SCRIPT_DIR/*.sh; do
source $script
done
fi
# linux
if [[ $OSTYPE == "linux"* ]]; then
export NODE_OPTIONS="--max-old-space-size=8192"
export PATH=$PATH:~/.cargo/bin
export PATH=$HOME/.local/bin:$PATH
export OLLAMA_MODELS=/home/xfy/pl/docker/ollama/ollama/
export OLLAMA_HOST=0.0.0.0:11434
export STAGE_SERVER=root@192.168.1.16
export PROD_SERVER=ci@129.211.172.57
# export PATH=$PATH:~/pl/opt/cangjie/bin/
# export PATH=$PATH:~/pl/opt/cangjie/tools/bin
# source ~/pl/opt/cangjie/envsetup.sh
if [[ ":$FPATH:" != *":/home/xfy/.zsh/completions:"* ]]; then export FPATH="/home/xfy/.zsh/completions:$FPATH"; fi
. "/home/xfy/.deno/env"
# Wasmer
export WASMER_DIR="/home/xfy/.wasmer"
[ -s "$WASMER_DIR/wasmer.sh" ] && source "$WASMER_DIR/wasmer.sh"
# rua scripts
if [ -d $RUA_SCRIPT_DIR/linux/ ]; then
for script in $RUA_SCRIPT_DIR/linux/*.sh; do
source $script
done
fi
fi
# macos
if [[ $OSTYPE == "darwin"* ]]; then
# rust library
export PATH="/opt/homebrew/opt/libpq/bin:$PATH"
export LDFLAGS="-L/opt/homebrew/opt/libpq/lib"
export CPPFLAGS="-I/opt/homebrew/opt/libpq/include"
export PKG_CONFIG_PATH="/opt/homebrew/opt/libpq/lib/pkgconfig"
# proxy
export http_proxy="http://127.0.0.1:7890"
export https_proxy="http://127.0.0.1:7890"
test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh"
# Android
export PATH="$PATH:/Volumes/SN/SDK/cmdline-tools/bin"
export ANDROID_HOME="/Volumes/SN/SDK/Android"
export ANDROID_EMULATOR_="$ANDROID_HOME/emulator"
export NDK_HOME="$ANDROID_HOME/ndk/26.2.11394342"
# Java
export JAVA_HOME="/Volumes/SN/SDK/JDK/jdk-17.0.10.jdk/Contents/Home"
export PATH=$JAVA_HOME/bin:$PATH
# Flutter
export PATH=/Volumes/SN/SDK/flutter/bin:$PATH
# ollama
export OLLAMA_MODELS=/Volumes/SN/Ollama/models/
export OLLAMA_HOST=localhost:11434
# Add deno completions to search path
if [[ ":$FPATH:" != *":/Users/xfy/.zsh/completions:"* ]]; then export FPATH="/Users/xfy/.zsh/completions:$FPATH"; fi
. "/Users/xfy/.deno/env"
# The following lines have been added by Docker Desktop to enable Docker CLI completions.
fpath=(/Users/xfy/.docker/completions $fpath)
autoload -Uz compinit
compinit
# End of Docker CLI completions
fi
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
# fzf
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
# 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