Giter VIP home page Giter VIP logo

powerline-go's Introduction

A Powerline style prompt for your shell

A Powerline like prompt for Bash, ZSH and Fish. Based on Powerline-Shell by @banga. Ported to golang by @justjanne.

Solarized+Powerline

  • Shows some important details about the git/hg branch (see below)
  • Changes color if the last command exited with a failure code
  • If you're too deep into a directory tree, shortens the displayed path with an ellipsis
  • Shows the current Python virtualenv environment
  • Shows the current Ruby version using rbenv or rvm
  • Shows if you are in a nix shell
  • It's easy to customize and extend. See below for details.

Table of Contents

Version Control

All of the version control systems supported by powerline shell give you a quick look into the state of your repo:

  • The current branch is displayed and changes background color when the branch is dirty.
  • When the local branch differs from the remote, the difference in number of commits is shown along with or indicating whether a git push or pull is pending

In addition, git has a few extra symbols:

  • -- a file has been modified, but not staged for commit
  • -- a file is staged for commit
  • -- a file has conflicts
  • + -- untracked files are present
  • -- stash is present

Each of these will have a number next to it if more than one file matches.

Installation

Requires Go 1.15+

powerline-go uses ANSI color codes, these should nowadays work everywhere, but you may have to set your $TERM to xterm-256color for it to work.

If you want to use the "patched" mode (which is the default, and provides improved UI), you'll need to install a powerline font, either as fallback, or by patching the font you use for your terminal: see powerline-fonts. Alternatively you can use "compatible" or "flat" mode.

Precompiled Binaries

I provide precompiled binaries for x64 Linux and macOS in the releases tab

Other Platforms

  • Install (and update) the package with
go install github.com/justjanne/powerline-go@latest
  • By default it will be in $GOPATH/bin, if you want to change that, you can set your $GOPATH and/or $GOBIN, but will need to change the path in the following scripts, too.

Bash

Add the following to your .bashrc:

function _update_ps1() {
    PS1="$($GOPATH/bin/powerline-go -error $? -jobs $(jobs -p | wc -l))"

    # Uncomment the following line to automatically clear errors after showing
    # them once. This not only clears the error for powerline-go, but also for
    # everything else you run in that shell. Don't enable this if you're not
    # sure this is what you want.

    #set "?"
}

if [ "$TERM" != "linux" ] && [ -f "$GOPATH/bin/powerline-go" ]; then
    PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND"
fi

Currently, right prompt support is not available when using bash.

ZSH

Add the following to your .zshrc:

function powerline_precmd() {
    PS1="$($GOPATH/bin/powerline-go -error $? -jobs ${${(%):%j}:-0})"

    # Uncomment the following line to automatically clear errors after showing
    # them once. This not only clears the error for powerline-go, but also for
    # everything else you run in that shell. Don't enable this if you're not
    # sure this is what you want.

    #set "?"
}

function install_powerline_precmd() {
  for s in "${precmd_functions[@]}"; do
    if [ "$s" = "powerline_precmd" ]; then
      return
    fi
  done
  precmd_functions+=(powerline_precmd)
}

if [ "$TERM" != "linux" ] && [ -f "$GOPATH/bin/powerline-go" ]; then
    install_powerline_precmd
fi

Fish

Redefine fish_prompt in ~/.config/fish/config.fish:

function fish_prompt
    eval $GOPATH/bin/powerline-go -error $status -jobs (count (jobs -p))
end

Nix

When using nix-shell --pure, powerline-go will not be accessible, and your prompt will disappear.

To work around this you can add this snippet to your .bashrc, which should re-enable the prompt in most cases:

# Workaround for nix-shell --pure
if [ "$IN_NIX_SHELL" == "pure" ]; then
    if [ -x "$HOME/.nix-profile/bin/powerline-go" ]; then
        alias powerline-go="$HOME/.nix-profile/bin/powerline-go"
    elif [ -x "/run/current-system/sw/bin/powerline-go" ]; then
        alias powerline-go="/run/current-system/sw/bin/powerline-go"
    fi
fi

Powershell

Redefine prompt function on your profile:

# Load powerline-go prompt
function global:prompt {
    $pwd = $ExecutionContext.SessionState.Path.CurrentLocation
    $startInfo = New-Object System.Diagnostics.ProcessStartInfo
    $startInfo.FileName = "powerline-go"
    $startInfo.Arguments = "-shell bare"
    $startInfo.Environment["TERM"] = "xterm-256color"
    $startInfo.CreateNoWindow = $true
    $startInfo.StandardOutputEncoding = [System.Text.Encoding]::UTF8
    $startInfo.RedirectStandardOutput = $true
    $startInfo.UseShellExecute = $false
    $startInfo.WorkingDirectory = $pwd
    $process = New-Object System.Diagnostics.Process
    $process.StartInfo = $startInfo
    $process.Start() | Out-Null
    $standardOut = $process.StandardOutput.ReadToEnd()
    $process.WaitForExit()
    $standardOut
}

