Skip to content

Commit ea965c2

Browse files
change psedit to Open-EditorFile and alias psedit to it
1 parent dde1aac commit ea965c2

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

module/PowerShellEditorServices/Commands/PowerShellEditorServices.Commands.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ FunctionsToExport = @('Register-EditorCommand',
7777
'Out-CurrentFile',
7878
'Join-ScriptExtent',
7979
'Test-ScriptExtent',
80-
'psedit')
80+
'Open-EditorFile')
8181

8282
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
8383
CmdletsToExport = @()

module/PowerShellEditorServices/Commands/Public/CmdletInterface.ps1

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,13 @@ function Unregister-EditorCommand {
7777
}
7878
}
7979

80-
function psedit {
80+
function Open-EditorFile {
8181
param([Parameter(Mandatory=$true)]$FilePaths)
8282

8383
dir $FilePaths | where { !$_.PSIsContainer } | % {
8484
$psEditor.Workspace.OpenFile($_.FullName)
8585
}
8686
}
87-
Export-ModuleMember -Function psedit
87+
Set-Alias psedit Open-EditorFile -Scope Global
88+
89+
Export-ModuleMember -Function Open-EditorFile

src/PowerShellEditorServices/Session/RemoteFileManager.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,22 @@ public class RemoteFileManager
7474
7575
Register-EngineEvent -SourceIdentifier PSESRemoteSessionOpenFile {0}
7676
77-
if ((Test-Path -Path 'function:\global:PSEdit') -eq $false)
77+
if ((Test-Path -Path 'function:\global:Open-EditorFile') -eq $false)
7878
{{
79-
Set-Item -Path 'function:\global:PSEdit' -Value $PSEditFunction
79+
Set-Item -Path 'function:\global:Open-EditorFile' -Value $PSEditFunction
80+
Set-Alias psedit Open-EditorFile -Scope Global
8081
}}
8182
";
8283

8384
private const string RemovePSEditFunctionScript = @"
84-
if ((Test-Path -Path 'function:\global:PSEdit') -eq $true)
85+
if ((Test-Path -Path 'function:\global:Open-EditorFile') -eq $true)
8586
{
86-
Remove-Item -Path 'function:\global:PSEdit' -Force
87+
Remove-Item -Path 'function:\global:Open-EditorFile' -Force
88+
}
89+
90+
if (Get-Alias psedit)
91+
{
92+
Remove-Alias psedit
8793
}
8894
8995
Get-EventSubscriber -SourceIdentifier PSESRemoteSessionOpenFile -EA Ignore | Remove-Event

0 commit comments

Comments
 (0)