Giter VIP home page Giter VIP logo

powerline-go's Issues

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

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 >?

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

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

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?

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:

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?

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.

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...

Snap Package

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

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!

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.

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.

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  

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?

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.

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

Packaging notice

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

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

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.

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!

`-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)"

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?

`-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.

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?

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

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?

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?

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...

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 :).

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.

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

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

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?

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.

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.