mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-12 03:29:10 +02:00
Refactor the CLI markup code to make it re-useable
This commit is contained in:
24
tools/utils/hostname.go
Normal file
24
tools/utils/hostname.go
Normal file
@@ -0,0 +1,24 @@
|
||||
// License: GPLv3 Copyright: 2022, Kovid Goyal, <kovid at kovidgoyal.net>
|
||||
|
||||
package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
var _ = fmt.Print
|
||||
|
||||
var hostname string = "*"
|
||||
|
||||
func CachedHostname() string {
|
||||
if hostname == "*" {
|
||||
h, err := os.Hostname()
|
||||
if err != nil {
|
||||
hostname = h
|
||||
} else {
|
||||
hostname = ""
|
||||
}
|
||||
}
|
||||
return hostname
|
||||
}
|
||||
Reference in New Issue
Block a user