Skip to content

Commit

Permalink
Add shenv support
Browse files Browse the repository at this point in the history
  • Loading branch information
scop committed Dec 12, 2019
1 parent c9f514f commit 381efb0
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 6 deletions.
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -185,11 +185,11 @@ Usage of ./powerline-go:
(default "patched")
-modules string
The list of modules to load, separated by ','
(valid choices: aws, cwd, docker, dotenv, duration, exit, git, gitlite, hg, host, jobs, kube, load, newline, nix-shell, node, perlbrew, perms, plenv, root, shell-var, ssh, svn, termtitle, terraform-workspace, time, user, venv, vgo)
(valid choices: aws, cwd, docker, dotenv, duration, exit, git, gitlite, hg, host, jobs, kube, load, newline, nix-shell, node, perlbrew, perms, plenv, root, shell-var, shenv, ssh, svn, termtitle, terraform-workspace, time, user, venv, vgo)
(default "venv,user,host,ssh,cwd,perms,git,hg,jobs,exit,root")
-modules-right string
The list of modules to load anchored to the right, for shells that support it, separated by ','
(valid choices: aws, cwd, docker, dotenv, duration, exit, git, gitlite, hg, host, jobs, kube, load, newline, nix-shell, node, perlbrew, perms, plenv, root, shell-var, ssh, svn, termtitle, terraform-workspace, time, user, venv, vgo)
(valid choices: aws, cwd, docker, dotenv, duration, exit, git, gitlite, hg, host, jobs, kube, load, newline, nix-shell, node, perlbrew, perms, plenv, root, shell-var, shenv, ssh, svn, termtitle, terraform-workspace, time, user, venv, vgo)
-newline
Show the prompt on a new line
-numeric-exit-codes
Expand All @@ -201,7 +201,7 @@ Usage of ./powerline-go:
Use '~' for your home dir. You may need to escape this character to avoid shell substitution.
-priority string
Segments sorted by priority, if not enough space exists, the least priorized segments are removed first. Separate with ','
(valid choices: aws, cwd, docker, dotenv, duration, exit, git, gitlite, hg, host, jobs, kube, load, newline, nix-shell, node, perlbrew, perms, plenv, root, shell-var, ssh, svn, termtitle, terraform-workspace, time, user, venv, vgo)
(valid choices: aws, cwd, docker, dotenv, duration, exit, git, gitlite, hg, host, jobs, kube, load, newline, nix-shell, node, perlbrew, perms, plenv, root, shell-var, shenv, ssh, svn, termtitle, terraform-workspace, time, user, venv, vgo)
(default "root,cwd,user,host,ssh,perms,git-branch,git-status,hg,jobs,exit,cwd-path")
-shell string
Set this to your shell type
Expand Down
10 changes: 10 additions & 0 deletions defaults.go
Expand Up @@ -173,6 +173,9 @@ var themes = map[string]Theme{
ShellVarFg: 52,
ShellVarBg: 11,

ShEnvFg: 15,
ShEnvBg: 130,

NodeFg: 15,
NodeBg: 40,

Expand Down Expand Up @@ -533,6 +536,9 @@ var themes = map[string]Theme{
TimeFg: 236,
TimeBg: 15,

ShEnvFg: 130,
ShEnvBg: 15,

LoadFg: 15,
LoadBg: 22,
LoadHighBg: 161,
Expand Down Expand Up @@ -861,6 +867,8 @@ var themes = map[string]Theme{
TimeBg: 0,
ShellVarFg: 1,
ShellVarBg: 11,
ShEnvFg: 15,
ShEnvBg: 9,
NodeFg: 15,
NodeBg: 40,
LoadFg: 15,
Expand Down Expand Up @@ -1189,6 +1197,8 @@ var themes = map[string]Theme{
TimeBg: 0,
ShellVarFg: 1,
ShellVarBg: 11,
ShEnvFg: 15,
ShEnvBg: 9,
NodeFg: 15,
NodeBg: 40,
LoadFg: 15,
Expand Down
7 changes: 4 additions & 3 deletions main.go
Expand Up @@ -109,6 +109,7 @@ var modules = map[string]func(*powerline){
"perms": segmentPerms,
"root": segmentRoot,
"shell-var": segmentShellVar,
"shenv": segmentShEnv,
"ssh": segmentSSH,
"termtitle": segmentTermTitle,
"terraform-workspace": segmentTerraformWorkspace,
Expand Down Expand Up @@ -178,17 +179,17 @@ func main() {
"modules",
"venv,user,host,ssh,cwd,perms,git,hg,jobs,exit,root",
commentsWithDefaults("The list of modules to load, separated by ','",
"(valid choices: aws, cwd, docker, dotenv, duration, exit, git, gitlite, hg, host, jobs, kube, load, newline, nix-shell, node, perlbrew, perms, plenv, root, shell-var, ssh, svn, termtitle, terraform-workspace, time, user, venv, vgo)")),
"(valid choices: aws, cwd, docker, dotenv, duration, exit, git, gitlite, hg, host, jobs, kube, load, newline, nix-shell, node, perlbrew, perms, plenv, root, shell-var, shenv, ssh, svn, termtitle, terraform-workspace, time, user, venv, vgo)")),
ModulesRight: flag.String(
"modules-right",
"",
comments("The list of modules to load anchored to the right, for shells that support it, separated by ','",
"(valid choices: aws, cwd, docker, dotenv, duration, exit, git, gitlite, hg, host, jobs, kube, load, newline, nix-shell, node, perlbrew, perms, plenv, root, shell-var, ssh, svn, termtitle, terraform-workspace, time, user, venv, vgo)")),
"(valid choices: aws, cwd, docker, dotenv, duration, exit, git, gitlite, hg, host, jobs, kube, load, newline, nix-shell, node, perlbrew, perms, plenv, root, shell-var, shenv, ssh, svn, termtitle, terraform-workspace, time, user, venv, vgo)")),
Priority: flag.String(
"priority",
"root,cwd,user,host,ssh,perms,git-branch,git-status,hg,jobs,exit,cwd-path",
commentsWithDefaults("Segments sorted by priority, if not enough space exists, the least priorized segments are removed first. Separate with ','",
"(valid choices: aws, cwd, docker, dotenv, duration, exit, git, gitlite, hg, host, jobs, kube, load, newline, nix-shell, node, perlbrew, perms, plenv, root, shell-var, ssh, svn, termtitle, terraform-workspace, time, user, venv, vgo)")),
"(valid choices: aws, cwd, docker, dotenv, duration, exit, git, gitlite, hg, host, jobs, kube, load, newline, nix-shell, node, perlbrew, perms, plenv, root, shell-var, shenv, ssh, svn, termtitle, terraform-workspace, time, user, venv, vgo)")),
MaxWidthPercentage: flag.Int(
"max-width",
0,
Expand Down
23 changes: 23 additions & 0 deletions segment-shenv.go
@@ -0,0 +1,23 @@
package main

import (
pwl "github.com/justjanne/powerline-go/powerline"
"os"
"path"
)

func segmentShEnv(p *powerline) {
var env string
if env == "" {
env, _ = os.LookupEnv("SHENV_VERSION")
}
if env == "" {
return
}
envName := path.Base(env)
p.appendSegment("shenv", pwl.Segment{
Content: envName,
Foreground: p.theme.ShEnvFg,
Background: p.theme.ShEnvBg,
})
}
3 changes: 3 additions & 0 deletions themes.go
Expand Up @@ -119,6 +119,9 @@ type Theme struct {
ShellVarFg uint8
ShellVarBg uint8

ShEnvFg uint8
ShEnvBg uint8

NodeFg uint8
NodeBg uint8

Expand Down
2 changes: 2 additions & 0 deletions themes/default.json
Expand Up @@ -58,6 +58,8 @@
"TimeBg": 236,
"ShellVarFg": 52,
"ShellVarBg": 11,
"ShEnvFg": 15,
"ShEnvBg": 130,
"NodeFg": 15,
"NodeBg": 40,
"LoadFg": 15,
Expand Down

0 comments on commit 381efb0

Please sign in to comment.