Skip to content

Instantly share code, notes, and snippets.

@hleroy
Created January 2, 2022 19:24
Show Gist options
  • Save hleroy/31c669564020932dd53ff66d7c7bca1b to your computer and use it in GitHub Desktop.
Save hleroy/31c669564020932dd53ff66d7c7bca1b to your computer and use it in GitHub Desktop.
Display reminders when cd-ing into directories containing a .cd-reminder file
# cd_reminder
# - Add bash excerpt below to your .bashrc or .bash_aliases
# - Restart your terminal or run `source .bashrc`
# - Add a file named `.cd-reminder` into a directory
# - `cd` into this directory: the content of `.cd-reminder` will be printed out
# Slightly modified version from https://unix.stackexchange.com/questions/18532/show-message-when-cd-into-specific-directory
# to allow printing ANSI colors
cd_reminder() {
builtin cd "$@" && { [ ! -f .cd-reminder ] || echo -ne $(cat .cd-reminder | sed 's/$/\\n/' | sed 's/ /\\a /g'); }
}
alias cd=cd_reminder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment