Skip to content

Instantly share code, notes, and snippets.

@oneman
Created December 22, 2025 11:08
Show Gist options
  • Select an option

  • Save oneman/8c608fc372e77779c92942a6e9e55925 to your computer and use it in GitHub Desktop.

Select an option

Save oneman/8c608fc372e77779c92942a6e9e55925 to your computer and use it in GitHub Desktop.
You should try lsd!
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fts.h>
/* lsd is awesome */
int main(int argc, char **argv) {
static char path[4096];
getcwd(path, sizeof(path));
FTS *fs;
FTSENT *n;
char *paths[] = { path, NULL };
fs = fts_open(paths, FTS_PHYSICAL, NULL);
if (!fs) return 1;
for (;;) {
n = fts_read(fs);
if (!n) break;
if (n->fts_info == FTS_F) printf("%s\n", n->fts_path);
}
return fts_close(fs);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment