flathub / com.jetbrains.IntelliJ-IDEA-Ultimate

https://flathub.org/apps/details/com.jetbrains.IntelliJ-IDEA-Ultimate
15 stars 7 forks source link

Shell inside the IDE terminal is hard to use #169

Closed Job79 closed 8 months ago

Job79 commented 8 months ago

Hello! Have been using this flatpak for a while now together with the flatpak SDKs.

Sometimes I have to use the terminal in the IDE, mostly for little things like go get, npm outdated etc... And when I do this I use the flatpak shell, because that is where the SDKs are available. Now the problem is that the flatpak shell isn't really user friendly. The PS1 is sh-5.2$ and it uses sh instead of bash.

So my question is, would it be possible to use bash for the shell inside the terminal? And could we set a better PS1? Something like [📦 \W]\$ would probably be good because the hostname and user aren't important inside flatpak.

I would be open to try implementing this myself, but I would need some help because I am new to flatpak. Where would I even start?

x80486 commented 8 months ago

I think this may be more complex than you think. There are already some tickets around this subject. Some people understand the challenges, some others think this should be solved on the Flatpak side.

You can give it a whirl, but as far as I can tell, if JetBrains doesn't modify the plugin to behave correctly with all the restrictions imposed by the sandbox, any solution would be somehow "broken" here and there — from time to time.

In the meantime, you can use flatpak-spawn --host /bin/bash (or any shell) to be able to use your shell.

I always use the host installs (SDK, toolkits, etc.) and Console / Terminal application, so I don't have much feedback on this.

Job79 commented 8 months ago

Interesting! Sounds like your workflow is quite different from mine.

I am using silverblue, so prefer the flatpak extension SDKs. It would be possible to install things on the host, but flatpaks are preferred. And the flatpaks extension SDKs are pretty good, never really had problems with them and everything just works (except for php, which is difficult to package because of its many extensions). Using the host shell isn't possible because the extension SDKs are only available inside the flatpak. The nice thing about the extension SDKs is that I can isolate the IDE from the host by removing the filesystem access, this way my filesystem doesn't get cluttered with ~/.npm, ~/.dotnet etc..

So I looked some more into the problem, and while the default shell is /bin/sh it is still bash. Which makes the PS1 not containing the path the only problem (because it causes me to execute commands in the wrong directories). After some searching I was able to fix the PS1 locally, by setting the ENV environment variable and pointing it to a file that sets the PS1. So I think that fixing this could be pretty straightforward.

It would be possible to do something like this:

I assume it is probably best to do this in the https://github.com/Lctrs/jetbrains-flatpak-wrapper repo so it works for all the IDE's. The ENV could then be set in the jetbrains.sh file.

Now does this sound like a good idea? If it doesn't I have fixed it locally so that would be fine too. If you think this doesn't sound horrible I could try implementing it, so far it doesn't seem too difficult.

x80486 commented 8 months ago

It might work. You may want to test this on another distribution, because Silverblue is quite different from the rest in many ways. All in all, that repository is the correct one to put a change at that scale.

Most JetBrains products I've used are released (to this date) with the Terminal plugin, so it makes sense to fix it there.

Job79 commented 8 months ago

I created a pull request to fix this issue.

Should probably have made an issue in the ide-flatpak-wrapper repository first but we'll see where it goes. It wasn't much work either way.

Job79 commented 8 months ago

Because this is more of a ide-flatpak-wrapper issue now should I keep this open? Feel free to close it if you feel like this is the wrong place.