Skip to content

Commit

Permalink
Added module for docker machine names
Browse files Browse the repository at this point in the history
  • Loading branch information
justjanne committed Aug 22, 2017
1 parent 56a5438 commit bbc1154
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 11 deletions.
23 changes: 13 additions & 10 deletions defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,24 @@ var symbolTemplates = map[string]Symbols{
},
}

var shellInfos = map[string]ShellInfo {
var shellInfos = map[string]ShellInfo{
"bash": {
colorTemplate: "\\[\\e%s\\]",
rootIndicator: " \\$ ",
colorTemplate: "\\[\\e%s\\]",
rootIndicator: " \\$ ",
escapedBackslash: `\\\\`,
escapedDollar: `\$`,
escapedDollar: `\$`,
},
"zsh": {
colorTemplate: "%%{\u001b%s%%}",
rootIndicator: " %# ",
colorTemplate: "%%{\u001b%s%%}",
rootIndicator: " %# ",
escapedBackslash: `\\`,
escapedDollar: `\$`,
escapedDollar: `\$`,
},
"bare": {
colorTemplate: "%s",
rootIndicator: " $ ",
colorTemplate: "%s",
rootIndicator: " $ ",
escapedBackslash: `\`,
escapedDollar: `$`,
escapedDollar: `$`,
},
}

Expand Down Expand Up @@ -70,6 +70,9 @@ var defaultTheme = Theme{
SshFg: 254,
SshBg: 166, // medium orange

DockerMachineFg: 177, // light purple
DockerMachineBg: 55, // purple

RepoCleanFg: 0, // black
RepoCleanBg: 148, // a light green color
RepoDirtyFg: 15, // white
Expand Down
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ func getValidCwd() string {

var modules = map[string](func(*powerline)){
"cwd": segmentCwd,
"docker": segmentDocker,
"exit": segmentExitCode,
"git": segmentGit,
"hg": segmentHg,
Expand Down Expand Up @@ -101,7 +102,7 @@ func main() {
Modules: flag.String("modules",
"venv,user,ssh,host,cwd,perms,git,hg,jobs,exit,root",
"The list of modules to load. Separate with ','\n"+
" (valid choices: cwd, exit, git, hg, host, jobs, perms, root, ssh, user, venv)\n"+
" (valid choices: cwd, docker, exit, git, hg, host, jobs, perms, root, ssh, user, venv)\n"+
" "),
PrevError: flag.Int("error", 0,
"Exit code of previously executed command"),
Expand Down
17 changes: 17 additions & 0 deletions segment-docker.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package main

import (
"os"
"fmt"
)

func segmentDocker(p *powerline) {
dockerMachineName, _ := os.LookupEnv("DOCKER_MACHINE_NAME")
if dockerMachineName != "" {
p.appendSegment(segment{
content: fmt.Sprintf(" %s ", dockerMachineName),
foreground: p.theme.DockerMachineFg,
background: p.theme.DockerMachineBg,
})
}
}
3 changes: 3 additions & 0 deletions themes.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ type Theme struct {
SshFg uint8
SshBg uint8

DockerMachineFg uint8
DockerMachineBg uint8

RepoCleanFg uint8
RepoCleanBg uint8
RepoDirtyFg uint8
Expand Down

0 comments on commit bbc1154

Please sign in to comment.