The right command in the right folder at the right time
Table of Contents
The right command in the right folder at the right time #
you need to perform some actions
you are in the right folder
radical-folder-dispatcher is your hero!
Let’s be honest, it’s not a common request to execute some command(s) on folder basis unless something similar to setting a development environment comes to you mind (maybe I’m a bit biased towards software development ;) ). I’ve nailed it down how to do it automatically. Thanks for asking!
The trick here is to use the Bash PROMPT_COMMAND environment variable to execute some command before Bash displays a prompt, and in this case is the entry function . At this point a check is performed against a list of candidates placed at file lines (, executing each function declared before the pipe separator () and the first matching fires the corresponding program declared after the separator. The match is decided upon the function return value : 0 is a match and everything else is a no-match (). If no match is found the program declared at file is executed.
Go on, try it for yourself, follow the install instructions and spread the word!
Update #1 (September 23rd, 2018) : added code line number and contents for the main script parts.