Sometimes I like to have very customized bash aliases and maybe keybindings when I enter on a folder (can be a project where I'm used to type lots of commands from CLI).Lets suppose when I enter a folder like projectAlpha/ I expect some custom aliases like:alias doTaskX='./app arg1 arg2...|filter arg1 arg2...'...More than it I was thinking of:Display a helpful message showing aliases and common commandsDisplaying some common custom keybindings for my projectBut as soon as I leave the root of my project these settings become unavailable.What is the best approach to do it today?
Setting temporary bash aliases when entering a folder
bash;shell;alias
Bash has special variable PROMPT_COMMAND which content is executed every time after the command is executed, so you can set it as follows:PROMPT_COMMAND='[[ $PWD = /tmp ]] && { alias ll=ls; echo Remember: ll=ls; } || { unalias ll 2>/dev/null; }'From now on every time you will be in the /tmp directory alias ll will be created and in all other directories it will be removed.Probably more practical is to gather all your aliases and other stuff in one function (say makealias) and all unaliases in the other function makeunalias which you can run depending on your needs, something likePROMPT_COMMAND='[[ $PWD = /tmp ]] && makealias || makeunalias 2>/dev/null'Notice that stderr redirection is present only to prevent some useless in this case alerts.