1

The .hidden file is quite convenient to hide directories, what applications use and generated themselves.

How do I treat items listed in the .hidden file hidden, while using ls?

https://sh.c7.ee/5JG0W/Screenshot%20from%202020-02-19%2000-52-35.png

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
u15p7fgy863eiq5
  • 205
  • 2
  • 5

2 Answers2

0

By default, files in a .hidden file folder would not be hidden themselves: check it with ls -l0.

You can hide them individually

chflags hidden .hidden/foo
chflags hidden .hidden/foo

Check also their Extended Attributes with xattr to see if they have any special attribute compared to regular files outside .hidden

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

GNU ls has option --hide=, so if you have that implementation, it's possible to create a simple wrapper:

#!/usr/bin/env sh

hide=
if [ -f .hidden ]; then
    while IFS= read -r line; do
        hide="$hide --hide=$line"  # use `--ignore` to have them hidden even when `ls -a`
    done < .hidden
fi

ls $hide "$@"

It's a rough example, there is a bit of edge cases to handle (like I did in ls.hidden).

Jorengarenar
  • 2,705
  • 5
  • 23
  • 60