oh-my-posh/src/console_title.go

33 lines
676 B
Go
Raw Normal View History

2020-12-26 10:21:26 -08:00
package main
import "fmt"
type consoleTitle struct {
env environmentInfo
settings *Settings
2020-12-26 10:51:21 -08:00
formats *ansiFormats
2020-12-26 10:21:26 -08:00
}
// ConsoleTitleStyle defines how to show the title in the console window
type ConsoleTitleStyle string
const (
// FolderName show the current folder name
FolderName ConsoleTitleStyle = "folder"
// FullPath show the current path
FullPath ConsoleTitleStyle = "path"
)
func (t *consoleTitle) getConsoleTitle() string {
2020-12-26 10:51:21 -08:00
var title string
2020-12-26 10:21:26 -08:00
switch t.settings.ConsoleTitleStyle {
case FullPath:
2020-12-26 10:51:21 -08:00
title = t.env.getcwd()
2020-12-26 10:21:26 -08:00
case FolderName:
fallthrough
default:
2020-12-26 10:51:21 -08:00
title = base(t.env.getcwd(), t.env)
2020-12-26 10:21:26 -08:00
}
2020-12-26 10:51:21 -08:00
return fmt.Sprintf(t.formats.title, title)
2020-12-26 10:21:26 -08:00
}