Skip to content

Conversation

belotn
Copy link
Contributor

@belotn belotn commented Apr 2, 2022

fzf allow to complete ssh|telnet command with a list of known hosts. The purpose of this is to allow to grab all host (from command invoke-command or enter-pssesion ) from history and append it to prompt

PSFzf.Base.ps1 Outdated
}

function Invoke-FzfHandlerHistoryHost {
$Commands = @('icm','Invoke-Command','Enter-PSSession','etsn')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a bit limiting, and seems case-sensitive? Should probably be using (Get-Command $Name -Type Alias).ResolvedCommandname (plus error checking) to get the command from an alias so that it also works for custom aliases, not just icm and etsn.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes ! Maybe something like that :

	$Cmdlets = @('Invoke-Command','Enter-PSSession')
	$Alias = (get-alias |? { $Cmdlets -contains $_.ResolvedCommand }).Name
	$Commands = $Cmdlets + $Alias

And as in Powershell 5, Get-Service, Get-Process, Get-WmiObject used to have a "-ComputerName" parameters, this entries should be searched in history

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants