Change Prompt after executing a command

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Change Prompt after executing a command

Matthias
Is it possible to change the session variable "PROMPT" by a executed custom
command in a bundle?

For example:

karaf@root()> item:add Something
Created item with id 12345 and content "Hello World!"
karaf@root():item:12345>item:change content "42 rules"
Changed content of item with id 12345 to "42 rules"





--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
Reply | Threaded
Open this post in threaded view
|

Re: Change Prompt after executing a command

jbonofre
Hi,

you can change PROMPT property in the command Session.

The command has an access to Session, so you can do:

...
public class MyCommand implements Action {

@Reference
Session session;

public Object execute() {
  session.put(Session.PROMPT, "fooo");
  return null;
}

Regards
JB

On 04/06/2019 20:31, matthiaw wrote:

> Is it possible to change the session variable "PROMPT" by a executed custom
> command in a bundle?
>
> For example:
>
> karaf@root()> item:add Something
> Created item with id 12345 and content "Hello World!"
> karaf@root():item:12345>item:change content "42 rules"
> Changed content of item with id 12345 to "42 rules"
>
>
>
>
>
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
>

--
Jean-Baptiste Onofré
[hidden email]
http://blog.nanthrax.net
Talend - http://www.talend.com
Reply | Threaded
Open this post in threaded view
|

Re: Change Prompt after executing a command

Matthias
Thanks. This works. Is there a possibility to add a session-listener? When i
am in a subshell and set the command "exit", then i need to set the new
prompt, but there is no possibility. I only can "reset" the prompt with
dynamic values, when i am excecution my own commands, but not the "default"
ones.

Or do i have to override the default ones, like "exit".



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
Reply | Threaded
Open this post in threaded view
|

Re: Change Prompt after executing a command

jbonofre
Hi Matthias,

You can register whatever you want in the session and check the session
content (like PROMPT_ORIGIN if you want).

Regards
JB

On 05/06/2019 19:32, matthiaw wrote:

> Thanks. This works. Is there a possibility to add a session-listener? When i
> am in a subshell and set the command "exit", then i need to set the new
> prompt, but there is no possibility. I only can "reset" the prompt with
> dynamic values, when i am excecution my own commands, but not the "default"
> ones.
>
> Or do i have to override the default ones, like "exit".
>
>
>
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
>

--
Jean-Baptiste Onofré
[hidden email]
http://blog.nanthrax.net
Talend - http://www.talend.com