(ctx context.Context, config *Config, kubeconfigPath string)
| 88 | } |
| 89 | |
| 90 | func (u *UnixShell) CreateCommand(ctx context.Context, config *Config, kubeconfigPath string) *exec.Cmd { |
| 91 | cmd := exec.CommandContext(ctx, u.executable) |
| 92 | |
| 93 | // setup env |
| 94 | env := cmd.Environ() |
| 95 | env = setEnvironmentVariable(env, "KUBECONFIG", kubeconfigPath) |
| 96 | |
| 97 | // set custom prompt with color based on privilege level |
| 98 | var promptColor string |
| 99 | if config.Privileged { |
| 100 | promptColor = "\\[\\033[1;31m\\]" // red |
| 101 | } else { |
| 102 | promptColor = "\\[\\033[1;34m\\]" // blue |
| 103 | } |
| 104 | prompt := fmt.Sprintf("%s%s\\[\\033[0m\\] \\u@\\h:\\w$ ", promptColor, config.PromptInfo) |
| 105 | env = setEnvironmentVariable(env, "PS1", prompt) |
| 106 | |
| 107 | // Suppress macOS bash deprecation warning that appears when bash is spawned |
| 108 | // on systems where zsh is the default shell. This prevents the noisy message: |
| 109 | // "The default interactive shell is now zsh. To update your account to use zsh..." |
| 110 | env = setEnvironmentVariable(env, "BASH_SILENCE_DEPRECATION_WARNING", "1") |
| 111 | |
| 112 | cmd.Env = env |
| 113 | cmd.Stdin = os.Stdin |
| 114 | cmd.Stdout = os.Stdout |
| 115 | cmd.Stderr = os.Stderr |
| 116 | |
| 117 | return cmd |
| 118 | } |
nothing calls this directly
no test coverage detected