Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Aliases and native utils name collision #567

Copy link
Copy link
@vors

Description

@vors
Issue body actions

We have 24 conflicting names between PS aliases and /bin, /usr/bin, etc folders

# /bin
cat              
cp               
echo             
kill             
ls               
mv               
ps               
pwd              
rm               
rmdir            
sleep
# /usr/bin
cd                     
clear                  
cpp                    
diff                   
fc                     
man                    
ri                     
sort                   
tee                    
type                   
write         
# /usr/sbin
ac
# /sbin
mount

We need to figure out what's out story about it.

I think it make sense to play around with different options to see pros and cons on practice.

Try it (the snippet is outdated, see the new snippet for 0.3.0 bellow)

You can add this snippet to your profile and easily switch from one mode to another

  • Remove-PSAliases will remove aliases, so you can use native utilities.
  • Set-PSAliases will restore aliases.
$global:__aliases = @(
    'cat',              
    'cp',               
    'echo',             
    'kill',             
    'ls',               
    'mv',               
    'ps',               
    'pwd',              
    'rm',               
    'rmdir',            
    'sleep',
    'cd',                     
    'clear',                  
    'cpp',                    
    'diff',                   
    'fc',                     
    'man',                    
    'ri',                     
    'sort',                   
    'tee',                    
    'type',                   
    'write',         
    'ac',
    'mount'
) 

function Set-PSAliases
{
    $global:__aliases | % { 
        Write-Host "Adding $_"
        Set-Alias $_ $global:__aliases_backup[$_] -Scope Global 
    }      
}

function Remove-PSAliases
{
    if (-not $global:__aliases_backup) {
        $global:__aliases_backup = @{}
        $global:__aliases | % {
            $global:__aliases_backup[$_] = (Get-Command $_).ResolvedCommandName
        }
    }

    $global:__aliases | % { 
        Write-Host "Removing $_"
        while (Test-Path alias:$_) {
            Remove-Item -Force alias:$_ 
        }
    }
}
Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aUsability(LEGACY) Helps filter issues that might be higher priority because they directly affect usability(LEGACY) Helps filter issues that might be higher priority because they directly affect usability

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.