Use ProcessStartInfo is needed to allow fill the enviromnet variables required by powerline-go.

Customization

There are a few optional arguments which can be seen by running powerline-go -help. These can be used by changing the command you have set in your shell’s init file.

Usage of powerline-go:
  -alternate-ssh-icon
         Show the older, original icon for SSH connections
  -colorize-hostname
         Colorize the hostname based on a hash of itself, or use the PLGO_HOSTNAMEFG and PLGO_HOSTNAMEBG env vars (both need to be set).
  -condensed
         Remove spacing between segments
  -cwd-max-depth int
         Maximum number of directories to show in path
         (default 5)
  -cwd-max-dir-size int
         Maximum number of letters displayed for each directory in the path
         (default -1)
  -cwd-mode string
         How to display the current directory
         (valid choices: fancy, semifancy, plain, dironly)
         (default "fancy")
  -duration string
         The elapsed clock-time of the previous command
  -duration-min string
         The minimal time a command has to take before the duration segment is shown (default "0")
  -east-asian-width
         Use East Asian Ambiguous Widths
  -error int
         Exit code of previously executed command
  -eval
         Output prompt in 'eval' format.
  -git-assume-unchanged-size int
         Disable checking for changed/edited files in git repositories where the index is larger than this size (in KB), improves performance (default 2048)
  -git-disable-stats string
         Comma-separated list to disable individual git statuses
         (valid choices: ahead, behind, staged, notStaged, untracked, conflicted, stashed)
  -git-mode string
         How to display git status
         (valid choices: fancy, compact, simple)
         (default "fancy")
  -hostname-only-if-ssh
         Show hostname only for SSH connections
  -ignore-repos string
         A list of git repos to ignore. Separate with ','.
         Repos are identified by their root directory.
  -ignore-warnings
         Ignores all warnings regarding unset or broken variables
  -jobs int
         Number of jobs currently running
  -max-width int
         Maximum width of the shell that the prompt may use, in percent. Setting this to 0 disables the shrinking subsystem.
  -mode string
         The characters used to make separators between segments.
         (valid choices: patched, compatible, flat)
         (default "patched")
  -modules string
         The list of modules to load, separated by ','
         (valid choices: aws, bzr, cwd, direnv, docker, docker-context, dotenv, duration, exit, fossil, gcp, git, gitlite, goenv, hg, host, jobs, kube, load, newline, nix-shell, node, perlbrew, perms, plenv, rbenv, root, rvm, shell-var, shenv, ssh, svn, termtitle, terraform-workspace, time, user, venv, vgo, vi-mode, wsl)
         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, direnv, docker, docker-context, dotenv, duration, exit, fossil, gcp, git, gitlite, goenv, hg, host, jobs, kube, load, newline, nix-shell, node, perlbrew, perms, plenv, rbenv, root, rvm, shell-var, shenv, ssh, svn, termtitle, terraform-workspace, time, user, venv, vgo, wsl)
         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
  -numeric-exit-codes
         Shows numeric exit codes for errors.
  -path-aliases string
         One or more aliases from a path to a short name. Separate with ','.
         An alias maps a path like foo/bar/baz to a short name like FBB.
         Specify these as key/value pairs like foo/bar/baz=FBB.
         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, direnv, docker, docker-context, dotenv, duration, exit, fossil, gcp, git, gitlite, goenv, hg, host, jobs, kube, load, newline, nix-shell, node, perlbrew, perms, plenv, rbenv, root, rvm, shell-var, shenv, ssh, svn, termtitle, terraform-workspace, time, user, venv, vgo, vi-mode, wsl)
         (default "root,cwd,user,host,ssh,perms,git-branch,git-status,hg,jobs,exit,cwd-path")
  -shell string
         Set this to your shell type
         (valid choices: autodetect, bare, bash, zsh)
         (default "autodetect")
  -shell-var string
         A shell variable to add to the segments.
  -shell-var-no-warn-empty
         Disables warning for empty shell variable.
  -shorten-eks-names
         Shortens names for EKS Kube clusters.
  -shorten-gke-names
         Shortens names for GKE Kube clusters.
  -static-prompt-indicator
         Always show the prompt indicator with the default color, never with the error color
  -theme string
         Set this to the theme you want to use
         (valid choices: default, low-contrast, gruvbox, solarized-dark16, solarized-light16)
         (default "default")
  -trim-ad-domain
         Trim the Domainname from the AD username.
  -truncate-segment-width int
         Maximum width of a segment, segments longer than this will be shortened if space is limited. Setting this to 0 disables it.
         (default 16)
  -venv-name-size-limit int
         Show indicator instead of virtualenv name if name is longer than this limit (defaults to 0, which is unlimited)
  -vi-mode string
         The current vi-mode (eg. KEYMAP for zsh) for vi-module module

