chore: add shell
704b26d5
2 file(s) · +21 −1
| 8 | 8 | "strings" |
|
| 9 | 9 | "syscall" |
|
| 10 | 10 | "time" |
|
| 11 | + | "path/filepath" |
|
| 12 | + | "errors" |
|
| 11 | 13 | ) |
|
| 12 | 14 | ||
| 13 | 15 | func GetHostname() (string, error) { |
|
| 83 | 85 | } |
|
| 84 | 86 | ||
| 85 | 87 | return count, nil |
|
| 88 | + | } |
|
| 89 | + | ||
| 90 | + | func GetShell() (string, error) { |
|
| 91 | + | shellEnv := os.Getenv("SHELL") |
|
| 92 | + | if shellEnv == "" { |
|
| 93 | + | return "", errors.New("Could not fetch shell") |
|
| 94 | + | } |
|
| 95 | + | ||
| 96 | + | shell := filepath.Base(shellEnv) |
|
| 97 | + | ||
| 98 | + | return shell, nil |
|
| 86 | 99 | } |
|
| 87 | 100 | ||
| 88 | 101 | func GetMemory() (string, error) { |
|
| 14 | 14 | // Machine - Done |
|
| 15 | 15 | // Kernel - Done |
|
| 16 | 16 | // Distro - Done |
|
| 17 | - | // Packages - /lib/apk/db/installed count P: |
|
| 17 | + | // Packages - Done |
|
| 18 | 18 | // Shell - env |
|
| 19 | 19 | // Terminal? |
|
| 20 | 20 | // Uptime - Done |
|
| 61 | 61 | os.Exit(1) |
|
| 62 | 62 | } |
|
| 63 | 63 | fmt.Println("Packages: ", packages, "(apk)") |
|
| 64 | + | ||
| 65 | + | shell, err := internal.GetShell() |
|
| 66 | + | if err != nil { |
|
| 67 | + | fmt.Println("error:", err) |
|
| 68 | + | os.Exit(1) |
|
| 69 | + | } |
|
| 70 | + | fmt.Println("Shell: ", shell) |
|
| 64 | 71 | ||
| 65 | 72 | memory, err := internal.GetMemory() |
|
| 66 | 73 | if err != nil { |
|