Skip to content

gnuvalerie/nitchrevived

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

NiTch

incredibly fast system fetch written in nim๐Ÿ‘‘, NiTch Revived is project supposed to continue the NiTch after it become not maintained.


Maintenance Commits

Description ๐Ÿ“–

nitchrevived 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 nitchrevived 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


Installation โ˜๏ธ

wget -O - https://git.teto.party/pkgs/nitchrevived/raw/branch/main/install.sh | sh

Usage ๐Ÿชจ

nitchrevived

flags:

 -f --fetch   | return fetch about system
 -h --help    | return help message
 -v --version | return version of program
 -l --logo    | return fetch with specified distro logo

Configuration โš™๏ธ

nitch is configured by changing the source code

src/funcs/drawing.nim - config file

import
  std/terminal,     # import standard terminal lib
  std/strutils,
  getDistroId,      # import to get distro id through /etc/os-release
  ../assets/logos,  # uncomment if you use your own logo
  ../nitches/[getUser, getHostname,
                  getDistro, getKernel,
                  getUptime, getShell,
                  getPkgs, getRam, getLogo]  # import nitches to get info about user system

# the main function for drawing fetch
proc drawInfo*(asciiArt: bool, distro: string) =
  let  # distro id (arch, manjaro, debian)
    distroId = if distro.len > 0: distro else: getDistroId()

  let  # logo and it color
    coloredLogo = getLogo(distroId)  # color + logo tuple
    # (fgRed, nitchLogo)

  const  # icons before cotegores
    userIcon   = "๏€‡ "  # recomended: "๏€‡ " or "|>"
    hnameIcon  = "๎œ” "  # recomended: "๎œ” " or "|>"
    distroIcon = "๓ฐป€ "  # recomended: "๓ฐป€ " or "|>"
    kernelIcon = "๓ฐŒข "  # recomended: "๓ฐŒข " or "|>"
    uptimeIcon = "๏€— "  # recomended: "๏€— " or "|>"
    shellIcon  = "๏’‰ "  # recomended: "๏’‰ " or "|>"
    pkgsIcon   = "๓ฐ– "  # recomended: "๓ฐ– " or "|>"
    ramIcon    = "๓ฐ› "  # recomended: "๓ฐ› " or "|>"
    colorsIcon = "๓ฐ˜ "  # recomended: "๓ฐ˜ " or "->"
    # please insert any char after the icon
    # to avoid the bug with cropping the edge of the icon

    dotIcon = "๏‘„"  # recomended: "๏‘„" or "โ– "
    # icon for demonstrate colors

  const  # categories
    userCat   = " user   โ”‚ "  # recomended: " user   โ”‚ "
    hnameCat  = " hname  โ”‚ "  # recomended: " hname  โ”‚ "
    distroCat = " distro โ”‚ "  # recomended: " distro โ”‚ "
    kernelCat = " kernel โ”‚ "  # recomended: " kernel โ”‚ "-
    uptimeCat = " uptime โ”‚ "  # recomended: " uptime โ”‚ "
    shellCat  = " shell  โ”‚ "  # recomended: " shell  โ”‚ "
    pkgsCat   = " pkgs   โ”‚ "  # recomended: " pkgs   โ”‚ "
    ramCat    = " memory โ”‚ "  # recomended: " memory โ”‚ "
    colorsCat = " colors โ”‚ "  # recomended: " colors โ”‚ "

  let  # all info about system
    userInfo     = getUser()          # get user through $USER env variable
    hostnameInfo = getHostname()      # get Hostname hostname through /etc/hostname
    distroInfo   = getDistro()        # get distro through /etc/os-release
    kernelInfo   = getKernel()        # get kernel through /proc/version
    uptimeInfo   = getUptime()        # get Uptime through /proc/uptime file
    shellInfo    = getShell()         # get shell through $SHELL env variable
    pkgsInfo     = getPkgs(distroId)  # get amount of packages in distro
    ramInfo      = getRam()           # get ram through /proc/meminfo

  const  # aliases for colors
    color1 = fgRed
    color2 = fgYellow
    color3 = fgGreen
    color4 = fgCyan
    color5 = fgBlue
    color6 = fgMagenta
    color7 = fgWhite
    color8 = fgBlack
    color0 = fgDefault

  # ascii art
  if not asciiArt:
    discard
  else:
    stdout.styledWrite(styleBright, coloredLogo[0], coloredLogo[1], color0)

  # colored out
  stdout.styledWrite("\n", styleBright, "  โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ\n")
  stdout.styledWrite("  โ”‚ ", color2, userIcon, color0, userCat, color1, userInfo, color0, "\n",)
  if not isEmptyOrWhitespace(hostnameInfo):
    stdout.styledWrite("  โ”‚ ", color2, hnameIcon, color0, hnameCat, color2, hostnameInfo, color0, "\n")
    stdout.styledWrite("  โ”‚ ", color3, distroIcon, color0, distroCat, color3, distroInfo, color0, "\n")
    stdout.styledWrite("  โ”‚ ", color4, kernelIcon, color0, kernelCat, color4, kernelInfo, color0, "\n")
    stdout.styledWrite("  โ”‚ ", color5, uptimeIcon, color0, uptimeCat, color5, uptimeInfo, color0, "\n")
    stdout.styledWrite("  โ”‚ ", color6, shellIcon, color0, shellCat, color6, shellInfo, color0, "\n")
    stdout.styledWrite("  โ”‚ ", color1, pkgsIcon, color0, pkgsCat, color1, pkgsInfo, color0, "\n")
    stdout.styledWrite("  โ”‚ ", color2, ramIcon, color0, ramCat, fgYellow, ramInfo, color0, "\n")
    stdout.styledWrite("  โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค\n")
    stdout.styledWrite("  โ”‚ ", color7, colorsIcon, color0, colorsCat, color7, dotIcon, " ", color1, dotIcon, " ", color2, dotIcon, " ", color3, dotIcon, " ", color4, dotIcon, " ", color5, dotIcon, " ", color6, dotIcon, " ", color8, dotIcon, color0, "\n")
    stdout.styledWrite("  โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ\n\n")

