-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.zshenv
More file actions
133 lines (104 loc) · 5.39 KB
/
Copy path.zshenv
File metadata and controls
133 lines (104 loc) · 5.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# -----------------------------------------------------------------------------
# This file is sourced for all shell sessions, including interactive, login, and non-interactive shells.
# Place your universal environment variables here.
# It is sourced first, before ~/.zprofile, ~/.zshrc, and ~/.zlogin.
# -----------------------------------------------------------------------------
# Set DOTFILES to organize configuration files
export DOTFILES="$HOME/.dotfiles"
source $DOTFILES/zsh/utils.zsh
# SSH agent socket — the sm tunnel forwards the Mac's agent to this constant
# path on remote hosts. Set in .zshenv (not .zshrc) so non-interactive shells
# (git hooks, cron) get it too. When the socket is absent, SSH_AUTH_SOCK is
# left alone so a plain ssh session's own forwarded agent keeps working.
if [[ "$OSTYPE" != darwin* && -S "$HOME/.ssh/agent-tunnel.sock" && "$HERDR_WORKER" != 1 ]]; then
export SSH_AUTH_SOCK="$HOME/.ssh/agent-tunnel.sock"
fi
# On a headless remote host (non-macOS), route browser-opening through the
# Remote Bridge to the local Mac's browser. $OSTYPE (a zsh builtin: no fork,
# and resolvable before the PATH array below is built) rather than an
# SSH_CLIENT gate — an unset SSH_CLIENT does not imply "local Mac" (could be
# cron/boot on a remote host).
if [[ "$OSTYPE" != darwin* ]]; then
export BROWSER=ropen
fi
# Set ZDOTDIR to point to the .dotfiles zsh directory
export ZDOTDIR="$DOTFILES/zsh"
# Set XDG Base Directories explicitly
export XDG_CONFIG_HOME="$HOME/.config"
export XDG_DATA_HOME="$HOME/.local/share"
export XDG_CACHE_HOME="$HOME/.cache"
# Set the directory to store zinit and plugins
export ZINIT_ROOT="${XDG_DATA_HOME}/zinit"
export ZINIT_HOME="${ZINIT_ROOT}/zinit.git"
# Universal environment variables
export HISTSIZE=10000
export HISTFILE="$ZDOTDIR/.zsh_history"
export SAVEHIST=$HISTSIZE
# ── PATH (ZINIT_ROOT must be set before this block) ──────────────────────────
typeset -U path
path=(
"$DOTFILES/bin"
"$DOTFILES/remote-bridge/bin"
${(s.:.)PATH} # This expands the current PATH into an array in Zsh
)
# Prepend zinit polaris/bin if it exists (not present on all systems)
[[ -d "$ZINIT_ROOT/polaris/bin" ]] && path=("$ZINIT_ROOT/polaris/bin" "${path[@]}")
# mise shims first: tools must resolve while .zshrc is still sourcing (fzf.zsh
# evals `fzf --zsh`) and in non-interactive shells (herdr panes, ssh commands,
# git hooks). `mise activate` alone injects PATH only at the first prompt —
# too late for both. At prompt time activate still takes precedence over shims.
[[ -d "$XDG_DATA_HOME/mise/shims" ]] && path=("$XDG_DATA_HOME/mise/shims" "${path[@]}")
# ~/.local/bin universally, not only via .zprofile (login shells): native
# installers (claude, mise itself) live there, and non-login shells — herdr
# panes on Linux, ssh commands — never source .zprofile. Appended like
# .zprofile did, so system binaries keep winning name conflicts.
[[ -d "$HOME/.local/bin" ]] && path+=("$HOME/.local/bin")
# Linuxbrew for every shell, not only login (.zprofile/brew shellenv):
# codex, opencode, sesh, lazygit, bat, and nvim live there on Linux hosts.
# Inserted AFTER the mise-shims element so mise stays the single source of
# truth in non-login shells; login shells keep their .zprofile order because
# brew shellenv re-prepends and typeset -U keeps the frontmost occurrence.
if [[ "$OSTYPE" != darwin* && -d /home/linuxbrew/.linuxbrew/bin ]]; then
path=("${path[@]:0:1}" /home/linuxbrew/.linuxbrew/bin /home/linuxbrew/.linuxbrew/sbin "${path[@]:1}")
fi
# Re-export the PATH from the path array
export PATH="${(j.:.)path}"
! command_exists git-lia && file_exists "$DOTFILES/bin/git-lia/git-lia" && path+=("$DOTFILES/bin/git-lia/git-lia")
path_exists "$DOTFILES/bin/nvim/bin/" && path+=("$DOTFILES/bin/nvim/bin")
# Optional: Source .zprofile in non-login shells
# if [[ ( "$SHLVL" -eq 1 && ! -o LOGIN ) && -s ${ZDOTDIR:-~}/.zprofile ]]; then
# source ${ZDOTDIR:-~}/.zprofile
# fi
# Set Neovim as the pager for man pages
export MANPAGER='nvim +Man!'
# Set a high width for man page formatting to avoid line wrapping
export MANWIDTH=999
# Allow Git to discover repositories across filesystem boundaries
export GIT_DISCOVERY_ACROSS_FILESYSTEM=1
# AI tools: point lit-ai-context to claude-config monorepo
export LIA_DOCS_PATH="$HOME/repos/claude-config"
# Raycast development repository
export RAYCAST_DEV_PATH="$HOME/repos/raycast"
# Add syntax highlighting to man pages
if command_exists bat; then
if command_exists fzf; then
export FZF_PREVIEW_OPTS="bat {} || cat {} || tree -C {}"
export FZF_CTRL_T_OPTS="--min-height 30 --preview-window down:60% --preview-window noborder --preview '($FZF_PREVIEW_OPTS) 2> /dev/null'"
fi
export NULLCMD=bat
export MANPAGER="sh -c 'col -bx | bat -l man -p'"
fi
if is_macos; then
export HOMEBREW_CASK_OPTS="--no-quarantine"
export HOMEBREW_BUNDLE_FILE_GLOBAL="$DOTFILES/brew/osx/.Brewfile"
export HOMEBREW_UPGRADE_EXCLUDE_PACKAGES="elgato-wave-link elgato-stream-deck raycast aldente"
else
export HOMEBREW_BUNDLE_FILE_GLOBAL="$DOTFILES/brew/linux/.Brewfile"
fi
# Prevent intelephense from crashing
export NODE_OPTIONS=--max_old_space_size=8192
file_exists "$HOME/.zshenv-private" && source "$HOME/.zshenv-private"
file_exists "$HOME/.dotfiles-local/.zshenv" && source "$HOME/.dotfiles-local/.zshenv"
export TERM=xterm-256color
export TMPDIR="$HOME/tmp"
export CLAUDE_CODE_TMPDIR="$HOME/tmp/ai/claude"