fix(zsh): Cleanup environment variable

This commit is contained in:
js0ny 2024-11-30 05:14:00 +00:00
parent 567c8d1b3b
commit 9436322a73
4 changed files with 24 additions and 5 deletions

View file

@ -4,9 +4,6 @@
# Sourced by user's zshrc if is macOS 在用户的 zshrc 中被引用macOS 特定配置 # Sourced by user's zshrc if is macOS 在用户的 zshrc 中被引用macOS 特定配置
# Entry point in $DOTFILES/tools/zsh/common.zshrc (入口点) # Entry point in $DOTFILES/tools/zsh/common.zshrc (入口点)
# Homebrew Path
export PATH=/opt/homebrew/bin:/opt/homebrew/sbin:$PATH
# macOS # # macOS #
alias xclip="pbcopy" alias xclip="pbcopy"

View file

@ -36,8 +36,7 @@ done
set -k set -k
# TODO: Below should be reorganized # TODO: Below should be reorganized
export PATH=$HOME/bin:$HOME/.local/bin:/usr/local/bin:$PATH export PATH=$HOME/.local/bin:$PATH
export PATH=$HOME/.local/share/gem/ruby/3.3.0/bin:$PATH # Ruby Executables
export NVM_DIR="$HOME/.config/nvm" export NVM_DIR="$HOME/.config/nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm

View file

@ -33,6 +33,15 @@ export PAGER="less -R"
export EDITOR="nvim" export EDITOR="nvim"
export VISUAL="nvim" export VISUAL="nvim"
# Minimal PATH for early commands
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$PATH"
if [ -d "/opt/homebrew/bin" ]; then # macOS
export PATH="/opt/homebrew/bin:$PATH"
elif [ -d "/home/linuxbrew/.linuxbrew/bin" ]; then # Linux
export PATH="/home/linuxbrew/.linuxbrew/bin:$PATH"
fi
# macOS Specific # macOS Specific
# This syntax is POSIX standard, for portability # This syntax is POSIX standard, for portability
if [ "$(uname)" = "Darwin" ]; then if [ "$(uname)" = "Darwin" ]; then
@ -52,6 +61,7 @@ fi
# Cargo # Cargo
if command -v cargo > /dev/null; then if command -v cargo > /dev/null; then
export CARGO_HOME="$XDG_DATA_HOME"/cargo export CARGO_HOME="$XDG_DATA_HOME"/cargo
export PATH="$CARGO_HOME/bin:$PATH"
fi fi
# CGDB # CGDB
if command -v cgdb > /dev/null; then if command -v cgdb > /dev/null; then
@ -60,6 +70,7 @@ fi
# .NET # .NET
if command -v dotnet > /dev/null; then if command -v dotnet > /dev/null; then
export DOTNET_CLI_HOME="$XDG_DATA_HOME"/dotnet export DOTNET_CLI_HOME="$XDG_DATA_HOME"/dotnet
export PATH="$DOTNET_CLI_HOME/.dotnet/tools:$PATH"
fi fi
# Docker # Docker
if command -v docker > /dev/null; then if command -v docker > /dev/null; then
@ -72,6 +83,7 @@ fi
# Go # Go
if command -v go > /dev/null; then if command -v go > /dev/null; then
export GOPATH="$XDG_DATA_HOME"/go export GOPATH="$XDG_DATA_HOME"/go
export PATH="$GOPATH/bin:$PATH"
fi fi
# Julia # Julia
if command -v julia > /dev/null; then if command -v julia > /dev/null; then
@ -100,6 +112,17 @@ if command -v screen > /dev/null; then
export SCREENRC="$XDG_CONFIG_HOME"/screen/screenrc export SCREENRC="$XDG_CONFIG_HOME"/screen/screenrc
export SCREENDIR="${XDG_RUNTIME_DIR}/screen" export SCREENDIR="${XDG_RUNTIME_DIR}/screen"
fi fi
# Ruby Gem
# Ruby Gem
if command -v gem > /dev/null; then
setopt nullglob
for dir in "$HOME/.local/share/gem/ruby/"*/bin; do
if [ -d "$dir" ]; then
export PATH="$dir:$PATH"
fi
done
unsetopt nullglob
fi
# Spacemacs # Spacemacs
if command -v emacs > /dev/null; then if command -v emacs > /dev/null; then
export SPACEMACSDIR="$XDG_CONFIG_HOME"/spacemacs export SPACEMACSDIR="$XDG_CONFIG_HOME"/spacemacs