diff options
| -rw-r--r-- | LICENSE | 19 | ||||
| -rw-r--r-- | README.md | 18 | ||||
| -rwxr-xr-x | nufetch.nu | 54 |
3 files changed, 91 insertions, 0 deletions
@@ -0,0 +1,19 @@ +Copyright (c) 2024 seth + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..8698502 --- /dev/null +++ b/README.md @@ -0,0 +1,18 @@ +# nufetch + +[neofetch](https://github.com/dylanaraps/neofetch) or [pfetch](https://github.com/dylanaraps/pfetch), but in [nu](https://www.nushell.sh/)! + +## Usage + +Assuming you have `nu` [installed](https://www.nushell.sh/book/installation.html): + +``` +git clone https://github.com/getchoo/nufetch +cd nufetch +./nufetch.nu +``` + +## TODO + +- [ ] Support package counts +- [ ] Maybe support the ASCII art... diff --git a/nufetch.nu b/nufetch.nu new file mode 100755 index 0000000..67770a6 --- /dev/null +++ b/nufetch.nu @@ -0,0 +1,54 @@ +#!/usr/bin/env nu + +let sys = (sys) + +let field_color = (ansi blue_bold) +let reset = (ansi reset) + +def make_field [name: string, value: string] { + $"($field_color)($name)($reset): ($value)" +} + +def user_signature [] { + let user = (whoami) + let hostname = ($sys | get host.hostname) + $"($user)@($hostname)" +} + +def os_info [] { + let host = ($sys | get host) + let info = $"($host.name) \(($host.os_version))" + make_field "os" $info +} + +def host_info [] { + let machine = (uname | get machine) + make_field "host" $machine +} + +def kernel_info [] { + let kernel_version = ($sys | get host.kernel_version) + make_field "kernel" $kernel_version +} + +def uptime_info [] { + let uptime = ($sys | get host.uptime | into string) + make_field "uptime" $uptime +} + +def mem_info [] { + let mem = ($sys | get mem) + make_field "memory" $"($mem.available) / ($mem.total)" +} + +let fields = [ + (user_signature), + (os_info), + (host_info), + (kernel_info), + (uptime_info), + (mem_info) +] + +$fields | reduce {|it| ($it | into string) ++ "\n"} +$fields | to text |
