MCPcopy Create free account
hub / github.com/github/gh-aw / uninstallPowerShellCompletion

Function uninstallPowerShellCompletion

pkg/cli/shell_completion.go:530–558  ·  view source on GitHub ↗

uninstallPowerShellCompletion uninstalls PowerShell completion

(verbose bool)

Source from the content-addressed store, hash-verified

528
529// uninstallPowerShellCompletion uninstalls PowerShell completion
530func uninstallPowerShellCompletion(verbose bool) error {
531 shellCompletionLog.Print("Uninstalling PowerShell completion")
532
533 // Determine PowerShell profile path
534 var profileCmd *exec.Cmd
535 if runtime.GOOS == "windows" {
536 profileCmd = exec.Command("powershell", "-NoProfile", "-Command", "echo $PROFILE")
537 } else {
538 profileCmd = exec.Command("pwsh", "-NoProfile", "-Command", "echo $PROFILE")
539 }
540
541 var profileBuf bytes.Buffer
542 profileCmd.Stdout = &profileBuf
543 if err := profileCmd.Run(); err != nil {
544 return fmt.Errorf("failed to get PowerShell profile path: %w", err)
545 }
546
547 profilePath := strings.TrimSpace(profileBuf.String())
548
549 fmt.Fprintln(os.Stderr, console.FormatInfoMessage("PowerShell profile path: "+profilePath))
550 fmt.Fprintln(os.Stderr, "")
551 fmt.Fprintln(os.Stderr, console.FormatInfoMessage("To uninstall completions, remove the following line from your PowerShell profile:"))
552 fmt.Fprintln(os.Stderr, "")
553 fmt.Fprintln(os.Stderr, " gh aw completion powershell | Out-String | Invoke-Expression")
554 fmt.Fprintln(os.Stderr, "")
555 fmt.Fprintln(os.Stderr, console.FormatInfoMessage("Then restart your shell or run: . $PROFILE"))
556
557 return nil
558}

Callers 1

UninstallShellCompletionFunction · 0.85

Calls 5

FormatInfoMessageFunction · 0.92
PrintMethod · 0.80
RunMethod · 0.45
ErrorfMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected