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

Added hostname segment and isGitDir #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

baol
Copy link

@baol baol commented Oct 27, 2016

  • Implemented a simple hostname segment
  • isGitDir will avoid spawning a process when not in a git dir

@@ -21,7 +21,7 @@ import (
"fmt"
"os"

"github.com/otann/powerline-go/powerline"
"github.com/baol/powerline-go/powerline"
Copy link
Owner

Choose a reason for hiding this comment

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

Well, I understand the purpose behind, but it doesn't makes sense in this fork ;)

Copy link
Author

Choose a reason for hiding this comment

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

Sorry, went in by mistake!

func HostSegment(t Theme) Segment {
hn, _ := os.Hostname()
return Segment{
Bg: t.Lock.Bg,
Copy link
Owner

Choose a reason for hiding this comment

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

Should there be additional config for home segment colors as well?

@@ -124,7 +146,11 @@ func getGitInformation() (string, bool) {
return status, staged
}

func GitSegment(t Theme) Segment {
func GitSegment(cwdParts []string, t Theme) Segment {
if !isGitDir(cwdParts) {
Copy link
Owner

Choose a reason for hiding this comment

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

I think this should be done in getGitInformation, also isn't there a way to check same thing without constructing a path from it's parts?

Copy link
Author

Choose a reason for hiding this comment

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

Maybe, maybe not. getGitInformation at the moment gets information from git, isGitDir is a pre-filter. cwdParts was the closest information to what was needed that is already available to other segments.

@Otann
Copy link
Owner

Otann commented Oct 30, 2016

Thanks a lot for this segment! This will be of much use, when reading configuration from file will be added

@baol
Copy link
Author

baol commented Oct 31, 2016

How would you handle reading from config without reading the config every time? Env variables maybe?

@Otann
Copy link
Owner

Otann commented Oct 31, 2016

I think both, readingsimple json from file should be really quick

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants