Home > other >  Change the prompt in spring shell at runtime
Change the prompt in spring shell at runtime

Time:04-08

is it possible to change the prompt in a spring shell application? For default it seems that the prompt is:

shell:>

Is is possible to change this text at runtime?

THX

CodePudding user response:

You can define a PromptProvider, see in the Docs: https://docs.spring.io/spring-shell/docs/current-SNAPSHOT/reference/htmlsingle/#_promptprovider

CodePudding user response:

Thank you for the answer! I've overlooked this feature. I created this class, put it into my configuration-package and it works good for me:

package de.myapp.spring.configuration;

@Configuration
@ComponentScan("de.myapp.spring.shell")
public class ShellApplicationConfiguration implements PromptProvider {

    @Override
    public final AttributedString getPrompt() {

        return new AttributedString("myapp:>");

    }

}
  • Related