mirror of
https://github.com/DefectingCat/dotfiles
synced 2025-07-15 16:51:36 +00:00
100 lines
3.5 KiB
Bash
100 lines
3.5 KiB
Bash
export ZSH="$HOME/.oh-my-zsh"
|
|
ZSH_THEME="powerlevel10k/powerlevel10k"
|
|
plugins=(git zsh-autosuggestions zsh-syntax-highlighting zsh-vi-mode)
|
|
source $ZSH/oh-my-zsh.sh
|
|
|
|
alias icat="kitty +kitten icat"
|
|
alias kssh="kitty +kitten ssh"
|
|
alias ll="ls -lhtr"
|
|
# 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
|
|
# rust
|
|
export RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static
|
|
export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/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"
|
|
eval "$(pyenv init -)"
|
|
# bun completions
|
|
[ -s "~/.bun/_bun" ] && source "~/.bun/_bun"
|
|
# disbale powerlevel10k configuration
|
|
POWERLEVEL9K_DISABLE_CONFIGURATION_WIZARD=true
|
|
|
|
# linux
|
|
if [[ $OSTYPE == "linux"* ]]; then
|
|
export GPG_TTY=$(tty)
|
|
export NODE_OPTIONS="--max-old-space-size=8192"
|
|
export PATH=$PATH:~/.cargo/bin
|
|
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://localhost:10809"
|
|
export https_proxy="http://localhost:10809"
|
|
test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh"
|
|
fi
|
|
|
|
export RUA_SCRIPT_DIR=~/.config/rua-scripts/
|
|
if [ -r $RUA_SCRIPT_DIR/xdg-startup.sh ]; then
|
|
source ~/.config/rua-scripts/xdg-startup.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
|
|
}
|
|
|
|
add-zsh-hook chpwd load-nvmrc
|
|
load-nvmrc
|