Eval

If using eval and -modules-right is desired, the shell setup must be modified slightly, as shown below:

Bash

Add the following to your .bashrc:

function _update_ps1() {
    eval "$($GOPATH/bin/powerline-go -error $? -shell bash -eval -modules-right git)"
}

if [ "$TERM" != "linux" ] && [ -f "$GOPATH/bin/powerline-go" ]; then
    PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND"
fi
ZSH

Add the following to your .zshrc:

function powerline_precmd() {
    eval "$($GOPATH/bin/powerline-go -error $? -shell zsh -eval -modules-right git)"
}

function install_powerline_precmd() {
  for s in "${precmd_functions[@]}"; do
    if [ "$s" = "powerline_precmd" ]; then
      return
    fi
  done
  precmd_functions+=(powerline_precmd)
}

if [ "$TERM" != "linux" ]; then
    install_powerline_precmd
fi
Fish

Eval mode (and modules-right support) for Fish is not currently available.

Path Aliases

The point of the path aliases feature is to allow you to replace long paths with a shorter string that you can understand more quickly. This is useful if you're often in deep path hierarchies that end up consuming most of your terminal width, even when some portions are replaced by an ellipsis.

For example, you might want to replace the string $GOPATH/src/github.com with @GOPATH-GH. When you're in a directory like $GOPATH/src/github.com/justjanne/powerline-go, you'll instead see @GOPATH-GH > justjanne > powerline-go in the shell prompt.

Aliases are defined as comma-separated key value pairs, like this:

powerline-go ... -path-aliases \$GOPATH/src/github.com=@GOPATH-GH,\~/work/projects/foo=@FOO,\~/work/projects/bar=@BAR

Note that you should use ~ instead of /home/username when specifying the path. Also make sure to escape the ~ character. Otherwise your shell will perform interpolation on it before powerline-go can see it!

Duration

The duration segment requires some assistance from the shell. The shell must have a hook that gets executed immediately before the command.

Bash

Bash 4.4 includes an easy way to get a start-time, using $PS0. However, not all operating systems come with a sufficiently recent version of Bash installed. This example only has seconds precision. Add or modify your .bashrc file to include the following:

INTERACTIVE_BASHPID_TIMER="/tmp/${USER}.START.$$"

PS0='$(echo $SECONDS > "$INTERACTIVE_BASHPID_TIMER")'

function _update_ps1() {
  local __ERRCODE=$?

  local __DURATION=0
  if [ -e $INTERACTIVE_BASHPID_TIMER ]; then
    local __END=$SECONDS
    local __START=$(cat "$INTERACTIVE_BASHPID_TIMER")
    __DURATION="$(($__END - ${__START:-__END}))"
    rm -f "$INTERACTIVE_BASHPID_TIMER"
  fi

  PS1="$($GOPATH/bin/powerline-go -modules duration -duration $__DURATION -error $__ERRCODE -shell bash)"
}

if [ "$TERM" != "linux" ] && [ -f "$GOPATH/bin/powerline-go" ]; then
  PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND"
fi

Zsh

Using $EPOCHREALTIME requires loading the 'datetime' module in your .zshrc file, for example:

zmodload zsh/datetime

function preexec() {
  __TIMER=$EPOCHREALTIME
}

function powerline_precmd() {
  local __ERRCODE=$?
  local __DURATION=0

  if [ -n $__TIMER ]; then
    local __ERT=$EPOCHREALTIME
    __DURATION="$(($__ERT - ${__TIMER:-__ERT}))"
  fi

  PS1="$(powerline-go -modules duration -duration $__DURATION -error $__ERRCODE -shell zsh)"
  unset __TIMER
}

If the 'datetime' module is unavailable or unwanted, you may replace $EPOCHREALTIME with $SECONDS, at the loss of precision.

Fish

The fish prompt, in ~/.config/fish/config.fish, will require a minimum of changes, as Fish automatically provides $CMD_DURATION, although with only milliseconds accuracy.

function fish_prompt
    set duration (math -s6 "$CMD_DURATION / 1000")
    $GOPATH/bin/powerline-go -modules duration -duration $duration -error $status -shell bare
end

License

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

powerline-go's People

Contributors

