[shell] fixed visual glitch, prompt not spawning

This commit is contained in:
Rasmus Moorats 2019-03-20 18:51:22 +00:00
parent bf3cb0704e
commit ab3dd2067e
2 changed files with 6 additions and 5 deletions
internal
setting
shell

View file

@ -120,10 +120,9 @@ func GetResponse(id int) connection.Response {
// UpdatePrompt refreshes the prompt and sets it according to current status
func (s *ShellVars) UpdatePrompt() {
var prompt string
if s.Conn.Ws == nil {
// Not connected
prompt = "\033[91miop\033[0;1m$\033[0m "
} else {
prompt = "\033[91miop\033[0;1m$\033[0m "
if s.Conn.Ws != nil {
if s.Conn.User == "" {
// Connected but not authenticated
prompt = "\033[32miop\033[0;1m$\033[0m "
@ -132,6 +131,7 @@ func (s *ShellVars) UpdatePrompt() {
prompt = fmt.Sprintf("\033[32miop\033[0m %s\033[0;1m$\033[0m ", s.Conn.User)
}
}
if s.Instance != nil {
s.Instance.SetPrompt(prompt)
s.Instance.Refresh()

View file

@ -114,6 +114,8 @@ func Shell(script string) error {
Sv.Instance = prepareShell()
defer Sv.Instance.Close()
Sv.UpdatePrompt()
rc := GetRCFile()
if rc != "" {
runScript(rc)
@ -168,7 +170,6 @@ func prepareShell() *readline.Instance {
go scriptListener()
go msgParser()
Sv.UpdatePrompt()
Sv.UpdateCompleter(cmd.CommandList)
return l