Merge pull request #114 from glvr182/feature/add-repo-name

Feature: Added repository name to status
This commit is contained in:
Jesse Duffield 2018-08-11 09:51:11 +10:00 committed by GitHub
commit 9fbc332c9a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View file

@ -32,7 +32,8 @@ func refreshStatus(g *gocui.Gui) error {
}
branch := branches[0]
name := coloredString(branch.Name, branch.getColor())
fmt.Fprint(v, " "+name)
repo := getCurrentProject()
fmt.Fprint(v, " "+repo+" → "+name)
return nil
})

View file

@ -2,6 +2,9 @@ package main
import (
"fmt"
"log"
"os"
"path/filepath"
"strings"
"github.com/fatih/color"
@ -40,3 +43,12 @@ func coloredString(str string, colorAttribute color.Attribute) string {
func coloredStringDirect(str string, colour *color.Color) string {
return colour.SprintFunc()(fmt.Sprint(str))
}
// used to get the project name
func getCurrentProject() string {
pwd, err := os.Getwd()
if err != nil {
log.Fatalln(err.Error())
}
return filepath.Base(pwd)
}