This question already has an answer here:
So, I can create custom key mapping for specific directories like this:
autocmd BufNewFile,BufRead <name of directory>* map <key> :! <command here>
This only executes the command in that specific directory. Say I have F5 as key, then outside of that directory, F5 does not do anything special. To add F5 to another directory, I simply repeat the above code and change name of directory and commands. This would get make my vimrc to be very messy if I have many directories that I need F5 to do stuff (just for example).
Is it possible to do something like this? `
if (directory = <dirA>) then execute this command else if (directory = <dirB>) then execute this command instead