Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I display a message when I cd into a specific directory? This directory is a local one, and I just need a reminder when I go into it from the terminal.

share|improve this question
up vote 20 down vote accepted

If I were you, I would toy around with something like that in my shell configuration file (e.g. ~/.bashrc):

reminder_cd() {
    builtin cd "$@" && { [ ! -f .cd-reminder ] || cat .cd-reminder 1>&2; }

alias cd=reminder_cd

This way, you can add a .cd-reminder file in each directory you want to get a reminder for. The content of the file will be displayed after each successful cd to the directory.

gim@tenebreuse ~/tmp % echo 'warning: this directory is pure junk' > .cd-reminder
gim@tenebreuse ~/tmp % cd ..
gim@tenebreuse ~ % cd tmp
warning: this directory is pure junk
gim@tenebreuse ~/tmp % 
share|improve this answer
Cool idea by the way! I like it, and maybe I'll use it too :-) – Stéphane Gimenez Aug 11 '11 at 0:52
Awesome. Thank you, Stéphane! – Connor Montgomery Aug 11 '11 at 0:59
Not importat in this case, but in general is good abit to always double quote $@. – enzotib Aug 11 '11 at 15:04
Thanks, I'm now wondering if there is any case where $@ should be preferred over "$@" – Stéphane Gimenez Aug 11 '11 at 18:49
You should use $@ or $* (they are the same thing when unquoted) when you want IFS wordsplitting to occur. – Chris Down Sep 16 '11 at 20:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.