argoyle avatar autarch avatar belphegor avatar beppler avatar breml avatar buckley310 avatar caleb-artifact avatar cjvaughter avatar dex4er avatar dswij avatar emansije avatar fgaz avatar issif avatar james-antill avatar joemiller avatar justjanne avatar mexchip avatar mjgiarlo avatar mschneider82 avatar object88 avatar pdf avatar picosushi avatar pmenglund avatar scop avatar scottslowe avatar sebastiandeutsch avatar seph-barker avatar tjamet avatar v1gnesh avatar vgropp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

powerline-go's Issues

Support for keymap highlighting

I'm using vi mode as my editor mode in zsh (bindkey -v).

Normal pormpts (part of oh-my-zshell or prezto) are implemented in zsh and they are taking advantage of zle-keymap-select and changing part of the prompt based on $KEYMAP variable.

This is very simple example:

function zle-line-init zle-keymap-select {
    RPS1="${${KEYMAP/vicmd/-- NORMAL --}/(main|viins)/-- INSERT --}"
    RPS2=$RPS1
    zle reset-prompt
}

zle -N zle-line-init
zle -N zle-keymap-select

I'd like to know which vi mode (insert or command) am I using. Any idea how I could implement this feature in powerline-go? I could probably use the function zle-keymap-select to change the RPS1 command or set some environment variable and then call zle reset-prompt. What do you think?

Manual installation instructions not working for Ubuntu 18.04

I've been using powerline-go for a while in both macOS and Ubuntu 16.04 using manual installation into ~/.powerline and using the instructions for installation have always worked for me using the following in by ~/.bash_aliases:

function _update_ps1() {
    PS1="$(~/.powerline/powerline-go-linux-amd64 -error $?)"
}
export PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND"

But after installing 18.04, this no longer works. The prompt is just the normal default Ubuntu prompt. I've tried all I could to figure out what is happening but have been unable to figure it out. I'm using the latest version available in the Releases tab. Let me know if I can give you any more information that would help.

Suggestion for easier installing and updating instructions.

Use go get -u github.com/justjanne/powerline-go to install, then just point to the binary in $HOME/go/bin, eg:

function powerline_precmd() {
    PS1="$(~/go/bin/powerline-go -error $? -shell zsh)"
}

function install_powerline_precmd() {
  for s in "${precmd_functions[@]}"; do
    if [ "$s" = "powerline_precmd" ]; then
      return
    fi
  done
  precmd_functions+=(powerline_precmd)
}

if [ "$TERM" != "linux" ]; then
    install_powerline_precmd
fi

Then to update, just to do go get -u github.com/justjanne/powerline-go

Right prompt support

I like to put my git info on a right prompt (yey fish). I can do it with powerline-go -shell bare -mode flat -modules git, and that looks fine, but would it be possible to add a -prompt option that maybe points the segment separator this way < instead of this way >?

Path Aliases Not Working

Not sure if I'm doing it wrong or what 😕 I'm using the following arguments:

-cwd-max-depth 3 -modules user,cwd,git,exit -newline -path-aliases /workspace/core-products/Divi=Divi,/workspace/core-products/Divi/core=core@Divi,/workspace/core-products/Divi/epanel=epanel@Divi,/workspace/core-products/Divi/includes/builder=builder@Divi,/workspace/core-products/Extra=Extra,/workspace/core-products/Extra/core=core@Extra,/workspace/core-products/Extra/epanel=epanel@Extra,/workspace/core-products/Extra/includes/builder=builder@Extra,/workspace/core-products/divi-builder=DBP,/workspace/core-products/divi-builder/core=core@DBP,/workspace/core-products/divi-builder/includes/builder=builder@DBP,/workspace/wordpress/4.9.6=WordPress

Could you let me know if it looks okay?

When powerline exceeds terminal's width it will disappear

mkdir -p dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9/dir10
cd -p dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9/dir10
git init
git checkout -b very-long-branch-name-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

After executing these powerline disappears for me, I'm not sure if that's the case in original.

While this example is a little overkill, this also can happen in real use - when using terminator and splitting terminals into half.

I use Fish Shell 2.6.0 on Manjaro Linux

Adding windows support

Hi,

First of all, great work 👍

I was wandering if you would consider a PR or making a few modification to add windows support. Actually, it almost support compilation on windows right off the bat. The only thing preventing it is a unix syscall in segment-readonly.go.

	if unix.Access(cwd, unix.W_OK) != nil {
		p.appendSegment("perms", segment{
			content:    fmt.Sprintf(" %s ", p.symbolTemplates.Lock),
			foreground: p.theme.ReadonlyFg,
			background: p.theme.ReadonlyBg,
		})
	}

