mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-28 20:39:40 -08:00
parent
395a250ca5
commit
7cb752abcb
|
@ -47,16 +47,22 @@ theme.
|
||||||
oh-my-posh -config sample.json -shell universal
|
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
|
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
|
||||||
question marks, [set up your terminal][setupterm] to use a supported font before continuing.
|
boxes with question marks, [set up your terminal][setupterm] to use a supported font before continuing.
|
||||||
|
|
||||||
## General Settings
|
## General Settings
|
||||||
|
|
||||||
- final_space: `boolean` - when true adds a space at the end of the prompt
|
- 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: `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
|
> "I Like The Way You Speak Words" - Gary Goodspeed
|
||||||
|
|
||||||
|
### Console Title Style
|
||||||
|
|
||||||
|
- `folder`: show the current folder name
|
||||||
|
- `path`: show the current path
|
||||||
|
|
||||||
## Block
|
## Block
|
||||||
|
|
||||||
Let's take a closer look at what defines a block.
|
Let's take a closer look at what defines a block.
|
||||||
|
|
|
@ -140,7 +140,14 @@ func (e *engine) render() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if e.settings.ConsoleTitle {
|
if e.settings.ConsoleTitle {
|
||||||
|
switch e.settings.ConsoleTitleStyle {
|
||||||
|
case FullPath:
|
||||||
e.renderer.setConsoleTitle(e.env.getcwd())
|
e.renderer.setConsoleTitle(e.env.getcwd())
|
||||||
|
case FolderName:
|
||||||
|
fallthrough
|
||||||
|
default:
|
||||||
|
e.renderer.setConsoleTitle(base(e.env.getcwd(), e.env))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
e.renderer.creset()
|
e.renderer.creset()
|
||||||
if e.settings.FinalSpace {
|
if e.settings.FinalSpace {
|
||||||
|
|
10
settings.go
10
settings.go
|
@ -10,6 +10,7 @@ import (
|
||||||
type Settings struct {
|
type Settings struct {
|
||||||
FinalSpace bool `json:"final_space"`
|
FinalSpace bool `json:"final_space"`
|
||||||
ConsoleTitle bool `json:"console_title"`
|
ConsoleTitle bool `json:"console_title"`
|
||||||
|
ConsoleTitleStyle ConsoleTitleStyle `json:"console_title_style"`
|
||||||
Blocks []*Block `json:"blocks"`
|
Blocks []*Block `json:"blocks"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +20,9 @@ type BlockType string
|
||||||
// BlockAlignment aligment of a Block
|
// BlockAlignment aligment of a Block
|
||||||
type BlockAlignment string
|
type BlockAlignment string
|
||||||
|
|
||||||
|
// ConsoleTitleStyle defines how to show the title in the console window
|
||||||
|
type ConsoleTitleStyle string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// Prompt writes one or more Segments
|
// Prompt writes one or more Segments
|
||||||
Prompt BlockType = "prompt"
|
Prompt BlockType = "prompt"
|
||||||
|
@ -28,6 +32,10 @@ const (
|
||||||
Left BlockAlignment = "left"
|
Left BlockAlignment = "left"
|
||||||
// Right aligns right
|
// Right aligns right
|
||||||
Right BlockAlignment = "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
|
// Block defines a part of the prompt with optional segments
|
||||||
|
@ -75,6 +83,8 @@ func loadUserConfiguration(env environmentInfo) (*Settings, error) {
|
||||||
func getDefaultSettings(info string) *Settings {
|
func getDefaultSettings(info string) *Settings {
|
||||||
settings := &Settings{
|
settings := &Settings{
|
||||||
FinalSpace: true,
|
FinalSpace: true,
|
||||||
|
ConsoleTitle: true,
|
||||||
|
ConsoleTitleStyle: FolderName,
|
||||||
Blocks: []*Block{
|
Blocks: []*Block{
|
||||||
{
|
{
|
||||||
Type: Prompt,
|
Type: Prompt,
|
||||||
|
|
Loading…
Reference in a new issue