kelleyma49 / PSFzf

A PowerShell wrapper around the fuzzy finder fzf
MIT License
795 stars 36 forks source link

Prevent the module from creating certain aliases #15

Closed dstcruz closed 5 years ago

dstcruz commented 6 years ago

Is there a way to prevent the module from importing certain aliases? In my case, specifically, the alias fd shadows the fd command (the cool find command).

Is the solution to do something like this? This doesn't seem very clean, as it might end up not removing the alias that was intended.

Import-Module PSFzf -ArgumentList 'Ctrl+T','Ctrl+R'
Remove-Item alias:fd
kelleyma49 commented 6 years ago

I have a commit up that uses New-Alias instead of Set-Alias - see https://github.com/kelleyma49/PSFzf/commit/5490cda782556300e291b5f5eedd8a85102e488a. This commit makes it so aliases declared before the import of PSFzf won't be overwritten. Will that solve your issue?

glucas commented 5 years ago

Using New-Alias to avoid clobbering existing aliases would be good. but won't solve the issue here where fd is an executable on the path rather than a predefined alias.

I think you'd need to check using Get-Command, e.g.

(Get-Command fd -ErrorAction SilentlyContinue)  # fd exists, don't clobber it
kelleyma49 commented 5 years ago

Using New-Alias to avoid clobbering existing aliases would be good. but won't solve the issue here where fd is an executable on the path rather than a predefined alias.

I think you'd need to check using Get-Command, e.g.

(Get-Command fd -ErrorAction SilentlyContinue)  # fd exists, don't clobber it

Good point. I've updated PSFzf to use Get-Command. See release https://www.powershellgallery.com/packages/PSFzf/1.1.19.