Skip to content

Commit e4fa97e

Browse files
mojotxpraveenkumar
authored andcommitted
Add support for fish-shell on macOS
Add fish shell support for `crc oc-env` Addresses #1047
1 parent 523e185 commit e4fa97e

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

pkg/os/shell/shell.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ func GenerateUsageHint(userShell, cmdLine string) string {
3939
comment := "#"
4040

4141
switch userShell {
42+
case "fish":
43+
cmd = fmt.Sprintf("eval (%s)", cmdLine)
4244
case "powershell":
4345
cmd = fmt.Sprintf("& %s | Invoke-Expression", cmdLine)
4446
case "cmd":
@@ -57,6 +59,8 @@ func GetEnvString(userShell string, envName string, envValue string) string {
5759
return fmt.Sprintf("$Env:%s = \"%s\"", envName, envValue)
5860
case "cmd":
5961
return fmt.Sprintf("SET %s=%s", envName, envValue)
62+
case "fish":
63+
return fmt.Sprintf("contains %s $fish_user_paths; or set -U fish_user_paths %s $fish_user_paths", envValue, envValue)
6064
default:
6165
return fmt.Sprintf("export %s=\"%s\"", envName, envValue)
6266
}
@@ -65,6 +69,8 @@ func GetEnvString(userShell string, envName string, envValue string) string {
6569
func GetPathEnvString(userShell string, prependedPath string) string {
6670
var pathStr string
6771
switch userShell {
72+
case "fish":
73+
pathStr = prependedPath
6874
case "powershell":
6975
pathStr = fmt.Sprintf("%s;$Env:PATH", prependedPath)
7076
case "cmd":

pkg/os/shell/shell_darwin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package shell
22

33
var (
4-
supportedShell = []string{"bash", "zsh"}
4+
supportedShell = []string{"bash", "zsh", "fish"}
55
)

0 commit comments

Comments
 (0)