-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy path.zshenv
More file actions
68 lines (63 loc) · 2.96 KB
/
.zshenv
File metadata and controls
68 lines (63 loc) · 2.96 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
# vim:ft=zsh
#
# cmux ZDOTDIR bootstrap for zsh.
#
# GhosttyKit already uses a ZDOTDIR injection mechanism for zsh (setting ZDOTDIR
# to Ghostty's integration dir). cmux also needs to run its integration, but
# we must restore the user's real ZDOTDIR immediately so that:
# - /etc/zshrc sets HISTFILE relative to the real ZDOTDIR/HOME (shared history)
# - zsh loads the user's real .zprofile/.zshrc normally (no wrapper recursion)
#
# We restore ZDOTDIR from (in priority order):
# - GHOSTTY_ZSH_ZDOTDIR (set by GhosttyKit when it overwrote ZDOTDIR)
# - CMUX_ZSH_ZDOTDIR (set by cmux when it overwrote a user-provided ZDOTDIR)
# - unset (zsh treats unset ZDOTDIR as $HOME)
if [[ -n "${GHOSTTY_ZSH_ZDOTDIR+X}" ]]; then
builtin export ZDOTDIR="$GHOSTTY_ZSH_ZDOTDIR"
builtin unset GHOSTTY_ZSH_ZDOTDIR
elif [[ -n "${CMUX_ZSH_ZDOTDIR+X}" ]]; then
builtin export ZDOTDIR="$CMUX_ZSH_ZDOTDIR"
builtin unset CMUX_ZSH_ZDOTDIR
else
builtin unset ZDOTDIR
fi
{
# zsh treats unset ZDOTDIR as if it were HOME. We do the same.
builtin typeset _cmux_file="${ZDOTDIR-$HOME}/.zshenv"
[[ ! -r "$_cmux_file" ]] || builtin source -- "$_cmux_file"
if [[ -o interactive \
&& -z "${ZSH_EXECUTION_STRING:-}" \
&& "${CMUX_SHELL_INTEGRATION:-1}" != "0" \
&& -n "${CMUX_SHELL_INTEGRATION_DIR:-}" \
&& -r "${CMUX_SHELL_INTEGRATION_DIR}/cmux-zsh-integration.zsh" \
&& "${TERM:-}" == "xterm-256color" \
&& -z "${CMUX_ZSH_RESTORE_TERM:-}" ]]; then
# Keep startup TERM-compatible prompt/theme selection during shell init,
# then restore the managed xterm-256color identity once zle starts.
builtin export CMUX_ZSH_RESTORE_TERM="$TERM"
builtin export TERM="xterm-ghostty"
fi
} always {
if [[ -o interactive ]]; then
# We overwrote GhosttyKit's injected ZDOTDIR, so manually load Ghostty's
# zsh integration if available.
#
# We can't rely on GHOSTTY_ZSH_ZDOTDIR here because Ghostty's own zsh
# bootstrap unsets it before chaining into this cmux wrapper.
if [[ "${CMUX_LOAD_GHOSTTY_ZSH_INTEGRATION:-0}" == "1" ]]; then
if [[ -n "${CMUX_SHELL_INTEGRATION_DIR:-}" ]]; then
builtin typeset _cmux_ghostty="$CMUX_SHELL_INTEGRATION_DIR/ghostty-integration.zsh"
fi
if [[ ! -r "${_cmux_ghostty:-}" && -n "${GHOSTTY_RESOURCES_DIR:-}" ]]; then
builtin typeset _cmux_ghostty="$GHOSTTY_RESOURCES_DIR/shell-integration/zsh/ghostty-integration"
fi
[[ -r "$_cmux_ghostty" ]] && builtin source -- "$_cmux_ghostty"
fi
# Load cmux integration (unless disabled)
if [[ "${CMUX_SHELL_INTEGRATION:-1}" != "0" && -n "${CMUX_SHELL_INTEGRATION_DIR:-}" ]]; then
builtin typeset _cmux_integ="$CMUX_SHELL_INTEGRATION_DIR/cmux-zsh-integration.zsh"
[[ -r "$_cmux_integ" ]] && builtin source -- "$_cmux_integ"
fi
fi
builtin unset _cmux_file _cmux_ghostty _cmux_integ
}