Files
dotfiles/zsh/zshrc
2024-10-14 14:07:57 +08:00

157 lines
5.3 KiB
Bash

# Add deno completions to search path
if [[ ":$FPATH:" != *":/home/xfy/.zsh/completions:"* ]]; then export FPATH="/home/xfy/.zsh/completions:$FPATH"; fi
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 vi="/usr/bin/vim"
alias vim="nvim"
alias x86="env /usr/bin/arch -x86_64 /bin/zsh --login"
alias arm="env /usr/bin/arch -arm64 /bin/zsh --login"
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/
export NODEJS_ORG_MIRROR=https://npmmirror.com/mirrors/node/
if [[ $OSTYPE == "linux"* ]]; then
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
fi
if [[ $OSTYPE == "darwin"* ]]; then
export NVM_DIR="$HOME/.nvm"
[ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh" # This loads nvm
[ -s "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completion
fi
# deno
export DVM_DIR="/Users/xfy/.dvm"
export PATH="$DVM_DIR/bin:$PATH"
# rust
export RUSTUP_UPDATE_ROOT=https://mirrors.tuna.tsinghua.edu.cn/rustup/rustup
export RUSTUP_DIST_SERVER=https://mirrors.tuna.tsinghua.edu.cn/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
# 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 PATH=$PATH:~/pl/opt/cangjie/bin/
# export PATH=$PATH:~/pl/opt/cangjie/tools/bin
# source ~/pl/opt/cangjie/envsetup.sh
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:10809"
export https_proxy="http://127.0.0.1:10809"
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=0.0.0.0:11434
fi
export LOCAL_SCRIPT_DIR=~/.config/local-scripts/
if [ -r $LOCAL_SCRIPT_DIR/appimage.sh ]; then
source ~/.config/local-scripts/appimage.sh
fi
if [ -r $LOCAL_SCRIPT_DIR/local.sh ]; then
source ~/.config/local-scripts/local.sh
fi
export RUA_SCRIPT_DIR=~/.config/rua-scripts/
if [ -r $RUA_SCRIPT_DIR/xdg-startup.sh ]; then
source ~/.config/rua-scripts/xdg-startup.sh
source ~/.config/rua-scripts/docker.sh
source ~/.config/rua-scripts/show-client.sh
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
# place this after nvm initialization!
autoload -U add-zsh-hook
load-nvmrc() {
local nvmrc_path
nvmrc_path="$(nvm_find_nvmrc)"
if [ -n "$nvmrc_path" ]; then
local nvmrc_node_version
nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")
if [ "$nvmrc_node_version" = "N/A" ]; then
nvm install
elif [ "$nvmrc_node_version" != "$(nvm version)" ]; then
nvm use
fi
elif [ -n "$(PWD=$OLDPWD nvm_find_nvmrc)" ] && [ "$(nvm version)" != "$(nvm version default)" ]; then
echo "Reverting to nvm default version"
nvm use default
fi
}
. "/home/xfy/.deno/env"