So I made the modification

	const W_USR = 0002
	// Check user's permissions on directory in a portable but probably slower way
	fileInfo, _ := os.Stat(cwd)
	if fileInfo.Mode()&W_USR != W_USR {
		p.appendSegment("perms", segment{
			content:    fmt.Sprintf(" %s ", p.symbolTemplates.Lock),
			foreground: p.theme.ReadonlyFg,
			background: p.theme.ReadonlyBg,
		})
	}

and it seems to work just fine (at least if you're using git-bash).

powerline_gitbash_windows

I made the change by adding a specific implementation for windows so I'm sure it doesn't break anything for Unix users. But it's not really necessary, what's your thought about that ?

It is not thoroughly tested but I don't mind testing some more and submit a PR ;-)

More details

Snap Package

Do you have any interest in getting your package built as a snap package? This is something I could likely assist with.

Extra symbols for Mercurial

Hi,

Is it possible to add extra symbols to the prompt for mercurial repos like you have enabled for git repos?

don't know what this flag means

Hi, nice tool, I use it on every machine!

I just saw something that I didn't know how to identify and I was wondering if you knew what it was. There is a small blue flag that appears when I am in one of my repos, and there is no reason for it that is apparent to me...

screen shot 2018-04-22 at 4 42 23 pm

I couldn't find any way to track down its meaning either, is there a centralized powerline standard anywhere that we could link to?

Collapse function partially functional

Version 1.8.1

The collapse now works but it seems to have issues and collapses out segments even when the terminal is wide enough to be able to handle them all. As soon as one segment collapses, additional segments are removed.

Also seems to have lost the exit code detection.

pw-go-collapse

Blank PS1 after exporting $PS1 or only displays ?'s

Hello, I tried to install powerline-go by using the instructions provided I downloaded the Release Binary, and also using go get. Then I placed the following two functions in my .bash_profile or .bashrc

function _update_ps1() {
  PS1="$($GOBIN/powerline-go -error $?)"
}

if [ "$TERM" != "linux" ]; then
  PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND"
fi

export PS1=$PROMPT_COMMAND

This shows a blank terminal with nothing displayed.

This is by just supplying
export PS1=$($GOBIN/powerline-go -newline -error $?) displays the following

Last login: Tue Aug 29 10:31:14 on ttys002
 user01  M1711AF4  ~  $ 
 $ 

What am I doing wrong?

Running
OSX with iTerm2 using Bash.

Permission denied - linux

Hey,

I wanted to see how well this prompt builder works, but the linux release versions just won't execute. Strangely saying Permission denied. File looks a good build though: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, with debug_info, not stripped, and file exec bits are set (-rwxr--r--) by me, still they won't work. Am I missing something?

cwd-mode dironly lead to hostname only

adding the dironly option thorugh changing my .bshrc entry to

function _update_ps1() {
         PS1="$(~/go/bin/powerline-go -cwd-mode dironly -error $?)"
    }
 
    if [ "$TERM" != "linux" ]; then
        PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND"
    fi

leads form this
bildschirmfoto von 2017-12-08 12-54-30

to this
bildschirmfoto von 2017-12-08 12-55-29

Am I getting the dironly mode wrong? Or did I wrote the parameter I a wrong way? Because I expected it the other way around; the hostname disappeared and only the dir displayed.

Would be nice if anyone could help me with this :).

Random crash

Hi

Every once in a while, the powerline-go process crashes at startup:

failed MSpanList_Insert 0x2b3000 0x1f8405c5e7e0 0x0 0x0
fatal error: MSpanList_Insert

runtime stack:
runtime.throw(0x1a8cb0, 0x10)
	/home/travis/.gimme/versions/go1.6.linux.amd64/src/runtime/panic.go:530 +0x90 fp=0x7fff5fbfee50 sp=0x7fff5fbfee38
runtime.(*mSpanList).insert(0x265fc8, 0x2b3000)
	/home/travis/.gimme/versions/go1.6.linux.amd64/src/runtime/mheap.go:933 +0x293 fp=0x7fff5fbfee80 sp=0x7fff5fbfee50
runtime.(*mheap).freeSpanLocked(0x2657c0, 0x2b3000, 0x100, 0x0)
	/home/travis/.gimme/versions/go1.6.linux.amd64/src/runtime/mheap.go:809 +0x4be fp=0x7fff5fbfeee8 sp=0x7fff5fbfee80
runtime.(*mheap).grow(0x2657c0, 0x8, 0x0)
	/home/travis/.gimme/versions/go1.6.linux.amd64/src/runtime/mheap.go:675 +0x2a0 fp=0x7fff5fbfef40 sp=0x7fff5fbfeee8
