nitch
is a small and incredibly fast system fetch written fully in nim๐
without any dependencies, on my pc
it executes in around 1.70 miliseconds.
The source code of nitch
is highly documented and I hope it will act as a learning resource for nim
and linux systems architecture
If anything in the source code is unclear or is lacking in its explanation, open an issue. Sometimes you get too close to something and you fail to see the "bigger picture"!
btw written in nim๐
why nim๐
? because it's fast and simple
wget https://raw.githubusercontent.com/unxsh/nitch/main/setup.sh && sh setup.sh
nitch
flags:
-f --fetch | return fetch about system
-h --help | return help message
-v --version | return version of program
import std/terminal # import standard terminal lib
import getDistroId # import to get distro id through /etc/os-release
#import ../assets/logos # uncomment if you use your own logo
import ../nitches/[getUser, getHostname,
getDistro, getKernel,
getUptime, getShell,
getPkgs, getRam,
getLogo, getLogoColor] # import nitches to get info about user system
# the main function for drawing fetch
proc drawInfo*() =
let # distro id (arch, manjaro, debian)
distroId: string = getDistroId()
let # logo and it color
logoColor: ForegroundColor = getLogoColor(distroId) # color for logo
defaultLogo: string = getLogo(distroId) # default logo from nitch/src/assets/logos
const # icons before cotegores
userIcon: string = "๏ " # recomended: "๏ " or "|>"
hnameIcon: string = "๎ " # recomended: "๎ " or "|>"
distroIcon: string = "๏ ผ " # recomended: "๏ ผ " or "|>"
kernelIcon: string = "๏ ค " # recomended: "๏ ค " or "|>"
uptimeIcon: string = "๏ " # recomended: "๏ " or "|>"
shellIcon: string = "๏ " # recomended: "๏ " or "|>"
pkgsIcon: string = "๏ฃ " # recomended: "๏ฃ " or "|>"
ramIcon: string = "๏ก " # recomended: "๏ก " or "|>"
colorsIcon: string = "๏ฃ " # recomended: "๏ฃ " or "->"
# please insert any char after the icon
# to avoid the bug with cropping the edge of the icon
dotIcon: string = "๏" # recomended: "๏" or "โ "
# icon for demonstrate colors
const # categories
userCat: string = " user โ " # recomended: " user โ "
hnameCat: string = " hname โ " # recomended: " hname โ "
distroCat: string = " distro โ " # recomended: " distro โ "
kernelCat: string = " kernel โ " # recomended: " kernel โ "-
uptimeCat: string = " uptime โ " # recomended: " uptime โ "
shellCat: string = " shell โ " # recomended: " shell โ "
pkgsCat: string = " pkgs โ " # recomended: " pkgs โ "
ramCat: string = " memory โ " # recomended: " memory โ "
colorsCat: string = " colors โ " # recomended: " colors โ "
let # all info about system
userInfo: string = getUser() # get user through $USER env variable
hostnameInfo: string = getHostname() # get Hostname hostname through /etc/hostname
distroInfo: string = getDistro() # get distro through /etc/os-release
kernelInfo: string = getKernel() # get kernel through /proc/version
uptimeInfo: string = getUptime() # get Uptime through /proc/uptime file
shellInfo: string = getShell() # get shell through $SHELL env variable
pkgsInfo: string = getPkgs(distroId) # get amount of packages in distro
ramInfo: string = getRam() # get ram through /proc/meminfo
const # aliases for colors
color1: ForegroundColor = fgRed
color2: ForegroundColor = fgYellow
color3: ForegroundColor = fgGreen
color4: ForegroundColor = fgCyan
color5: ForegroundColor = fgBlue
color6: ForegroundColor = fgMagenta
color7: ForegroundColor = fgWhite
color8: ForegroundColor = fgBlack
color0: ForegroundColor = fgDefault
# colored out
stdout.styledWrite(styleBright, logoColor, defaultLogo)
stdout.styledWrite(styleBright, " โญโโโโโโโโโโโโฎ\n")
stdout.styledWrite(styleBright, " โ ", color1, userIcon, color0, userCat, color1, userInfo, "\n")
stdout.styledWrite(styleBright, " โ ", color2, hnameIcon, color0, hnameCat, color2, hostnameInfo, "\n")
stdout.styledWrite(styleBright, " โ ", color3, distroIcon, color0, distroCat, color3, distroInfo, "\n")
stdout.styledWrite(styleBright, " โ ", color4, kernelIcon, color0, kernelCat, color4, kernelInfo, "\n")
stdout.styledWrite(styleBright, " โ ", color5, uptimeIcon, color0, uptimeCat, color5, uptimeInfo, "\n")
stdout.styledWrite(styleBright, " โ ", color6, shellIcon, color0, shellCat, color6, shellInfo, "\n")
stdout.styledWrite(styleBright, " โ ", color1, pkgsIcon, color0, pkgsCat, color1, pkgsInfo, "\n")
stdout.styledWrite(styleBright, " โ ", color2, ramIcon, color0, ramCat, fgYellow, ramInfo, "\n")
stdout.styledWrite(styleBright, " โโโโโโโโโโโโโค\n")
stdout.styledWrite(styleBright, " โ ", color7, colorsIcon, color0, colorsCat, color7, dotIcon, " ", color1, dotIcon, " ", color2, dotIcon, " ", color3, dotIcon, " ", color4, dotIcon, " ", color5, dotIcon, " ", color6, dotIcon, " ", color8, dotIcon, "\n")
stdout.styledWrite(styleBright, " โฐโโโโโโโโโโโโฏ\n\n")
0) install nim
git clone https://github.com/unxsh/nitch.git
cd nitch/
nimble build
After that you will get a ready-made binary file in the root directory of the project.
nitch
โโโ LICENSE
โโโ nitch
โโโ nitch.nimble
โโโ README.md
โโโ src
โ โโโ assets
โ โ โโโ assets.nim
โ โ โโโ logos.nim
โ โโโ flags
โ โ โโโ argParser.nim
โ โโโ funcs
โ โ โโโ drawing.nim
โ โ โโโ packages
โ โ โ โโโ getPacmanPkgs.nim
โ โ โโโ perform.nim
โ โโโ nitches
โ โ โโโ getDistro.nim
โ โ โโโ getHostname.nim
โ โ โโโ getKernel.nim
โ โ โโโ getPkgs.nim
โ โ โโโ getRam.nim
โ โ โโโ getShell.nim
โ โ โโโ getUptime.nim
โ โ โโโ getUser.nim
โ โโโ nitch.nim
โ โโโ nitch.nim.cfg
โโโ templates
โโโ cfgParser
โโโ cfgParser.nim
โโโ data.dat
โโโ listFiles.nim
โโโ readLine.nim
โโโ refTest.nim
โโโ shellCheck.nim
โโโ test.cfg
โโโ testFile
โโโ testProc.nim
7 directories, 30 files