-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathknown_paths.go
More file actions
37 lines (34 loc) · 798 Bytes
/
known_paths.go
File metadata and controls
37 lines (34 loc) · 798 Bytes
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
29
30
31
32
33
34
35
36
37
package common
import (
"github.com/mitchellh/go-homedir"
)
var knownPaths = []string{
// global
"/etc/profile",
"/etc/environment",
"/etc/zprofile",
"/etc/zlogin",
"/etc/zshenv",
// generic
"~/.profile",
"~/.pam_environment",
// zsh: https://zsh.sourceforge.io/Doc/Release/Files.html#Startup_002fShutdown-Files
"~/.zshenv",
"~/.zprofile",
"~/.zshrc",
"~/.zlogin",
// bash: https://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html
"~/.bashrc",
"~/.bash_profile",
"~/.bash_login",
}
// ForEachKnownPath iterates over expanded known paths if they're legitimate
func ForEachKnownPath(fn func(string, string)) {
for _, knownPath := range knownPaths {
expanded, err := homedir.Expand(knownPath)
if err != nil {
continue
}
fn(knownPath, expanded)
}
}