runtime.(*mheap).allocSpanLocked(0x2657c0, 0x1, 0x0)
	/home/travis/.gimme/versions/go1.6.linux.amd64/src/runtime/mheap.go:553 +0x4e3 fp=0x7fff5fbfef98 sp=0x7fff5fbfef40
runtime.(*mheap).alloc_m(0x2657c0, 0x1, 0x15, 0x0)
	/home/travis/.gimme/versions/go1.6.linux.amd64/src/runtime/mheap.go:437 +0x119 fp=0x7fff5fbfefc8 sp=0x7fff5fbfef98
runtime.(*mheap).alloc.func1()
	/home/travis/.gimme/versions/go1.6.linux.amd64/src/runtime/mheap.go:502 +0x41 fp=0x7fff5fbfeff8 sp=0x7fff5fbfefc8
runtime.systemstack(0x7fff5fbff018)
	/home/travis/.gimme/versions/go1.6.linux.amd64/src/runtime/asm_amd64.s:307 +0xab fp=0x7fff5fbff000 sp=0x7fff5fbfeff8
runtime.(*mheap).alloc(0x2657c0, 0x1, 0x10000000015, 0x1b8df)
	/home/travis/.gimme/versions/go1.6.linux.amd64/src/runtime/mheap.go:503 +0x63 fp=0x7fff5fbff048 sp=0x7fff5fbff000
runtime.(*mcentral).grow(0x2673c0, 0x0)
	/home/travis/.gimme/versions/go1.6.linux.amd64/src/runtime/mcentral.go:209 +0x93 fp=0x7fff5fbff0b0 sp=0x7fff5fbff048
runtime.(*mcentral).cacheSpan(0x2673c0, 0x262378)
	/home/travis/.gimme/versions/go1.6.linux.amd64/src/runtime/mcentral.go:89 +0x47d fp=0x7fff5fbff0f0 sp=0x7fff5fbff0b0
runtime.(*mcache).refill(0x2af000, 0x15, 0x7fff5fbff158)
	/home/travis/.gimme/versions/go1.6.linux.amd64/src/runtime/mcache.go:119 +0xcc fp=0x7fff5fbff128 sp=0x7fff5fbff0f0
runtime.mallocgc.func2()
	/home/travis/.gimme/versions/go1.6.linux.amd64/src/runtime/malloc.go:642 +0x2b fp=0x7fff5fbff148 sp=0x7fff5fbff128
runtime.systemstack(0x7fff5fbff1e8)
	/home/travis/.gimme/versions/go1.6.linux.amd64/src/runtime/asm_amd64.s:307 +0xab fp=0x7fff5fbff150 sp=0x7fff5fbff148
runtime.mallocgc(0x180, 0x185e00, 0x0, 0x800000000)
	/home/travis/.gimme/versions/go1.6.linux.amd64/src/runtime/malloc.go:643 +0x869 fp=0x7fff5fbff228 sp=0x7fff5fbff150
runtime.newobject(0x185e00, 0x262690)
	/home/travis/.gimme/versions/go1.6.linux.amd64/src/runtime/malloc.go:781 +0x42 fp=0x7fff5fbff250 sp=0x7fff5fbff228
runtime.malg(0x8000, 0x262900)
	/home/travis/.gimme/versions/go1.6.linux.amd64/src/runtime/proc.go:2634 +0x27 fp=0x7fff5fbff288 sp=0x7fff5fbff250
runtime.mpreinit(0x262c40)
	/home/travis/.gimme/versions/go1.6.linux.amd64/src/runtime/os1_darwin.go:140 +0x1f fp=0x7fff5fbff2a0 sp=0x7fff5fbff288
runtime.mcommoninit(0x262c40)
	/home/travis/.gimme/versions/go1.6.linux.amd64/src/runtime/proc.go:494 +0x105 fp=0x7fff5fbff2e8 sp=0x7fff5fbff2a0
runtime.schedinit()
	/home/travis/.gimme/versions/go1.6.linux.amd64/src/runtime/proc.go:434 +0x79 fp=0x7fff5fbff330 sp=0x7fff5fbff2e8
runtime.rt0_go(0x7fff5fbff360, 0x3, 0x7fff5fbff360, 0x0, 0x3, 0x7fff5fbff530, 0x7fff5fbff54d, 0x7fff5fbff560, 0x0, 0x7fff5fbff562, ...)
	/home/travis/.gimme/versions/go1.6.linux.amd64/src/runtime/asm_amd64.s:138 +0x132 fp=0x7fff5fbff338 sp=0x7fff5fbff330

It appears to be quite random, sorry for not being able to provide more reproduction conditions. I run it on macOS X (darwin-amd64) with -colorize-hostname option. Let me know if I can provide more information to help.

Modules disappeared after upgrading to version >1.7.0 on zsh with wsltty (1.8.0)

