Skip to content

Use Z Shell's $ZDOTDIR for correct interaction with shell configuration files #246

@RogueScholar

Description

@RogueScholar

The current installation script incorrectly handled integrating with my Z Shell (zsh) setup and I located the underlying cause for that here:

cli/install.sh

Lines 30 to 31 in e7feea3

if [ -f "$HOME/.zshrc" ]; then
DETECTED_PROFILE="$HOME/.zshrc"

Z Shell has always allowed users to define a custom location for their shell configuration files through the use of the $ZDOTDIR variable, described in both of the first-party (i.e. canonical) references Introduction to Z Shell and the Z Shell Documentation. This environment variable essentially manifests as ${ZDOTDIR:-$HOME} in practice, reflecting the default location for such files as the user's $HOME directory. Your script can (and should, in my opinion) make use of this feature with the following minimal patch:

                 DETECTED_PROFILE="$HOME/.bash_profile"
             fi
         elif [ "${SHELL#*zsh}" != "$SHELL" ]; then
-            if [ -f "$HOME/.zshrc" ]; then
-                DETECTED_PROFILE="$HOME/.zshrc"
+            if [ -f "${ZDOTDIR:-$HOME}/.zshrc" ]; then
+                typeset -g DETECTED_PROFILE="${ZDOTDIR:-$HOME}/.zshrc"
             fi
         fi
 

This struck me as too minor for a PR, considering I'm currently here in the role of a Transifex user trying to make use of the tool rather than am aspiring code contributor, but if submitting it that way would positively impact the likelihood of this solution being adopted, please say so and I'll gladly oblige.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions