I want to chsh --shell "$PowerShell" (to set PowerShell as my default shell) where $PowerShell is the revisionless path to pwsh in $PATH. I could use env for this, but I expect there’s a reason why most distributions (which set bash as their default) don’t use env.
In PowerShell, Get-Command 'pwsh' and [System.Diagnostics.Process]::GetCurrentProcess().MainModule.FileName both return /var/lib/snapd/snap/powershell/267/opt/powershell/pwsh. This isn’t usable, because it’ll break when the package is updated.
PS /home/RokeJulianLockhart> chsh -s '/snap/powershell/current/opt/powershell/pwsh'
Changing shell for RokeJulianLockhart.
Password:
chsh: "/snap/powershell/current/opt/powershell/pwsh" is not listed in /etc/shells.
Use chsh -l to see list.
PS /home/RokeJulianLockhart> cat -vbET '/etc/shells'
1 /bin/sh$
2 /bin/bash$
3 /usr/bin/sh$
4 /usr/bin/bash$
5 /usr/bin/tmux$
6 /bin/tmux$
PS /home/RokeJulianLockhart>
@KhazAkar, perhaps my method is fundamentally flawed, actually. I thought that it would work. /var/lib/snapd/snap/powershell/current/opt/powershell/pwsh doesn’t work either.
Nope not pwsh, that binary isn’t directly exposed by this snap. powershell is the binary that’s exposed. And setting cshs --shell /snap/bin/powershell worked.
/var/lib/snapd/snap/bin/powershell. Should that be set as my shell path instead?
Why? Because there’s no guarantee that it’ll be available? I suppose that that would apply to powershell too though, since (I expect) it’s just a symbolic link to the pwsh binary inside the SquashFS FS?
Because snap doesn’t run the executables directly, powershell in /snap/bin/powershell is actually a symlink to snapd itself, which effectively runs snap run powershell and sets up the environment.
It’s more likely to apply to strict snaps due to the additional layers involved, but even in classic, you’re bypassing wrappers such as setting the $SNAP variables apps might expect to actually function (E.G, if a script points to $SNAP/bin/executable, it might instead accidentally try /bin/executable which may not exist or be compatible).