# ---- requiments ----
#
#      nano
#      firefox
#      your computer
#      zsh

# ============================================================
#  alueNX+ 3.0.0
#  © duff_ai (2026) - All rights reserved.
# ============================================================

# ---------- Logo ----------
cat <<'LOGO_END'

███           █
█  ███    ██  █
     ██    █
    █      █
    █████
 (alueNX+ v.3.0.0)

© duff_ai (2026) - All rights reseved.
Type "help" for a list of commands.

LOGO_END

# ---------- Prompt ----------
PS1='\w @ ' # i think in zsh is $PATH, i dont know... but this is copyright also: you cant change it!

# ---------- help ----------
help() {
cat <<'HELP_END'
alueNX+ 3.0.0 - command reference:
  help                Show this help
  list [path]         List directory contents
  tfs [path]          Show directory tree
  goto <path>         Change current directory
  lct                 Print working directory
  txt <file> <str>    Write text to file
  txt <file> >> <s>   Append text to file
  mk <dir>            Make a directory
  f <file>            Create an empty file
  r <file>            Read a file
  tex <file>          Edit a file
  del <path>          Remove file or dir (recursive)
  move <src>, <dst>   Move file or dir
  copy <src>, <dst>   Copy file or dir (recursive)
  define <name> "..." Define a custom command
  tmp define <n> "..." Define a temporary command
  wb <url>            Open URL in Firefox
  mp2                 Become root (login shell)
  tmp_mp2 <cmd...>    Run a single command as root
  ./<file>            Execute a shell script
  <program>           Run a program from /bin
  text <text>         Print text (echo)
  cd                  Clear the screen
  e                   Exit the shell
  v                   Show version
Operators:
  &&&&                Chain commands
Paths:
  ~                   Home (= /user/main)
Custom commands:
  (none)
Programs in /bin:
  hw
  sysinfo
HELP_END
}

# ---------- FS ----------
list() { command ls --color=auto "$@"; }
tfs()  { command find "${1:-.}" | sed -e 's;[^/]*/;|____;g;s;____|; |;g'; }
goto() { builtin cd "$@"; }
lct()  { command pwd; }
txt()  { local f="$1"; shift; if [[ "$1" == ">>" ]]; then shift; echo "$*" >> "$f"; else echo "$*" > "$f"; fi; }
mk()   { command mkdir -p -- "$@"; }
f()    { command touch -- "$@"; }
r()    { command cat -- "$@"; }
tex()  { command nano -- "$@"; }
del()  { command rm -rf -- "$@"; }

move() {
    local a="$*"; local src="${a%%,*}"; local dst="${a##*,}"
    command mv -- "$(echo $src)" "$(echo $dst)"
}
copy() {
    local a="$*"; local src="${a%%,*}"; local dst="${a##*,}"
    command cp -r -- "$(echo $src)" "$(echo $dst)"
}

# ---------- Custom commands ----------
define()     { local n="$1"; shift; eval "$n() { $* ; }"; }
tmp_define() { local n="$1"; shift; eval "$n() { $* ; }"; }
tmp() { [[ "$1" == "define" ]] && { shift; tmp_define "$@"; }; }

# ---------- Root / PKG ----------
mp2()     { sudo su -; }
tmp_mp2() { sudo "$@"; }

# ---------- ETC ----------
wb()   { command firefox "$1" >/dev/null 2>&1 & }
text() { echo "$*"; }
v()    { echo "alueNX+ 3.0.0"; }
cd()   { clear; }
e()    { exit; }
edit() { nano ~/.bashrc; }
ral() {
    local root="${1:-.}"

    if [ ! -e "$root" ]; then
        printf 'ral: %s: i dont found your shit! \n' "$root" >&2
        return 1
    fi

    if [ -f "$root" ]; then
        _ral_one "$root"
        return 0
    fi

    find "$root" -mindepth 1 \( -type f -o -type l -o -type d \) -print0 \
        | sort -z \
        | while IFS= read -r -d '' p; do
            _ral_one "$p"
        done
}

_ral_one() {
    local p="$1"
    local size

    if [ -L "$p" ]; then
        printf '== %s -> %s ==\n' "$p" "$(readlink -- "$p")"
        return
    fi

    if [ -d "$p" ]; then
        printf '== %s/ ==\n' "$p"
        return
    fi

    size=$(wc -c < "$p" 2>/dev/null || echo 0)

    if [ ! -s "$p" ]; then
        printf '== %s (%sB, leer) ==\n' "$p" "$size"
        return
    fi

    if LC_ALL=C grep -Iq . "$p" 2>/dev/null; then
        printf '== %s (%sB) ==\n' "$p" "$size"
        cat -- "$p"
        [ -n "$(tail -c1 -- "$p")" ] && printf '\n'
    else
        printf '== %s (binary, %sB) ==\n' "$p" "$size"
    fi
}

# ---------- /bin ----------
hw()      { echo "Hello, World!"; }
sysinfo() { command uname -srm; }