Skip to content

Commit 3fc2fb7

Browse files
refactor(shell): remove powershell identifier
relates to #6806
1 parent 80ffa05 commit 3fc2fb7

14 files changed

Lines changed: 24 additions & 30 deletions

File tree

src/cli/init.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ func runInit(sh, command string) {
7474
log.Enable(plain)
7575
}
7676

77+
if sh == "powershell" {
78+
sh = shell.PWSH
79+
}
80+
7781
initCache(sh)
7882

7983
cfg := config.Load(configFlag, false)
@@ -163,7 +167,7 @@ func getFullCommand(cmd *cobra.Command, args []string) string {
163167
}
164168

165169
func initCache(sh string) {
166-
if !printOutput && eval && (sh == shell.PWSH || sh == shell.PWSH5) {
170+
if !printOutput && eval && sh == shell.PWSH {
167171
cache.Init(sh)
168172
return
169173
}

src/config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func (cfg *Config) getPalette() color.Palette {
120120
func (cfg *Config) Features(env runtime.Environment) shell.Features {
121121
var feats shell.Features
122122

123-
asyncShells := []string{shell.BASH, shell.ZSH, shell.FISH, shell.PWSH, shell.PWSH5}
123+
asyncShells := []string{shell.BASH, shell.ZSH, shell.FISH, shell.PWSH}
124124

125125
if cfg.Async && slices.Contains(asyncShells, env.Shell()) {
126126
log.Debug("async enabled")

src/prompt/engine.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ func (e *Engine) applyPowerShellBleedPatch() {
260260
// to avoid the background being printed on the next line
261261
// when at the end of the buffer.
262262
// See https://github.com/JanDeDobbeleer/oh-my-posh/issues/65
263-
if e.Env.Shell() != shell.PWSH && e.Env.Shell() != shell.PWSH5 {
263+
if e.Env.Shell() != shell.PWSH {
264264
return
265265
}
266266

@@ -522,7 +522,7 @@ func New(flags *runtime.Flags) *Engine {
522522
diff = -2
523523
}
524524
eng.rectifyTerminalWidth(diff)
525-
case shell.PWSH, shell.PWSH5:
525+
case shell.PWSH:
526526
// when in PowerShell, and force patching the bleed bug
527527
// we need to reduce the terminal width by 1 so the last
528528
// character isn't cut off by the ANSI escape sequences

src/prompt/extra.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func (e *Engine) ExtraPrompt(promptType ExtraPromptType) string {
9999
prompt += "\nRPROMPT=''"
100100
return prompt
101101
}
102-
case shell.PWSH, shell.PWSH5:
102+
case shell.PWSH:
103103
if promptType == Transient {
104104
// clear the line afterwards to prevent text from being written on the same line
105105
// see https://github.com/JanDeDobbeleer/oh-my-posh/issues/3628

src/prompt/primary.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func (e *Engine) needsPrimaryRightPrompt() bool {
110110
}
111111

112112
switch e.Env.Shell() {
113-
case shell.PWSH, shell.PWSH5, shell.GENERIC, shell.ZSH:
113+
case shell.PWSH, shell.GENERIC, shell.ZSH:
114114
return true
115115
default:
116116
return false

src/prompt/tooltip.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func (e *Engine) Tooltip(tip string) string {
4848
text, length = e.handleToolTipAction(text, length)
4949

5050
switch e.Env.Shell() {
51-
case shell.PWSH, shell.PWSH5:
51+
case shell.PWSH:
5252
e.rprompt = text
5353
e.currentLineLength = e.Env.Flags().Column
5454

src/segments/path.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ func (pt *Path) setPaths() {
179179
}
180180

181181
pt.pwd = pt.env.Pwd()
182-
if (pt.env.Shell() == shell.PWSH || pt.env.Shell() == shell.PWSH5) && len(pt.env.Flags().PSWD) != 0 {
182+
if pt.env.Shell() == shell.PWSH && len(pt.env.Flags().PSWD) != 0 {
183183
pt.pwd = pt.env.Flags().PSWD
184184
}
185185

src/shell/constants.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ const (
55
BASH = "bash"
66
PWSH = "pwsh"
77
FISH = "fish"
8-
PWSH5 = "powershell"
98
CMD = "cmd"
109
NU = "nu"
1110
GENERIC = "shell"

src/shell/dsc.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func (s *Shell) getShellConfigPath() (string, error) {
9797
case FISH:
9898
configDir := filepath.Join(home, ".config", "fish")
9999
return filepath.Join(configDir, "config.fish"), nil
100-
case PWSH, PWSH5:
100+
case PWSH:
101101
return cmd.Run(s.Name, "-NoProfile", "-Command", "$PROFILE")
102102
case NU:
103103
return cmd.Run("nu", "-c", "$nu.config-path")
@@ -192,7 +192,7 @@ func (s *Shell) shellCommand() string {
192192
return fmt.Sprintf(`eval "$(%s)"`, s.Command)
193193
case FISH:
194194
return s.Command + " | source"
195-
case PWSH, PWSH5:
195+
case PWSH:
196196
return s.Command + " | Invoke-Expression"
197197
case ELVISH:
198198
return fmt.Sprintf(`eval (%s)`, s.Command)

src/shell/dsc_test.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -397,14 +397,6 @@ func TestShellCommand(t *testing.T) {
397397
},
398398
expected: "oh-my-posh init pwsh | Invoke-Expression",
399399
},
400-
{
401-
name: "powershell shell command",
402-
shell: &Shell{
403-
Name: "powershell",
404-
Command: "oh-my-posh init powershell",
405-
},
406-
expected: "oh-my-posh init powershell | Invoke-Expression",
407-
},
408400
{
409401
name: "elvish shell command",
410402
shell: &Shell{

0 commit comments

Comments
 (0)