mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-03-05 20:49:04 -08:00
parent
35823e5b78
commit
5493ddb640
|
@ -1,6 +1,9 @@
|
|||
package template
|
||||
|
||||
import "path/filepath"
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
func glob(pattern string) (bool, error) {
|
||||
matches, err := filepath.Glob(pattern)
|
||||
|
@ -9,3 +12,8 @@ func glob(pattern string) (bool, error) {
|
|||
}
|
||||
return len(matches) > 0, nil
|
||||
}
|
||||
|
||||
func readFile(path string) string {
|
||||
content, _ := os.ReadFile(path)
|
||||
return string(content)
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ func funcMap() template.FuncMap {
|
|||
"reason": GetReasonFromStatus,
|
||||
"hresult": hresult,
|
||||
"trunc": trunc,
|
||||
"readFile": readFile,
|
||||
}
|
||||
for key, fun := range sprig.TxtFuncMap() {
|
||||
if _, ok := funcMap[key]; !ok {
|
||||
|
|
|
@ -169,6 +169,7 @@ use them.
|
|||
| `{{ if matchP "*.Repo" .Path }}Repo{{ else }}No Repo{{ end }}` | Exposes [regexp.MatchString][regexpms] as a boolean template function. |
|
||||
| `{{ replaceP "c.t" "cut code cat" "dog" }}` | Exposes [regexp.ReplaceAllString][regexpra] as a string template function. |
|
||||
| <code>\{\{ .Code | hresult \}\}</code> | Transform a status code to its HRESULT value for easy troubleshooting. For example `-1978335212` becomes `0x8A150014`. |
|
||||
| `{{ readFile ".version.json" }}` | Read a file in the current directory. Returns a string. |
|
||||
|
||||
<!-- markdownlint-enable MD013 -->
|
||||
|
||||
|
|
Loading…
Reference in a new issue