I'm running powerline-go in zsh, using wsltty 1.8.0 (mintty 2.8.0) on a Windows 10 WSL (Windows Subsystem for Linux)

When upgrading to any version >1.7.0, most modules disappear from the prompt line (git, venv, etc..)

My terminal width has not changed, but it seems like powerline-go doesn't consider it has enough space to draw all the modules.

With v1.7.0 everything seems to work just fine.

Packaging notice

Powerline-go has been packaged in Fedora and is available from Fedora 25 to the to-be-released Fedora 28.

Git seems to be broken for Fish shell on MacOS

I use fish as my main shell. After doing an update (with go get -u), the git integration seems to have stopped working. By that I mean it doesn't show up with the branch, changes etc., but powerline-go is running.

If I fire bash up instead, it is working.

I'm running fish 2.6.0, git 2.14.3 and latest pull of powerline-go (also tried 1.8.1).

Please let me know if I can give any more information.

Thanks

Esc+v not working in vi editor mode

I'm using vi mode as my editor mode in zsh.Pressing Esc+v opens vim editor in terminal.we can paste long commands and execute those commands after closing vim editor. Now that function is not working
with powerline-go.
Any suggestion, please.

Theme not applying on linux

I've modified the theme colors in my fork, and they apply fine on OSX. However, when I install on linux, they don't apply. I've learned that the colors in defaults.go are applied instead. Any reason why this could be? The $TERMs are the same, maybe I need to set some env var?

Not a huge problem, I just changed them in both places.

Thanks!

`-newline` repeats the `$` part twice?

This looks like an issue with my prompt, but when I added the -newline option, it repeats the $ on both lines:

image

PS1="$(~/bin/powerline-go -modules "time,cwd,perms,git,jobs,exit,root" -error $? -newline)"

Build error on i386 arch

When trying to build powerline-go on an i386 platform the following error occurs:

cd /builddir/build/BUILD/powerline-go-1.5.0
/usr/lib/golang/pkg/tool/linux_386/compile -o $WORK/_/builddir/build/BUILD/powerline-go-1.5.0.a -trimpath $WORK -shared -goversion go1.9beta2 -p main -complete -installsuffix shared -buildid 8bfc5e3a9a1fa903d42882c8c7a0a3679ddd0928 -D _/builddir/build/BUILD/powerline-go-1.5.0 -I $WORK -I /usr/share/gocode/pkg/linux_386_shared -pack ./defaults.go ./main.go ./powerline.go ./segment-cwd.go ./segment-docker.go ./segment-exitcode.go ./segment-git.go ./segment-hg.go ./segment-hostname.go ./segment-jobs.go ./segment-perlbrew.go ./segment-readonly.go ./segment-root.go ./segment-ssh.go ./segment-time.go ./segment-username.go ./segment-virtualenv.go ./themes.go
# _/builddir/build/BUILD/powerline-go-1.5.0
./powerline.go:92:16: constant 9223372036854775807 overflows int

The corresponding lines:

