Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: module to display current screen session #286

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,12 @@ Usage of powerline-go:
(default "patched")
-modules string
The list of modules to load, separated by ','
(valid choices: aws, bzr, cwd, docker, docker-context, dotenv, duration, exit, fossil, git, gitlite, goenv, 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)
(valid choices: aws, bzr, cwd, docker, docker-context, dotenv, duration, exit, fossil, git, gitlite, goenv, hg, host, jobs, kube, load, newline, nix-shell, node, perlbrew, perms, plenv, root, screen, shell-var, shenv, ssh, svn, termtitle, terraform-workspace, time, user, venv, vgo)
Unrecognized modules will be invoked as 'powerline-go-MODULE' executable plugins and should output a (possibly empty) list of JSON objects that unmarshal to powerline-go's Segment structs.
(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, bzr, cwd, docker, docker-context, dotenv, duration, exit, fossil, git, gitlite, goenv, 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)
(valid choices: aws, bzr, cwd, docker, docker-context, dotenv, duration, exit, fossil, git, gitlite, goenv, hg, host, jobs, kube, load, newline, nix-shell, node, perlbrew, perms, plenv, root, screen, shell-var, shenv, ssh, svn, termtitle, terraform-workspace, time, user, venv, vgo)
Unrecognized modules will be invoked as 'powerline-go-MODULE' executable plugins and should output a (possibly empty) list of JSON objects that unmarshal to powerline-go's Segment structs.
-newline
Show the prompt on a new line
Expand All @@ -267,7 +267,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, bzr, cwd, docker, docker-context, dotenv, duration, exit, fossil, 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)
(valid choices: aws, bzr, cwd, docker, docker-context, dotenv, duration, exit, fossil, git, gitlite, hg, host, jobs, kube, load, newline, nix-shell, node, perlbrew, perms, plenv, root, screen, 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
3 changes: 3 additions & 0 deletions defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,9 @@ var defaults = Config{
VirtualEnvFg: 00,
VirtualEnvBg: 35, // a mid-tone green

ScreenFg: 15, // white
ScreenBg: 26, // blue

VirtualGoFg: 220, // approx. Secondary Yellow
VirtualGoBg: 38, // approx. Gopher Blue

Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ var modules = map[string]func(*powerline) []pwl.Segment{
"perms": segmentPerms,
"rbenv": segmentRbenv,
"root": segmentRoot,
"screen": segmentScreenName,
"shell-var": segmentShellVar,
"shenv": segmentShEnv,
"ssh": segmentSSH,
Expand Down
30 changes: 30 additions & 0 deletions segment-screen.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package main

import (
"os"
"strings"

pwl "github.com/justjanne/powerline-go/powerline"
)

func segmentScreenName(p *powerline) []pwl.Segment {
var env string
if env == "" {
env, _ = os.LookupEnv("STY")
}
if env == "" {
return []pwl.Segment{}
}
// envName := env
envName := strings.Split(env, ".")[1]
if p.cfg.VenvNameSizeLimit > 0 && len(envName) > p.cfg.VenvNameSizeLimit {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like a bad idea to reuse settings from the Venv-segment. ;)

envName = p.symbols.VenvIndicator
}

return []pwl.Segment{{
Name: "screen",
Content: envName,
Foreground: p.theme.ScreenFg,
Background: p.theme.ScreenBg,
}}
}
3 changes: 3 additions & 0 deletions themes.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ type Theme struct {
VirtualEnvFg uint8
VirtualEnvBg uint8

ScreenFg uint8
ScreenBg uint8

VirtualGoFg uint8
VirtualGoBg uint8

Expand Down