zsh: clarify that an unset ZDOTDIR defaults to HOME

This fixes the incorrect comment and uses $HOME (rather than ~) to be a
little bit more explicit.

Also, our script is named ghostty-integration, not ghostty.zsh, so
update that part of the comment, too.
pull/8281/head
Jon Parise 2025-08-19 10:39:09 -04:00
parent e8a60a375c
commit 8300512a91
1 changed files with 5 additions and 4 deletions

View File

@ -29,14 +29,15 @@ fi
# Use try-always to have the right error code.
{
# Zsh treats empty $ZDOTDIR as if it was "/". We do the same.
# Zsh treats unset ZDOTDIR as if it was HOME. We do the same.
#
# Source the user's zshenv before sourcing ghostty.zsh because the former
# might set fpath and other things without which ghostty.zsh won't work.
# Source the user's .zshenv before sourcing ghostty-integration because the
# former might set fpath and other things without which ghostty-integration
# won't work.
#
# Use typeset in case we are in a function with warn_create_global in
# effect. Unlikely but better safe than sorry.
'builtin' 'typeset' _ghostty_file=${ZDOTDIR-~}"/.zshenv"
'builtin' 'typeset' _ghostty_file=${ZDOTDIR-$HOME}"/.zshenv"
# Zsh ignores unreadable rc files. We do the same.
# Zsh ignores rc files that are directories, and so does source.
[[ ! -r "$_ghostty_file" ]] || 'builtin' 'source' '--' "$_ghostty_file"