File: segment-direnv.go

package info (click to toggle)
powerline-go 1.25-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 612 kB
  • sloc: sh: 30; makefile: 4
file content (28 lines) | stat: -rw-r--r-- 512 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package main

import (
	"os"
	"path/filepath"
	"strings"

	pwl "github.com/justjanne/powerline-go/powerline"
)

func segmentDirenv(p *powerline) []pwl.Segment {
	content := os.Getenv("DIRENV_DIR")
	if content == "" {
		return []pwl.Segment{}
	}
	if strings.TrimPrefix(content, "-") == p.userInfo.HomeDir {
		content = "~"
	} else {
		content = filepath.Base(content)
	}

	return []pwl.Segment{{
		Name:       "direnv",
		Content:    content,
		Foreground: p.theme.DotEnvFg,
		Background: p.theme.DotEnvBg,
	}}
}