Building ๐Ÿ“ฆ

0) install nim

1) clone repo

git clone https://git.teto.party/pkgs/nitchrevived

2) change dir to nitch

cd nitchrevived/

3) build program with nimble

nimble build

After that you will get a ready-made binary file in the root directory of the project.


File architecture ๐Ÿ“

nitchrevived
โ”œโ”€โ”€ LICENSE
โ”œโ”€โ”€ nitchrevived
โ”œโ”€โ”€ nitchrevived.nimble
โ”œโ”€โ”€ README.md
โ””โ”€โ”€ src
    โ”œโ”€โ”€ assets
    โ”‚   โ”œโ”€โ”€ assets.nim
    โ”‚   โ””โ”€โ”€ logos.nim
    โ”œโ”€โ”€ flags
    โ”‚   โ””โ”€โ”€ argParser.nim
    โ”œโ”€โ”€ funcs
    โ”‚   โ”œโ”€โ”€ drawing.nim
    โ”‚   โ”œโ”€โ”€ packages
    โ”‚   โ”‚   โ”œโ”€โ”€ getPacmanPkgs.nim
    โ”‚   โ”‚   โ”œโ”€โ”€ getDpkgPkgs.nim
    โ”‚   โ”‚   โ”œโ”€โ”€ getRpmPkgs.nim
    โ”‚   โ”‚   โ”œโ”€โ”€ getXbpsPkgs.nim
    โ”‚   โ”‚   โ””โ”€โ”€ getPortagePkgs.nim
    โ”‚   โ””โ”€โ”€ perform.nim
    โ”œโ”€โ”€ nitches
    โ”‚   โ”œโ”€โ”€ getDistro.nim
    โ”‚   โ”œโ”€โ”€ getHostname.nim
    โ”‚   โ”œโ”€โ”€ getKernel.nim
    โ”‚   โ”œโ”€โ”€ getPkgs.nim
    โ”‚   โ”œโ”€โ”€ getRam.nim
    โ”‚   โ”œโ”€โ”€ getShell.nim
    โ”‚   โ”œโ”€โ”€ getUptime.nim
    โ”‚   โ””โ”€โ”€ getUser.nim
    โ”œโ”€โ”€ nitchrevived.nim
    โ””โ”€โ”€ nitchrevived.nim.cfg

7 directories, 25 files

Thanks for ideas & examples ๐Ÿ’ฌ