-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path.zshrc
More file actions
73 lines (66 loc) · 3.2 KB
/
Copy path.zshrc
File metadata and controls
73 lines (66 loc) · 3.2 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
source "$HOME/.zsh/p10k-preload.zsh"
# Options & env
autoload -Uz compinit; compinit -C
setopt interactivecomments autocd extendedglob
export CLICOLOR=1 EDITOR=nvim
# Plugins (load before config so autosuggestions defaults are set before
# abbreviations.zsh appends to ZSH_AUTOSUGGEST_CLEAR_WIDGETS)
source "$HOME/.zsh/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh"
source "$HOME/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh"
source "$HOME/.zsh/auto-notify.plugin.zsh"
# Source config
# path.zsh is sourced from .zshenv, not here: PATH has to exist for
# non-interactive shells too.
source "$HOME/.zsh/history.zsh"
source "$HOME/.zsh/keybindings.zsh"
source "$HOME/.zsh/abbreviations.zsh"
# Before fzf.zsh: it colors itself from the ~/.cache/dark-mode this writes.
source "$HOME/.zsh/appearance.zsh"
source "$HOME/.zsh/fzf.zsh"
source "$HOME/.zsh/functions.zsh"
# Tools
source "$HOME/.zsh/tools.zsh"
# Prompt
source "$HOME/.zsh/p10k.zsh"
# Local overrides. Spelled as `if` rather than `[[ … ]] && source …` because
# the && form leaves $? = 1 when the file is absent, and this is the last
# statement in .zshrc — so p10k painted the very first prompt's ❯ red on every
# machine that has no .zshrc.local.
if [[ -f "$HOME/.zshrc.local" ]]; then
source "$HOME/.zshrc.local"
fi
# Coding-agent notifications from a machine you are only ever ssh'd into come
# back to whichever machine you are sitting at, and need to name the pane holding
# that ssh so clicking one can land on it. LC_* is the only namespace ssh
# forwards by default (SendEnv LANG LC_* against sshd's matching AcceptEnv), and
# a %pane_id survives every rename and renumbering, so that is what travels.
#
# Which half runs depends on which end of the connection this shell is: the far
# end records where the login came from, keyed by tty, because a tmux session
# there outlives any one connection and cannot rely on its own environment.
# A login with no pane to declare has to erase the last one's answer, not just
# decline to write: ttys are reused, so /dev/pts/0 keeps whatever some earlier
# connection recorded there. Ssh'ing from a plain terminal tab after once having
# ssh'd from inside tmux left the old pane id standing, and a notification from
# this machine would then send the click to a pane that had nothing to do with
# it - selecting the wrong tab and yanking the local tmux somewhere else.
#
# LC_CLAUDE_PANE and ~/.claude/origin are compatibility mirrors for endpoints
# still running the old name; LC_AGENT_NOTIFY_PANE and ~/.agent-notify/origin are
# canonical.
if [[ -n $SSH_TTY ]]; then
agent_notify_origin=${LC_AGENT_NOTIFY_PANE:-${LC_CLAUDE_PANE:-}}
agent_notify_origin_file=${SSH_TTY//\//-}
mkdir -p ~/.agent-notify/origin ~/.claude/origin
if [[ -n $agent_notify_origin ]]; then
print -r -- "$agent_notify_origin" > ~/.agent-notify/origin/$agent_notify_origin_file
print -r -- "$agent_notify_origin" > ~/.claude/origin/$agent_notify_origin_file
else
rm -f ~/.agent-notify/origin/$agent_notify_origin_file \
~/.claude/origin/$agent_notify_origin_file
fi
unset agent_notify_origin agent_notify_origin_file
elif [[ -n $TMUX_PANE ]]; then
export LC_AGENT_NOTIFY_PANE=$TMUX_PANE
export LC_CLAUDE_PANE=$TMUX_PANE
fi