Skip to content

feat: support XDG_CONFIG_HOME - #431

Open
sebdanielsson wants to merge 4 commits into
microsoft:mainfrom
sebdanielsson:sebdanielsson-support-xdg-base-dirs
Open

feat: support XDG_CONFIG_HOME#431
sebdanielsson wants to merge 4 commits into
microsoft:mainfrom
sebdanielsson:sebdanielsson-support-xdg-base-dirs

Conversation

@sebdanielsson

Copy link
Copy Markdown

Unix users who configure XDG_CONFIG_HOME currently still get generated resources and shell integrations under ~/.inshellisense. This adds XDG-aware storage while preserving existing installations and Windows behavior.

Approach

  • Use $XDG_CONFIG_HOME/inshellisense for generated resources and rc.toml when XDG_CONFIG_HOME is an absolute Unix path.
  • Preserve ~/.inshellisense for unset, empty, relative, or Windows values, while retaining the existing ~/.config/inshellisense/rc.toml config fallback.
  • Generate safely quoted shell source commands for XDG paths, including paths containing spaces or quotes.
  • Resolve the bash preexec helper relative to its integration script and update the standalone package native module lookup to the same XDG resource root.
  • Add focused coverage for path resolution, compatibility fallbacks, and generated commands across supported shells.

Users moving from the legacy resource path can regenerate resources with is init or is reinit, then source the newly generated XDG plugin path.

Validation

  • Targeted Jest tests
  • TypeScript build and repository lint
  • Standalone package build
  • Local macOS zsh plugin and PTY startup with distinct legacy and XDG configs

Closes #423

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 29, 2026 18:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds XDG Base Directory support so Unix users with an absolute XDG_CONFIG_HOME store generated resources and rc.toml under $XDG_CONFIG_HOME/inshellisense, while preserving the legacy ~/.inshellisense behavior for Windows and non-absolute/unset XDG values.

Changes:

  • Introduce XDG-aware resource/config path resolution (resolveXdgConfigHome, resolveResourcesPath, resolveConfigFilePath) and wire it through constants/config loading.
  • Generate shell init “source” commands that safely quote absolute XDG paths (including spaces/quotes) while preserving legacy ~/.inshellisense commands.
  • Update bash preexec helper resolution and standalone package native-module lookup to respect the same XDG resource root; add focused Jest coverage and docs.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/utils/shell.ts Builds shell source commands with safe quoting; chooses legacy ~/.inshellisense vs XDG absolute paths.
src/utils/constants.ts Centralizes XDG-aware resource + config path resolution and exports computed paths.
src/utils/config.ts Switches XDG config fallback to the resolved XDG-aware xdgConfigPath.
src/ui/ui-uninstall.ts Updates uninstall messaging to reflect “resources” rather than “.inshellisense cache folder”.
src/tests/utils/shell.test.ts Adds unit tests for legacy command preservation and XDG path quoting across shells.
src/tests/utils/constants.test.ts Adds unit tests for XDG path resolution and compatibility fallbacks.
shell/shellIntegration.bash Resolves bash-preexec.sh relative to the integration script location.
scripts/pkg.ts Makes packaged native module lookup prefer XDG resource root when applicable.
README.md Documents XDG_CONFIG_HOME behavior for config and generated resources.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread README.md Outdated
Comment thread src/tests/utils/constants.test.ts Outdated
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

@cpendery cpendery left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

looks good overall, could we make the change to not break linux/macos users?

Comment thread src/utils/shell.ts Outdated
Comment thread src/utils/shell.ts Outdated
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@sebdanielsson
sebdanielsson requested a review from cpendery July 31, 2026 18:38

@cpendery cpendery left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A few more notes

  1. Only the rc file should probably go under the XDG_CONFIG_HOME, we probably want the native modules / other items to go under  XDG_DATA_HOME
  2. reinit doesn't delete the ~/.inshellisense directory, so it doesn't actually migrate users over to the new configuration location
  3. i think is doctor might tell users that the config is missing if it's been migrated & the legacy config will still be there, it should get flagged as a legacy configuration, similar to old shell plugins

Comment thread scripts/pkg.ts Outdated
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@sebdanielsson
sebdanielsson requested a review from cpendery August 1, 2026 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support XDG Base Directory Specification

3 participants