Skip to content

Commit

Permalink
terminal: add prompt color option
Browse files Browse the repository at this point in the history
Add option to configure prompt color.

Fixes #3603
  • Loading branch information
aarzilli committed Jan 25, 2024
1 parent efaf552 commit 8d07c70
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ type Config struct {
// Source list comment color, as a terminal escape sequence.
SourceListCommentColor string `yaml:"source-list-comment-color"`

// Color for the prompt line.
PromptColor string `yaml:"prompt-color"`

// Source list tab color, as a terminal escape sequence.
SourceListTabColor string `yaml:"source-list-tab-color"`

Expand Down
5 changes: 5 additions & 0 deletions pkg/terminal/terminal.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ type Term struct {
client service.Client
conf *config.Config
prompt string
pcolor string
line *liner.State
cmds *Commands
stdout *transcriptWriter
Expand Down Expand Up @@ -423,6 +424,10 @@ func (t *Term) formatPath(path string) string {
}

func (t *Term) promptForInput() (string, error) {
if t.stdout.colorEscapes != nil && t.conf.PromptColor != "" {
fmt.Fprintf(os.Stdout, t.conf.PromptColor)
defer fmt.Fprintf(os.Stdout, terminalResetEscapeCode)
}
l, err := t.line.Prompt(t.prompt)
if err != nil {
return "", err
Expand Down

0 comments on commit 8d07c70

Please sign in to comment.