When ever a certain user is doing: cd /var/www/* I want to display a red message, "THIS IS PRODUCTION".

on any folder bellow /var/www/

Is it possible?



Try this on for size:

PS1='$(if [[ $PWD == /var/www/* ]]; then echo -n "\[\033[01;31m\]THIS IS SPARTA\[\033[00m\]:"; fi; echo "\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$")'

For persistence... throw that in ~/.bashrc or some such.

  • Wooow. amazing!!! – SexyMF Jul 20 '17 at 5:07
  • +1 for the example message. :) – Esa Jokinen Jul 20 '17 at 5:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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