forked from justjanne/powerline-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added segment for rbenv to display the current ruby version
- Loading branch information
1 parent
59fef95
commit 50075d9
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package main | ||
|
||
import ( | ||
pwl "github.com/justjanne/powerline-go/powerline" | ||
"os/exec" | ||
"strings" | ||
) | ||
|
||
func runRbenvCommand(cmd string, args ...string) (string, error) { | ||
command := exec.Command(cmd, args...) | ||
out, err := command.Output() | ||
return string(out), err | ||
} | ||
|
||
func segmentRbenv(p *powerline) []pwl.Segment { | ||
out, err := runRbenvCommand("rbenv", "version") | ||
|
||
if err == nil { | ||
items := strings.Split(out, " ") | ||
if len(items) > 1 { | ||
return []pwl.Segment{{ | ||
Name: "rbenv", | ||
Content: items[0], | ||
Foreground: p.theme.TimeFg, | ||
Background: p.theme.TimeBg, | ||
}} | ||
} | ||
} | ||
|
||
return []pwl.Segment{} | ||
} |