jcollum
jcollum

Reputation: 46569

Some Powershell aliases in my profile are not loading, why?

Here's a section of my profile:

#alias gs='git status'
function GitStatus { & git status $args }
Set-Alias -Option AllScope -Name gs -Value GitStatus

# aliases - other ----------------------------------
function Touch { & echo $null >> $args }
Set-Alias -Option AllScope -Name touch -Value Touch
function LL { & ls }
Set-Alias -Option AllScope -Name ll -Value LL
function Open { & Invoke-Item $args }
Set-Alias -Option AllScope -Name open -Value Open

echo "Loading profile v6..."

My profile is at:

C:\Users\[USER NAME]\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

The profile loads without any errors:

$ .$PROFILE
Loading profile v6...

But the open alias isn't loaded.

$ open .\coverage\report.html
open : The term 'open' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if
a path was included, verify that the path is correct and try again.

But the gs alias is.

$ gs
On branch f/listener
Changes to be committed:

So how did I get in a situation where some of my alias load and some don't? There are no errors when the profile loads....

$ $PSVersionTable.PSVersion
Major  Minor  Build  Revision
-----  -----  -----  --------
5      1      14393  1198

Upvotes: 1

Views: 893

Answers (2)

Joby C John
Joby C John

Reputation: 1

I encountered the same issues when my $PROFILE was loading another .ps1 file containing aliases and functions.

To resolve this, I moved the aliases and functions directly into the $PROFILE file.

Upvotes: 0

Bill_Stewart
Bill_Stewart

Reputation: 24525

Try using

Set-Alias open Start-Process

I tested and it works for me.

Upvotes: 0

Related Questions