Skip to content

Changes to create $ZSH_CACHE_DIR/completions directory #708

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

war-turtle
Copy link
Contributor

Description

Changes to create $ZSH_CACHE_DIR/completions directory and add it to fpath.

Related Issue(s)

#707

Motivation and Context

Usage examples

How Has This Been Tested?

These line of changes were moved into a .zsh file
echo $fpath was added to the end of the file
then that file was executed to check if fpath was getting updated or not.
Also, the directory was created.

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • Bug fix (non-breaking change which fixes an issue)
  • Documentation change
  • New feature (non-breaking change which adds functionality)

Checklist:

  • All new and existing tests passed.
  • I have added tests to cover my changes.
  • I have updated the documentation accordingly.

Comment on lines +168 to +171
# Create "$ZSH_CACHE_DIR/completions" directory
[[ ! -d "$ZSH_CACHE_DIR/completions" ]] && command mkdir -p "$ZSH_CACHE_DIR/completions"
# Add "$ZSH_CACHE_DIR/completions" diretory to fpath
[[ -z ${fpath[(re)$ZSH_CACHE_DIR/completions]} ]] && fpath=( "$ZSH_CACHE_DIR/completions" "${fpath[@]}" )

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using this version of the code generated warning/error on my machine when going to zsh from a bash shell.

mkdir: cannot create directory ‘/completions’: Permission denied

I added these lines coming from oh-my-zsh repo:

# Make sure $ZSH_CACHE_DIR is writable, otherwise use a directory in $HOME
if [[ ! -w "$ZSH_CACHE_DIR" ]]; then
  ZSH_CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/oh-my-zsh"
fi

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MangelMaxime thanks for this review. I have added the snippet you shared in the PR.
But, I changed the directory to .cache/zinit, I hope that's ok.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be fine

@war-turtle war-turtle requested a review from MangelMaxime May 23, 2025 08:16
Comment on lines +168 to +171
# Create "$ZSH_CACHE_DIR/completions" directory
[[ ! -d "$ZSH_CACHE_DIR/completions" ]] && command mkdir -p "$ZSH_CACHE_DIR/completions"
# Add "$ZSH_CACHE_DIR/completions" diretory to fpath
[[ -z ${fpath[(re)$ZSH_CACHE_DIR/completions]} ]] && fpath=( "$ZSH_CACHE_DIR/completions" "${fpath[@]}" )

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be fine

@pschmitt pschmitt merged commit 6a51ac7 into zdharma-continuum:main May 24, 2025
15 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants