summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorseth <[email protected]>2024-05-26 07:05:30 -0400
committerseth <[email protected]>2024-05-26 07:05:30 -0400
commit59bee3d639caa5a831ce20f9e663671a49f3d1fd (patch)
treef8196cca9480e9790ef72890dc978bbeb593b1b2
initial commit
-rw-r--r--LICENSE19
-rw-r--r--README.md18
-rwxr-xr-xnufetch.nu54
3 files changed, 91 insertions, 0 deletions
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..b3b1528
--- /dev/null
+++ b/LICENSE
@@ -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