Skip to content

feat(shellhook): detect active shell and auto-create profile on tip install#17

Merged
jung-thomas merged 2 commits intomainfrom
feature/tip-shell-detect
May 7, 2026
Merged

feat(shellhook): detect active shell and auto-create profile on tip install#17
jung-thomas merged 2 commits intomainfrom
feature/tip-shell-detect

Conversation

@jung-thomas
Copy link
Copy Markdown
Contributor

Summary

  • Detects the user's active shell (PowerShell, Zsh, Bash) via environment heuristics during tip install
  • Auto-creates the detected shell's profile file (and parent directories) if it doesn't exist — fixes the case where PowerShell users get no hook because ~/Documents/PowerShell/Microsoft.PowerShell_profile.ps1 doesn't exist by default
  • Secondary shell profiles continue to be written only if they already exist on disk

Test plan

  • Run sap-devs tip install in PowerShell on a machine without an existing PS profile — verify the profile is created and hook is written
  • Run sap-devs tip install in Zsh/Bash — verify the detected shell's rc file is created if missing
  • Run sap-devs tip install when hook is already present — verify idempotent (no duplicate)
  • Run sap-devs tip uninstall — verify removal still works (no changes to Remove path)
  • CI: go test ./internal/shellhook/... passes (14 new test cases covering detection, creation, and edge cases)

…nstall

On Windows, PowerShell profiles don't exist by default so `tip install`
would only configure Git Bash profiles. Now detects the active shell via
environment heuristics (PSModulePath for PowerShell, SHELL for bash/zsh)
and creates the corresponding profile file before writing the hook.
Tests that simulate Windows PowerShell or Linux Zsh now override the
new `currentOS` package variable so candidateProfiles() generates the
correct platform paths regardless of the CI runner's actual GOOS.
@jung-thomas jung-thomas merged commit c1d2c4d into main May 7, 2026
3 checks passed
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.

1 participant