Documentation ¶
Index ¶
- Constants
- func ResetBackground() []byte
- func ResetFgBg() []byte
- func ResetForeground() []byte
- func SetBackground(background uint8) []byte
- func SetForeground(foreground uint8) []byte
- func SetTrueColorBackground(r, g, b int) []byte
- func SetTrueColorForeground(r, g, b int) []byte
- type Prompt
- type Segment
- type SegmentCWD
- type SegmentEnv
- type SegmentGit
- type SegmentHostname
- type SegmentRoot
- type SegmentUnknown
- type SegmentUsername
- type SegmentVirtualEnv
Constants ¶
const ( // SegmentEnvBackgroundR ... SegmentEnvBackgroundR = 163 // SegmentEnvBackgroundG ... SegmentEnvBackgroundG = 104 // SegmentEnvBackgroundB ... SegmentEnvBackgroundB = 75 )
const ( // SegmentGitBackground is the background color to use SegmentGitBackground = 148 // #afd700 // SegmentGitBackgroundR ... SegmentGitBackgroundR = 160 // SegmentGitBackgroundG ... SegmentGitBackgroundG = 180 // SegmentGitBackgroundB ... SegmentGitBackgroundB = 117 // SegmentGitForeground is the foreground color to use SegmentGitForeground = 0 // #000000 )
const ( // SegmentVirtualEnvBackground is the background color to use SegmentVirtualEnvBackground = 22 // #585858 // SegmentVirtualEnvBackgroundR ... SegmentVirtualEnvBackgroundR = 61 // SegmentVirtualEnvBackgroundG ... SegmentVirtualEnvBackgroundG = 116 // SegmentVirtualEnvBackgroundB ... SegmentVirtualEnvBackgroundB = 132 )
const ( // DefaultSegments are tbe list of segments to show on the prompt by // default. DefaultSegments = "username,hostname,virtualenv,cwd,git,root" )
const ( // SegmentCWDBackground is the background color to use SegmentCWDBackground = 237 // #3a3a3a )
const ( // SegmentHostnameBackground is the background color to use SegmentHostnameBackground = 238 // #444444 )
const ( // SegmentRootBackground is the background color to use SegmentRootBackground = 236 // #303030 )
const ( // SegmentUsernameBackground is the background color to use SegmentUsernameBackground = 240 // #585858 )
Variables ¶
This section is empty.
Functions ¶
func ResetBackground ¶
func ResetBackground() []byte
ResetBackground reset background to default value.
func ResetFgBg ¶
func ResetFgBg() []byte
ResetFgBg resets foreground and background to default values.
func ResetForeground ¶
func ResetForeground() []byte
ResetForeground reset foreground to default value.
func SetBackground ¶
SetBackground sets background color on the terminal
func SetForeground ¶
SetForeground sets foreground color on the terminal.
func SetTrueColorBackground ¶
SetTrueColorBackground sets background color on the terminal using true color format.
func SetTrueColorForeground ¶
SetTrueColorForeground sets foreground color on the terminal using true color format.
Types ¶
type Prompt ¶
type Prompt struct {
// contains filtered or unexported fields
}
Prompt type that defines the shell prompt structure.
type Segment ¶
type Segment interface { Compile() Render() []byte }
Segment is a partial or portion of the final prompt.
type SegmentCWD ¶
type SegmentCWD struct {
Data []byte
}
SegmentCWD implements the current working directory partial of the prompt.
It renders the current working directory path.
func NewSegmentCWD ¶
func NewSegmentCWD() *SegmentCWD
NewSegmentCWD creates an instace of SegmentCWD type.
func (*SegmentCWD) Compile ¶
func (s *SegmentCWD) Compile()
Compile collects the data for this segment.
func (*SegmentCWD) Render ¶
func (s *SegmentCWD) Render() []byte
Render renders the segment results.
type SegmentEnv ¶
type SegmentEnv struct {
Data []byte
}
SegmentEnv implements the python virtual env partial of the prompt.
Renders the current virtalenv python environment name if it is available.
func NewSegmentEnv ¶
func NewSegmentEnv() *SegmentEnv
NewSegmentEnv creates an instace of SegmentEnv type.
func (*SegmentEnv) Compile ¶
func (s *SegmentEnv) Compile()
Compile collects the data for this segment.
func (*SegmentEnv) Render ¶
func (s *SegmentEnv) Render() []byte
Render renders the segment results.
type SegmentGit ¶
type SegmentGit struct {
Data []byte
}
SegmentGit implements the git SCM partial of the prompt.
It renders the current branch if the folder contains a repository.
TODO: * git rev-parse --show-toplevel : shows root of the repo * git status --porcelain -b : shows conmplete status of the repo
func NewSegmentGit ¶
func NewSegmentGit() *SegmentGit
NewSegmentGit creates an instace of SegmentGit type.
func (*SegmentGit) Compile ¶
func (s *SegmentGit) Compile()
Compile collects the data for this segment.
func (*SegmentGit) Render ¶
func (s *SegmentGit) Render() []byte
Render renders the segment results.
type SegmentHostname ¶
type SegmentHostname struct {
Data []byte
}
SegmentHostname implements the hostname partial of the prompt.
It renders the current hostname up to the first '.'
TODO: * Add support for long/conmplete hostname.
func NewSegmentHostname ¶
func NewSegmentHostname() *SegmentHostname
NewSegmentHostname creates an instace of SegmentHostname type.
func (*SegmentHostname) Compile ¶
func (s *SegmentHostname) Compile()
Compile collects the data for this segment.
func (*SegmentHostname) Render ¶
func (s *SegmentHostname) Render() []byte
Render renders the segment results.
type SegmentRoot ¶
type SegmentRoot struct {
Data []byte
}
SegmentRoot implements the root partial of the prompt.
It renders the special character string "\$". In bash this results to character '#' if the effective UID is 0, otherwise '$'.
TODO: * Change background color if the last command exit status != 0
func NewSegmentRoot ¶
func NewSegmentRoot() *SegmentRoot
NewSegmentRoot creates an instace of SegmentRoot type.
func (*SegmentRoot) Compile ¶
func (s *SegmentRoot) Compile()
Compile collects the data for this segment.
func (*SegmentRoot) Render ¶
func (s *SegmentRoot) Render() []byte
Render renders the segment results.
type SegmentUnknown ¶
type SegmentUnknown struct {
Data []byte
}
SegmentUnknown implements the not-found segment partial of the prompt.
It renders an empty string.
func NewSegmentUnknown ¶
func NewSegmentUnknown() *SegmentUnknown
NewSegmentUnknown creates an instace of SegmentUnknown type.
func (*SegmentUnknown) Render ¶
func (s *SegmentUnknown) Render() []byte
Render renders the segment results.
type SegmentUsername ¶
type SegmentUsername struct {
Data []byte
}
SegmentUsername implements the username partial of the prompt.
Renders the current username.
TODO: * If the user is root (uid=0) use a different background.
func NewSegmentUsername ¶
func NewSegmentUsername() *SegmentUsername
NewSegmentUsername creates an instace of SegmentUsername type.
func (*SegmentUsername) Compile ¶
func (s *SegmentUsername) Compile()
Compile collects the data for this segment.
func (*SegmentUsername) Render ¶
func (s *SegmentUsername) Render() []byte
Render renders the segment results.
type SegmentVirtualEnv ¶
type SegmentVirtualEnv struct {
Data []byte
}
SegmentVirtualEnv implements the python virtual env partial of the prompt.
Renders the current virtalenv python environment name if it is available.
func NewSegmentVirtualEnv ¶
func NewSegmentVirtualEnv() *SegmentVirtualEnv
NewSegmentVirtualEnv creates an instace of SegmentVirtualEnv type.
func (*SegmentVirtualEnv) Compile ¶
func (s *SegmentVirtualEnv) Compile()
Compile collects the data for this segment.
func (*SegmentVirtualEnv) Render ¶
func (s *SegmentVirtualEnv) Render() []byte
Render renders the segment results.