diff --git a/docs/docs/configuration.md b/docs/docs/configuration.md index f2e0ba50..6d0e7b0f 100644 --- a/docs/docs/configuration.md +++ b/docs/docs/configuration.md @@ -47,16 +47,22 @@ theme. oh-my-posh -config sample.json -shell universal ``` -If all goes according to plan, you should see the prompt being printed out on the line below. In case you see a lot of boxes with -question marks, [set up your terminal][setupterm] to use a supported font before continuing. +If all goes according to plan, you should see the prompt being printed out on the line below. In case you see a lot of +boxes with question marks, [set up your terminal][setupterm] to use a supported font before continuing. ## General Settings - final_space: `boolean` - when true adds a space at the end of the prompt - console_title: `boolean` - when true sets the current location as the console title +- console_title_style: `string` - the title to set in the console - defaults to `folder` > "I Like The Way You Speak Words" - Gary Goodspeed +### Console Title Style + +- `folder`: show the current folder name +- `path`: show the current path + ## Block Let's take a closer look at what defines a block. diff --git a/engine.go b/engine.go index 3126248c..6cc1ff33 100644 --- a/engine.go +++ b/engine.go @@ -140,7 +140,14 @@ func (e *engine) render() { } } if e.settings.ConsoleTitle { - e.renderer.setConsoleTitle(e.env.getcwd()) + switch e.settings.ConsoleTitleStyle { + case FullPath: + e.renderer.setConsoleTitle(e.env.getcwd()) + case FolderName: + fallthrough + default: + e.renderer.setConsoleTitle(base(e.env.getcwd(), e.env)) + } } e.renderer.creset() if e.settings.FinalSpace { diff --git a/settings.go b/settings.go index 29428a0e..cfb00c28 100644 --- a/settings.go +++ b/settings.go @@ -8,9 +8,10 @@ import ( // Settings holds all the theme for rendering the prompt type Settings struct { - FinalSpace bool `json:"final_space"` - ConsoleTitle bool `json:"console_title"` - Blocks []*Block `json:"blocks"` + FinalSpace bool `json:"final_space"` + ConsoleTitle bool `json:"console_title"` + ConsoleTitleStyle ConsoleTitleStyle `json:"console_title_style"` + Blocks []*Block `json:"blocks"` } // BlockType type of block @@ -19,6 +20,9 @@ type BlockType string // BlockAlignment aligment of a Block type BlockAlignment string +// ConsoleTitleStyle defines how to show the title in the console window +type ConsoleTitleStyle string + const ( // Prompt writes one or more Segments Prompt BlockType = "prompt" @@ -28,6 +32,10 @@ const ( Left BlockAlignment = "left" // Right aligns right Right BlockAlignment = "right" + // FolderName show the current folder name + FolderName ConsoleTitleStyle = "folder" + // FullPath show the current path + FullPath ConsoleTitleStyle = "path" ) // Block defines a part of the prompt with optional segments @@ -74,7 +82,9 @@ func loadUserConfiguration(env environmentInfo) (*Settings, error) { func getDefaultSettings(info string) *Settings { settings := &Settings{ - FinalSpace: true, + FinalSpace: true, + ConsoleTitle: true, + ConsoleTitleStyle: FolderName, Blocks: []*Block{ { Type: Prompt,