Skip to content

Commit

Permalink
Improved the priority subsystem, and added a flag to only use a certain
Browse files Browse the repository at this point in the history
percentage of the width of the window.
  • Loading branch information
justjanne committed Aug 24, 2017
1 parent 16a46ce commit 8d337e2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 12 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ Usage of powerline-go:
Use East Asian Ambiguous Widths
-error int
Exit code of previously executed command
-max-width int
Maximum width of the shell that the prompt may use, in percent.
(default 50)
-mode string
The characters used to make separators between segments.
(valid choices: patched, compatible, flat)
Expand All @@ -152,6 +155,10 @@ Usage of powerline-go:
(default "venv,user,host,ssh,cwd,perms,git,hg,jobs,exit,root")
-newline
Show the prompt on a new line
-priority string
Segments sorted by priority, if not enough space exists, the least priorized segments are removed first. Separate with ','
(valid choices: cwd, docker, exit, git-branch, git-status, hg, host, jobs, perms, root, ssh, time, user, venv)
(default "root,cwd,user,host,ssh,perms,git-branch,git-status,hg,jobs,exit")
-shell string
Set this to your shell type
(valid choices: bare, bash, zsh)
Expand Down
29 changes: 17 additions & 12 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,19 @@ type segment struct {
}

type args struct {
CwdMode *string
CwdMaxDepth *int
CwdMaxDirSize *int
ColorizeHostname *bool
EastAsianWidth *bool
PromptOnNewLine *bool
Mode *string
Theme *string
Shell *string
Modules *string
Priority *string
PrevError *int
CwdMode *string
CwdMaxDepth *int
CwdMaxDirSize *int
ColorizeHostname *bool
EastAsianWidth *bool
PromptOnNewLine *bool
Mode *string
Theme *string
Shell *string
Modules *string
Priority *string
MaxWidthPercentage *int
PrevError *int
}

func warn(msg string) {
Expand Down Expand Up @@ -119,6 +120,10 @@ func main() {
"Segments sorted by priority, if not enough space exists, the least priorized segments are removed first. Separate with ','\n"+
" (valid choices: cwd, docker, exit, git-branch, git-status, hg, host, jobs, perms, root, ssh, time, user, venv)\n"+
" "),
MaxWidthPercentage: flag.Int("max-width",
50,
"Maximum width of the shell that the prompt may use, in percent.\n"+
" "),
PrevError: flag.Int("error", 0,
"Exit code of previously executed command"),
}
Expand Down
2 changes: 2 additions & 0 deletions powerline.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ func (p *powerline) draw() string {
shellMaxLength64, _ := strconv.ParseInt(shellMaxLengthStr, 0, 64)
shellMaxLength := int(shellMaxLength64)

shellMaxLength = shellMaxLength * *p.args.MaxWidthPercentage / 100

shellActualLength := 0
if shellMaxLength > 0 {
for _, segment := range p.Segments {
Expand Down

0 comments on commit 8d337e2

Please sign in to comment.