Skip to content

Commit

Permalink
refactor(core): move default_aliases into the scoped function (#3233)
Browse files Browse the repository at this point in the history
  • Loading branch information
chawyehsu authored and r15ch13 committed Mar 18, 2019
1 parent 39e406d commit 17cb68f
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions lib/core.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -512,24 +512,6 @@ function pluralize($count, $singular, $plural) {
if($count -eq 1) { $singular } else { $plural }
}

# for dealing with user aliases
$default_aliases = @{
'cp' = 'copy-item'
'echo' = 'write-output'
'gc' = 'get-content'
'gci' = 'get-childitem'
'gcm' = 'get-command'
'gm' = 'get-member'
'iex' = 'invoke-expression'
'ls' = 'get-childitem'
'mkdir' = { new-item -type directory @args }
'mv' = 'move-item'
'rm' = 'remove-item'
'sc' = 'set-content'
'select' = 'select-object'
'sls' = 'select-string'
}

function reset_alias($name, $value) {
if($existing = get-alias $name -ea ignore | Where-Object { $_.options -match 'readonly' }) {
if($existing.definition -ne $value) {
Expand Down Expand Up @@ -557,6 +539,24 @@ function reset_aliases() {
}
}

# for dealing with user aliases
$default_aliases = @{
'cp' = 'copy-item'
'echo' = 'write-output'
'gc' = 'get-content'
'gci' = 'get-childitem'
'gcm' = 'get-command'
'gm' = 'get-member'
'iex' = 'invoke-expression'
'ls' = 'get-childitem'
'mkdir' = { new-item -type directory @args }
'mv' = 'move-item'
'rm' = 'remove-item'
'sc' = 'set-content'
'select' = 'select-object'
'sls' = 'select-string'
}

# set default aliases
$default_aliases.keys | ForEach-Object { reset_alias $_ $default_aliases[$_] }
}
Expand Down

0 comments on commit 17cb68f

Please sign in to comment.