shell-pool / shpool

Think tmux, then aim... lower
Apache License 2.0
1.03k stars 13 forks source link

sourcing ~/.bashrc clobbers the shpool prompt prefix #35

Open ethanpailes opened 1 week ago

ethanpailes commented 1 week ago

Currently if you make some tweak to your shell's .rc files in which you have a custom prompt configured, then reload the changes by doing source ~/.bashrc or . ~/.bashrc, shpool's prompt prefix that it injects on startup will get clobbered. This is a bit sad.

I can think of a few approaches to this, none of which are entirely seemless:

  1. Add a new shpool prompt-hook <bash|zsh|fish> subcommand that is meant to be invoked with $(shpool prompt-hook bash), which you can add at the end of your .bashrc. In addition to doing the usual thing to inject a prompt, it sets a SHPOOL_PROMPT_ALREADY_SET_UP=true env var, which the normal prompt hooks setup code checks for in order to avoid double-adding the prompt on first startup.
  2. Add a new keybinding so that users can have shpool re-inject the prompt after they have sourced their config

The trouble with both of these approaches is that they are too manual. Shpool is meant to be an easy option that works well out of the box without configuration. We could have skipped all the prompt hook stuff if we were willing to demand that users edit their .rc files in order to use shpool, since they can just incorperate it into their normal prompt config, but shpool is meant to be easy to use even for people who are not comfortable with stuff like that.

mrzv commented 1 week ago

Closely related to this issue is the ability to disable automatic prompt setting in the config. I would like to be able to disable it and add $SHPOOL_SESSION_NAME to the prompt on my own.

ethanpailes commented 1 week ago

You can do that by setting prompt_prefix = "" in the config. We should probably do a better job of documenting that.

mrzv commented 1 week ago

Brilliant. Thanks!

mrzv commented 1 week ago

Except that didn't work. Am I supposed to put it in some section?

ethanpailes commented 1 week ago

You probably need to restart your daemon (this will get fixed once we deal with https://github.com/shell-pool/shpool/issues/29).

systemctl --user restart shpool

is the way to do it (or you could just stop the service and let socket activation take care of starting it back up again).

mrzv commented 1 week ago

Yup, that did it. Many thanks. It's a fantastic tool you've written. More feature requests are on the way. ;-)

ethanpailes commented 1 week ago

I just made https://github.com/shell-pool/shpool/pull/39 in order to try to document the config options better