ShellStartupOptions (@NotNull ShellStartupOptions options) { List<String> shellCommand = options.getShellCommand(); String shellExe = ContainerUtil.getFirstItem(shellCommand); if (shellCommand == null || shellExe == null) return options; List<String> arguments = new ArrayList<>(shellCommand.subList(1, shellCommand.size())); Map<String, String> envs = ShellStartupOptionsKt.createEnvVariablesMap(options.getEnvVariables()); ShellType shellType = null; boolean withCommandBlocks = false; List<String> resultCommand = new ArrayList<>(); resultCommand.add(shellExe); String shellName = PathUtil.getFileName(shellExe); String rcFilePath = findRCFile(shellName); if (rcFilePath != null) { if (shellName.equals(BASH_NAME) || (SystemInfo.isMac && shellName.equals(SH_NAME))) { addRcFileArgument(envs, arguments, resultCommand, rcFilePath, "--rcfile"); // remove --login to enable --rcfile sourcing boolean loginShell = arguments.removeAll(LOGIN_CLI_OPTIONS); setLoginShellEnv(envs, loginShell); setCommandHistoryFile(options, envs); shellType = ShellType.BASH; withCommandBlocks = true; } else if (shellName.equals(ZSH_NAME)) { String zdotdir = envs.get(ZDOTDIR); if (StringUtil.isNotEmpty(zdotdir)) { envs.put("_INTELLIJ_ORIGINAL_ZDOTDIR", zdotdir); } String zshDir = PathUtil.getParentPath(rcFilePath); envs.put(ZDOTDIR, zshDir); envs.put(IJ_ZSH_DIR, zshDir); shellType = ShellType.ZSH; withCommandBlocks = true; } else if (shellName.equals(FISH_NAME)) { // `--init-command=COMMANDS` is available since Fish 2.7.0 (released November 23, 2017) // Multiple `--init-command=COMMANDS` are supported. resultCommand.add("--init-command=source " + CommandLineUtil.posixQuote(rcFilePath)); shellType = ShellType.FISH; withCommandBlocks = true; } else if (isPowerShell(shellName)) { resultCommand.addAll(arguments); arguments.clear(); resultCommand.addAll(List.of("-NoExit", "-ExecutionPolicy", "Bypass", "-File", rcFilePath)); shellType = ShellType.POWERSHELL; withCommandBlocks = true; } } resultCommand.addAll(arguments); return options.builder() .shellCommand(resultCommand) .envVariables(envs) .shellIntegration(shellType != null ? new ShellIntegration(shellType, withCommandBlocks) : null) .build(); }