public function run($groupName, array $exludedProjects = [], $historyFile = null)
    {
        // Load the persisted shell command history.
        if ($historyFile) {
            $this->historyShellManager->getHistory()->loadHistory($historyFile);
        }

        // Set the prompt.
        $this->historyShellManager->setPrompt($this->getPrompt($groupName));

        // Disable auto exit from shell.
        $this->application->setAutoExit(false);

        // Show the welcome message.
        $this->output->writeln($this->getHeader($groupName, $exludedProjects));

        while (true) {
            // Add a new line to separate the prompts from each other.
            if ($this->promptCounter > 0 && !empty($cmd)) {
                $this->output->write("\n");
            }

            // Read the command the user enters.
            $cmd = $this->readline($groupName);
            $this->promptCounter++;

            if (false === $cmd) {
                $this->output->writeln("\n");

                break;
            }

            // Add the command to the history.
            if (!empty($cmd) && $cmd != 'exit') {
                $this->historyShellManager->getHistory()->addCommand($cmd);
            }

            // Create an event.
            $event = new BeforeShellCommandExecutionEvent($cmd);

            // Dispatch an event to do something with the command string before running it.
            $this->dispatcher->dispatch(ShellEvents::BEFORE_SHELL_COMMAND_EXECUTION_EVENT, $event);

            if ($event->getCommand() == 'exit') {
                $this->application->setAutoExit(true);
                return;
            }

            if ($exludedProjects != []) {
                foreach ($exludedProjects as &$exludedProject) {
                    $exludedProject = '-x '.$exludedProject;
                }
            }

            $command = new StringInput(
                sprintf(
                    'execute %s "%s"'.($exludedProjects != [] ? join(
                        ' ',
                        $exludedProjects
                    ) : ''),
                    $groupName,
                    $event->getCommand()
                )
            );

            $ret = $this->application->run($command, $this->output);

            if (0 !== $ret) {
                $this->output->writeln(
                    sprintf(
                        '<error>The command terminated with an error status (%s)</error>',
                        $ret
                    )
                );
            }
        }
    }