change prompt to arthas@pid (#803)

This commit is contained in:
portman xu
2019-08-28 14:12:14 +08:00
committed by hengyunabc
parent a97ce29cab
commit baf41aa59f
@@ -46,6 +46,7 @@ public class ShellImpl implements Shell {
private Term term;
private String welcome;
private Job currentForegroundJob;
private String prompt;
public ShellImpl(ShellServer server, Term term, InternalCommandManager commandManager,
Instrumentation instrumentation, int pid, JobControllerImpl jobController) {
@@ -64,6 +65,8 @@ public class ShellImpl implements Shell {
if (term != null) {
term.setSession(session);
}
this.setPrompt();
}
public JobController jobController() {
@@ -106,6 +109,14 @@ public class ShellImpl implements Shell {
this.welcome = welcome;
}
private void setPrompt(){
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("[arthas@");
stringBuilder.append(session.getPid());
stringBuilder.append("]$ ");
this.prompt = stringBuilder.toString();
}
public ShellImpl init() {
term.interruptHandler(new InterruptHandler(this));
term.suspendHandler(new SuspendHandler(this));
@@ -142,7 +153,7 @@ public class ShellImpl implements Shell {
}
public void readline() {
term.readline(Constants.DEFAULT_PROMPT, new ShellLineHandler(this),
term.readline(prompt, new ShellLineHandler(this),
new CommandManagerCompletionHandler(commandManager));
}