Here is one possibility, if your users access the directory via command line:
Redefine the shell's builtin cd
command in a global rc
file to check if a file .readme
is present in the current dir and if so, display it (with some nice optical elements).
a. With zsh
(/etc/zshrc
) you can use a specially designed hook function (chpwd
), which is called whenever the current working dir is changed:
function chpwd {
if [[ -e .readme ]]; then
echo
echo \#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#
cat .readme
echo \#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#
echo
fi }
b. I don't know if there's a similar possibility in bash
, however you can redefine cd
in /etc/bash.bashrc
:
cd() {
builtin cd "$@"
if [[ -e .readme ]]; then
echo
echo \#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#
cat .readme
echo \#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#
echo
fi
}
c. And finally the same with csh
(/etc/csh.cshrc
) syntax:
alias cd 'cd \!*; eval "if (-e .readme) then \\
echo \\
echo ################################################################################ \\
cat .readme \\
echo ################################################################################ \\
echo \\
endif"'
And this it how it looks like:
user@machine:~> cd temp
################################################################################
Attention! This is a temporary directory!
################################################################################
user@machine:~/temp>
zsh
you can simply usechpwd () { [[ -e .readme ]] && cat .readme }
.chpwd
is called whenever the current working dir is changed,.readme
is of course your message. This should be doable in other shells, too. In the worst case by redefiningcd
.;)
. With some more infos from the OP here, I think about writing an answer because I use this per-folder reminder heavily myself.bash
andzsh
if you setcd
to be an alias to the function you suggested.