Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have Github for Windows installed (Win7 x64). It also came with a handy shortcut that allowed launching a Git-optimized Powershell instance (which also displayed information such as the git file status in the prompt when in a tracked folder).

I deleted that shortcut a while ago and now I'm trying to restore it. I have found the script it was executing (shell.ps1 in the app folder), but trying to run it yields several rather ugly errors, such as:

Set-Alias : The AllScope option cannot be removed from the alias 'cat'.
At C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1:11 char:10
+ set-alias <<<<  cat        get-content
    + CategoryInfo          : WriteError: (cat:String) [Set-Alias], SessionStateUnauthorizedAccessException
    + FullyQualifiedErrorId : AliasAllScopeOptionCannotBeRemoved,Microsoft.PowerShell.Commands.SetAliasCommand

I can simply use an alternative (like the msys shell), but I'm really curious as to why the PowerShell version isn't working.

share|improve this question
add comment

3 Answers

Error suggest collision between your profile and shell.ps1. This particular one is probably because you have cat alias defined in your profile, and it's trying to overwrite the one in shell.ps1

I would follow suggestion from this script itself:

Generally you would run this from your Powershell Profile like this:

. (Resolve-Path "$env:LOCALAPPDATA\GitHub\shell.ps1")

Anyways: the heart of this is not this script, it's module that comes with it, so be sure to add one more line in your profile:

Import-Module $env:posh_git

That is the piece that handles prompt and other elements.

If you want to avoid using profile - just use -noprofile switch on powershell.exe.

share|improve this answer
    
I've added those commands in my profile, but they only seem to affect the x86 version of the powershell. The x64 instance apparently ignores that file, even though entering $profile shows the same profile filename as the x86 version. Moreover, now I'm getting another error in the x86 version: Import-Module : Cannot bind argument to parameter 'Name' because it is null., on the Import-Module line. –  Andrei Bârsan Mar 18 '13 at 12:49
1  
It should not matter with version of PS you use (x86/ x64), but just to be sure - you can always dot-source script directly from console. Error you get from Import-Module suggests that you are not dot-sourcing script though: . Shell.ps1 has very different effect than Shell.ps1. –  BartekB Mar 18 '13 at 12:59
add comment

See the answers to http://stackoverflow.com/q/17457182/95580; the following command worked for me:

%LocalAppData%\GitHub\GitHub.appref-ms --reinstall-shortcuts
share|improve this answer
add comment
up vote 0 down vote accepted

Well, I managed to hack together a solution, by manually loading my posh-git in my profile (the Import-Module $env:posh_git command wasn't working and was throwing a nasty error about $env:posh_git not being a module):

. (Resolve-Path "$env:LOCALAPPDATA\GitHub\shell.ps1")
. (Resolve-Path "$env:LOCALAPPDATA\GitHub\PoshGit_e0fc5e56ff55708a890f408f03656f758fa0ba8a\profile.example.ps1")

...and by commenting out all the default aliases in my default profile file located in (C:\Windows\System32\WindowsPowerShell\v1.0). It worked without this last change as well, but Poweshell kept showing a ton of errors when starting up. Strangely enough, aliases such as cat and ls still work.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.