├── .github └── workflows │ └── build.yml ├── .gitignore ├── LICENSE ├── README.md ├── go.mod ├── go.sum └── main.go /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Go 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | pull_request: 7 | branches: [ main ] 8 | 9 | jobs: 10 | build: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v2 14 | 15 | - name: Set up Go 16 | uses: actions/setup-go@v2 17 | with: 18 | go-version: 1.17 19 | 20 | - name: Build 21 | run: go build -v ./... 22 | 23 | - name: Upload 24 | uses: actions/upload-artifact@v2 25 | with: 26 | name: catfetch 27 | path: | 28 | catfetch 29 | README.md 30 | LICENSE -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | catfetch 2 | 3 | !catfetch/ 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2021 Domterion 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 |

🐱 Catfetch

3 | Catfetch is a small and cute fetch program written in Go. Linux only (developed on Arch BTW) 4 |
5 |
6 | 7 |
8 | 9 | # Installation 10 | 11 | Download a prebuilt binary from the releases or actions 12 | 13 | or 14 | 15 | DIY 16 | 17 | ```sh 18 | git clone https://github.com/Domterion/catfetch 19 | cd ./catfetch/ 20 | go get -d ./... 21 | go build -ldflags "-w -s" 22 | sudo install -m755 ./catfetch /usr/bin/catfetch 23 | cd ../ 24 | rm -rf ./catfetch/ 25 | catfetch 26 | ``` 27 | 28 | # License 29 | MIT 30 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/domterion/catfetch 2 | 3 | go 1.18 4 | 5 | require github.com/joho/godotenv v1.4.0 6 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/joho/godotenv v1.4.0 h1:3l4+N6zfMWnkbPEXKng2o2/MR5mSwTrBih4ZEkkz1lg= 2 | github.com/joho/godotenv v1.4.0/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= 3 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "os/user" 7 | "strings" 8 | 9 | "github.com/joho/godotenv" 10 | ) 11 | 12 | const red = "\033[0;31m" 13 | const yellow = "\033[0;33m" 14 | const green = "\033[0;32m" 15 | const blue = "\033[0;34m" 16 | const gray = "\033[0;90m" 17 | const purple = "\033[0;35m" 18 | const cyan = "\033[0;36m" 19 | const boldRed = "\033[1;31m" 20 | const boldYellow = "\033[1;33m" 21 | const boldBlue = "\033[1;34m" 22 | const boldGreen = "\033[1;32m" 23 | const boldPurple = "\033[1;35m" 24 | const boldWhite = "\033[1;37m" 25 | const reset = "\033[0m" 26 | 27 | // We cant escape backticks in Go.. 28 | const cat = `. . 29 | \` + "`" + `-"'"-'/ %s 30 | } 6 6 { %s 31 | =. Y ,= %s 32 | /^^^\ . %s 33 | / \ ) %s 34 | (..)-(..)/ 35 | ` 36 | 37 | func main() { 38 | godotenv.Load("/etc/os-release") 39 | 40 | username := getCurrentUsername() 41 | hostname := getHostname() 42 | 43 | formattedHostName := fmt.Sprintf("%s%s%s@%s%s%s", boldWhite, username, reset, boldWhite, hostname, reset) 44 | 45 | operatingSystem := getOperatingSystem() 46 | formattedOperatingSystem := fmt.Sprintf("%sos %s%s", red, reset, strings.ToLower(operatingSystem)) 47 | 48 | kernelVersion := getKernelVersion() 49 | formattedKernelVersion := fmt.Sprintf("%skernel %s%s", green, reset, kernelVersion) 50 | 51 | shell := os.Getenv("SHELL") 52 | formattedShell := fmt.Sprintf("%sshell %s%s", blue, reset, shell) 53 | 54 | formattedColors := fmt.Sprintf("%s███%s███%s███%s███%s███%s███ %s", red, green, yellow, blue, purple, cyan, reset) 55 | 56 | fmt.Printf(cat, formattedHostName, formattedOperatingSystem, formattedKernelVersion, formattedShell, formattedColors) 57 | } 58 | 59 | func getCurrentUsername() string { 60 | username, err := user.Current() 61 | 62 | if err != nil { 63 | return "unknown" 64 | } 65 | 66 | return username.Username 67 | } 68 | 69 | func getHostname() string { 70 | hostname, err := os.Hostname() 71 | 72 | if err != nil { 73 | return "unknown" 74 | } 75 | 76 | return hostname 77 | } 78 | 79 | func getOperatingSystem() string { 80 | return os.Getenv("NAME") 81 | } 82 | 83 | func getKernelVersion() string { 84 | file, err := os.ReadFile("/proc/version") 85 | 86 | if err != nil { 87 | return "unknown" 88 | } 89 | 90 | contents := string(file) 91 | 92 | return strings.Split(contents, " ")[2] 93 | } 94 | --------------------------------------------------------------------------------