feat: support XDG_CONFIG_HOME - #431
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
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
~/.inshellisensecommands. - 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.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
cpendery
left a comment
There was a problem hiding this comment.
looks good overall, could we make the change to not break linux/macos users?
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
cpendery
left a comment
There was a problem hiding this comment.
A few more notes
- Only the rc file should probably go under the
XDG_CONFIG_HOME, we probably want the native modules / other items to go underXDG_DATA_HOME reinitdoesn't delete the~/.inshellisensedirectory, so it doesn't actually migrate users over to the new configuration location- i think
is doctormight 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
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
|
||
| if [ -r ~/.inshellisense/shell/bash-preexec.sh ]; then | ||
| . ~/.inshellisense/shell/bash-preexec.sh | ||
| if [ -r "${BASH_SOURCE[0]%/*}/bash-preexec.sh" ]; then |
There was a problem hiding this comment.
I think this will break git bash on windows due to the different path separator. using cygpath to convert into a unix style path and then sourcing the preexec should fix the issue
__is_shell_source="${BASH_SOURCE[0]}"
if command -v cygpath >/dev/null 2>&1; then
__is_shell_source=$(cygpath -u "$__is_shell_source")
fi
if [ -r "${__is_shell_source%/*}/bash-preexec.sh" ]; then
. "${__is_shell_source%/*}/bash-preexec.sh"
fi
cpendery
left a comment
There was a problem hiding this comment.
also it might be nice to warn users if they have a legacy ~/.insehllisense shell plugin but their configs are in the XDG_CONFIG_DIR in the doctor command that they have a legacy shell plugin, we already do that for some of the early permutations of the plugin
Unix users who configure
XDG_CONFIG_HOMEcurrently still get generated resources and shell integrations under~/.inshellisense. This adds XDG-aware storage while preserving existing installations and Windows behavior.Approach
$XDG_CONFIG_HOME/inshellisensefor generated resources andrc.tomlwhenXDG_CONFIG_HOMEis an absolute Unix path.~/.inshellisensefor unset, empty, relative, or Windows values, while retaining the existing~/.config/inshellisense/rc.tomlconfig fallback.Users moving from the legacy resource path can regenerate resources with
is initoris reinit, then source the newly generated XDG plugin path.Validation
Closes #423