Skip to content

shell-init creates ~/.bashrc on macOS, where login bash never reads it #9

Description

@fcreme

When tstyles shell-init finds no rc file at all, it creates one for the login
shell rather than silently doing nothing (terminals.ps1, ~line 616):

$loginShell = if ($env:SHELL -and $env:SHELL -match 'zsh') { 'zsh' } else { 'bash' }
$target = $candidates | Where-Object Shell -eq $loginShell | Select-Object -First 1

Get-ShellRcCandidate returns the bash candidates in the order .bashrc,
.bash_profile, so -First 1 always picks .bashrc.

That is the wrong file on macOS, and the reason is documented two functions
away, in Get-ShellRcCandidate's own comment:

~/.bash_profile is included because macOS Terminal.app starts bash as a
LOGIN shell, which reads .bash_profile and never .bashrc.

So on a fresh macOS machine whose login shell is bash and which has no rc files
yet, shell-init creates ~/.bashrc, reports success, and the shell never
reads it.

Expected

Create the file the login shell will actually read — .bash_profile on macOS,
.bashrc on Linux.

Why this is a good first issue

The reasoning is already written down in the file; this is about applying it in
one more place. Get-TStylesPlatform gives you the platform, and
tests/Shell-Integration.Tests.ps1 shows how the rc-file paths are faked.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions