Reputation: 627
I have a command say intr-cmd
which opens an interactive console for web framework. But I need to run command cmd-a
before and cmd-b
after running the intr-cmd
manually. These commands change some files for intr-cmd
to run.
How can I code this in Bash such that I only have to run intr-cmd
and these commands are run before and after it.
Edit: Some explanation
intr-cmd
opens an interactive console but it first reads a file of currently installed plugins to load them. But there is a plugin which is installed on production but is not working on the local environment and it is not necessary for my work. but the plugins file is committed into the git. so I have to comment on the plugin then run the intr-cmd
and then uncomment that line in the file.
I want to automate this step so that it does not accidentally get committed to the git.
Upvotes: 0
Views: 234
Reputation: 17493
You can create a function intr-cmd
, which replaces the general intr-cmd
command, as explained here.
I should like like:
intr-cmd()
{
cmd-a
/path/intr-cmd
cmd-b
}
(Obviously you need to fill in the right path.)
I tried to flag your question as a duplicate, but as the link refers to another StackExchange forum, this wasn't allowed, hence this answer.
Upvotes: 2
Reputation: 67831
In your case, instead of changing intr-cmd
each time you need it, you could create a git branch (possibly in a specific clone of your git repo) for your testing environment with a modified version of intr-cmd
, and/or a modified version of the plugin list.
Upvotes: 0