from Hacker News

lc: List files in categories (and columns) – from Coherent Unix clone

by networked on 1/10/25, 10:10 AM with 31 comments

  • by jll29 on 1/10/25, 11:52 AM

    Nice to read an older piece of clean C code once in a while. Gives me that cozy retro feel and fond childhood memories.

    Beautifying the output sounds like a good idea, perhaps something like this should be an option of standard ls?

    What strikes me is that the code (which is very idiomatic of C code) is very expressive at the function level, but most of it happens inside the few functions, and the function bodies are much less readable for those who don't write C ls clones all day. The main function is very long because it handles command line switches, that boilerplate could be moved to a function or library.

    The file lc.1 (UNIX man pasge) is missing, as has already. been pointed out.

    • simple/compact: single file

    • small: 446 lines of C code

    • flat/monolithic: lots of global variables, no separation between functionality and I/O, no separation between command and library API that does the core part of the work.

    (Just posting what was on my mind, not my intention to attack this fine work!)

  • by BSDobelix on 1/10/25, 12:28 PM

  • by hk__2 on 1/10/25, 11:34 AM

    If the author sees this: please copy/paste the manual in your README instead of including an image with text on it. You’ll help blind people and search engines.
  • by ZoomZoomZoom on 1/10/25, 2:51 PM

    Not to be confused with another lc, which is a highly configurable "multi-dimensional"[1] file lister focused on flexibility and configurability, written in Nim.

    https://github.com/c-blake/lc

    Key features:

    - Multi-level sorting by combinations of attributes like size, time, and file type, with user-defined precedence

    - Configurable file kind sorting order

    - Value-dependent coloring for file attributes such as timestamps, permissions, or sizes.

    - Abbreviations: Automatically shorten filenames, user/group names or symlink targets.

    - File type classification: Integrates libmagic for file type inspection.

    - Hyperlink support

    - Per-directory configs: custom behaviors for specific directories using local tweak files (.lc).

    - Lightweight (~900 lines of code) with only author's CLI library "cligen" and Nim's stdlib as dependencies.

    and more.

    [1]: https://github.com/c-blake/lc#vector-typemulti-dimensionalit...

  • by oguz-ismail on 1/10/25, 11:23 AM

    No colorful text, no emojis, no Unicode decorations. Nice.
  • by jmclnx on 1/10/25, 5:56 PM

    I was a Coherent User and lc was my goto file list.
  • by Rucadi on 1/10/25, 1:07 PM

    Hacked pretty fast a version with json support, not pretty but just as a concept: https://github.com/Rucadi/lc
  • by boxed on 1/10/25, 12:24 PM

    The categories being "files" and "directories"? So just two categories?
  • by layer8 on 1/10/25, 6:38 PM

    I wouldn’t call it listed in columns when the order is row-major. Rather listed in rows.
  • by johnthescott on 1/11/25, 3:17 PM

    brings back memories. my first exposure to unix was coherent and 4bsd. fond memories studying the source.