for shellActualLength > shellMaxLength {
minPriority := math.MaxInt64
minPrioritySegmentId := -1

It seems math.MaxInt64 overflow on 32Bit system?

Please add a module that will display a specified shell variable

This would be great to display user-specific statuses. For example, I work with multiple AWS accounts and set an AWS_ACCOUNT environment in my shell that I use to display which AWS keypair is active in the shell session so I can see in the prompt if I've got the production keypair active.

cwd-max-dir-size throws error

First off - thanks for the great prompt!

That said, I used -cwd-max-dir-size 3 and received this error:

panic: runtime error: slice bounds out of range

goroutine 1 [running]:
panic(0x55bf40, 0xc8200140e0)
	/home/travis/.gimme/versions/go1.6.linux.amd64/src/runtime/panic.go:464 +0x3e6
main.segmentCwd(0xc8200be000)
	/home/travis/gopath/src/github.com/justjanne/powerline-go/segment-cwd.go:121 +0xc5a
main.main()
	/home/travis/gopath/src/github.com/justjanne/powerline-go/main.go:125 +0x559  

funny character on ssh

Thank you for the project, works great. Had a question, any suggestions to get it working over SSH?

screenshot from 2018-02-18 16-52-18

I have tried to add local to the .ssh/config file, that didn't seem to help

Double prompt when using as root

When I use powerline-go as root use the prompt I'm getting looks like this
�_root@yose:/home/crdil\ 20:19:58  root  yose  home  crdil  SIGINT  # 

For some reason I get a double prompt when using powerline when sudoing or su, I've added powerline to roots bashrc and commented out the standard PS1 in /root/.bashrc plus in /etc/bash.bashrc but I still get a double prompt.

Am I doing something wrong or is this a bug?

Support Xresources for themes

Example .Xresources file:

! special
*.foreground:   #c5c8c6
*.background:   #1d1f21
*.cursorColor:  #c5c8c6

! black
*.color0:       #282a2e
*.color8:       #373b41

! red
*.color1:       #a54242
*.color9:       #cc6666

! green
*.color2:       #8c9440
*.color10:      #b5bd68

! yellow
*.color3:       #de935f
*.color11:      #f0c674

! blue
*.color4:       #5f819d
*.color12:      #81a2be

! magenta
*.color5:       #85678f
*.color13:      #b294bb

! cyan
*.color6:       #5e8d87
*.color14:      #8abeb7

! white
*.color7:       #707880
*.color15:      #c5c8c6

It'd be real nice if you could pass -theme xresources, and powerline-go would parse your xresources file and use those colors accordingly.

A note on xresources:

The colors 0-7 are the 'normal' colors. Colors 8-15 are their 'bright' counterparts, used for highlighting

Question: Bold Text

Is it supported?

I have implemented a personal colour scheme using the 0-15 colours. The program works really well, performance in TMUX is very quick.

I was wondering whether I could edit the segment *.go files to use bold text. Or do I have to make changes somewhere else?

Thanks!

Hostname Colour

Hi there - is there a way to set the hostname colour to a custom colour? I know I could take the source and mode and compile - but was just curious...

Displaying of command errors could probably use some tweaking

For some commands a non-zero exit isn't really indicative of an error. As an example, run git grep frobnitz in this repo. This returns a non-zero exit code because nothing was found, but showing this as an error had me quite confused for a bit.

I have no idea how to handle this. Maybe make it possible to ignore certain error codes via config?

Git Error

I'm getting an error on a part of the git information.
Instead of showing the branch name it display "error"
I can see the number of untracked files properly.

How to reproduce:

mkdir projectname
cd projectname
git init (-> right after this the prompt display error instead of the branch name)

Once I add a file and start to track and commit it the error is removed and the proper branch is displayed.

Any idea?

image

In the previous screen cap:

  • go-chat is a project wich is tracked and for wich the local branch is linked to a remote branch.
  • cloud-native-app is a porject a just started and was not yet tracked...

`-colorize-hostname` option not implemented?

Hi

The usage help and the README advertise a -colorize-hostname flag to "Colorize the hostname based on a hash of itself", but it doesn't seem to be actually implemented. Can you confirm? And if so, I suggest pulling this flag from the code to avoid confusing users.

Long directory name in path doesn't fully collapse

See attached, when in a directory that has a long path it appears that the prompt overwrites itself and drops the last directory to the leftmost position.

Fedora 26
GNOME Terminal
Bash
Installed via copr: eclipseo/powerline-go

.bashrc snip

# User specific aliases and functions

## Powerline-go
function _update_ps1() {
    PS1="$(/usr/bin/powerline-go -error $?)"
}

if [ "$TERM" != "linux" ]; then
    PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND"
fi

screenshot from 2017-10-12 08-49-12

Feature Request: Implement -version

Managing powerline-go on both Linux (built from source) and macOS (binary download) would be easier to maintain consistency with a '-version' flag to query against.

Powerline adds excess spaces in prompt with some characters in the prompt content

Hello,

The cause of the error that you add spaces in output for EastAsianAmbiguous characters.

I made a quick patch to correct the issue for Greek and Cyrillic characters.

May be I missed something but I don't understand why you add extra spaces in prompt output for EastAsianAmbiguous character.

====

--- a/powerline.go
+++ b/powerline.go
@@ -185,7 +186,10 @@ func (p *powerline) numEastAsianRunes(segmentContent *string) int {
 		switch width.LookupRune(r).Kind() {
 		case width.Neutral:
 		case width.EastAsianAmbiguous:
-			numEastAsianRunes += 1
+			if !(0x370 <= r && r <= 0x3ff || // Greek and Coptic
+				0x400 <= r && r <= 0x4ff) { // Cyrillic
+				numEastAsianRunes += 1
+			}
 		case width.EastAsianWide:
 		case width.EastAsianNarrow:
 		case width.EastAsianFullwidth:

Color for the right-most separator is off

The color for the right-most separator is slightly brighter than the background color of the segment preceding it (see yellow boxes in the screenshot; the screenshot uses the low contrast theme, but the situation is the same in the default theme):

screenshot

I tried to tweak the conditional separatorBackground in powerline.drawRow(), but unfortunately didn't quite manage to achieve the desired result (i.e., the right-most separator having the same color as the previous segment's background color).

@justjanne: Thank you for this great utility. And your readme is super nice and easy to follow too.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.