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
?
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
?
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
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).