dotfiles/zsh/.config/zsh/path.zsh

38 lines
1 KiB
Bash

# Efficient PATH management
function update_path() {
# Define directories to add to PATH
local dirs=(
"/usr/local/texlive/2024/bin/x86_64-linux"
"$HOME/.local/bin"
"$HOME/.bin"
"$HOME/.dotnet/tools"
"$HOME/.local/share/npm/bin"
"$HOME/.local/share/cargo/bin"
"$HOME/.local/share/go/bin"
)
# Prepare new PATH variable
local new_path=""
# Add directories if they exist
for dir in "${dirs[@]}"; do
if [ -d "$dir" ]; then
new_path="${new_path:+$new_path:}$dir"
fi
done
# Set PATH with current values if they don't already exist in the path
if [[ -n "$new_path" ]]; then
export PATH="$new_path:$PATH"
fi
# Set MANPATH and INFOPATH if texlive directory exists
if [ -d "/usr/local/texlive/2024/texmf-dist/doc/man" ]; then
export MANPATH="/usr/local/texlive/2024/texmf-dist/doc/man:${MANPATH:-}"
export INFOPATH="/usr/local/texlive/2024/texmf-dist/doc/info:${INFOPATH:-}"
fi
}
# Run the function
update_path