简体   繁体   中英

Run a command before and after running an interactive command

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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM