From 9b53e3f167cb4c5e62fcf937faf5664d2242a0c5 Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Mon, 4 Mar 2024 18:27:32 +0900 Subject: [PATCH] Write whole installation steps Update #4 --- PSFzfHistory.psd1 | 6 ++--- README.md | 61 ++++++++++++++++++++++++++++++++++++------- src/PSFzfHistory.psm1 | 1 - 3 files changed, 55 insertions(+), 13 deletions(-) diff --git a/PSFzfHistory.psd1 b/PSFzfHistory.psd1 index 62361f5..10159af 100644 --- a/PSFzfHistory.psd1 +++ b/PSFzfHistory.psd1 @@ -9,7 +9,7 @@ @{ # Script module or binary module file associated with this manifest. -# RootModule = '' +RootModule = 'src/PSFzfHistory.psm1' # Version number of this module. ModuleVersion = '0.0.1' @@ -30,7 +30,7 @@ CompanyName = 'Unknown' Copyright = '(c) Kenichi Kamiya. All rights reserved.' # Description of the functionality provided by this module -Description = 'fzf integration to realize history substring search with small code' +Description = 'fzf history integration with small code' # Minimum version of the PowerShell engine required by this module # Adjust with bundled PSReadLine @@ -67,7 +67,7 @@ PowerShellVersion = '5.1' # FormatsToProcess = @() # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess -NestedModules = @('src/PSFzfHistory.psm1') +# NestedModules = @('src/PSFzfHistory.psm1') # Functions 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 functions to export. FunctionsToExport = @('Invoke-FzfHistory', 'Set-FzfHistoryKeybind') diff --git a/README.md b/README.md index 5ba4048..6082a2d 100644 --- a/README.md +++ b/README.md @@ -6,18 +6,46 @@ ## Usage -As a preparation step, install and add the path for fzf with your favorite method +### Requirements + +Install fzf with your favorite method, I prefer winget in Windows as follows ```pwsh -# Install fzf winget install --exact --id junegunn.fzf +``` + +### Features + +Try this after [whole installation steps](#installation) + +```pwsh +Invoke-FzfHistory +``` + +And enable the keybind if you want +```pwsh +Set-FzfHistoryKeybind -Chord Ctrl+r +``` + +### Enable in your Profile.ps1 + +In your $PROFILE + +```pwsh # Make sure the winget tools in your PATH # https://github.com/microsoft/winget-cli/issues/2498#issuecomment-1553863082 $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") + +# Add this section if you want the keybind +if (Get-Module -Name PSFzfHistory) { + Set-FzfHistoryKeybind -Chord Ctrl+r +} ``` -Now [PowerShell Gallery](https://www.powershellgallery.com/) looks like [not accepting new author or publish](https://github.com/PowerShell/PowerShellGallery/issues/266). So I describe how to load local files here. +### Installation + +Unfortunately, now [PowerShell Gallery](https://www.powershellgallery.com/) looks like [not accepting new author or publish](https://github.com/PowerShell/PowerShellGallery/issues/266). So I describe how to install local modules. Download this module from GitHub @@ -25,24 +53,39 @@ Download this module from GitHub Invoke-WebRequest 'https://github.com/kachick/PSFzfHistory/archive/refs/heads/main.zip' -OutFile .\PSFzfHistory.zip Expand-Archive .\PSFzfHistory.zip .\ Remove-Item PSFzfHistory.zip +Move-Item .\PSFzfHistory-main\ .\PSFzfHistory\ ``` -Enable it +Create local repository if you don't have it yet ```pwsh -Import-Module -Name .\PSFzfHistory-main\src\PSFzfHistory.psm1 +# https://stackoverflow.com/questions/49987884/how-to-install-update-a-powershell-module-from-a-local-folder-set-up-an-intern +$local_modules_path = Join-Path -Path (Split-Path -Parent $PROFILE) -ChildPath "MyModules" +New-Item -Force -ItemType "Directory" -Path $local_modules_path +Register-PSRepository -Name "MyRepository" -InstallationPolicy Trusted -SourceLocation $local_modules_path ``` -Now you can use the better history experience +Install from your local repository ```pwsh -Invoke-FzfHistory +# https://github.com/PowerShell/PowerShellGetv2/issues/606 +$env:DOTNET_CLI_UI_LANGUAGE="en_US" +$env:DOTNET_CLI_LANGUAGE="en_US" +$env:NUGET_CLI_LANGUAGE="en_US" +Publish-Module -Path .\PSFzfHistory -Repository MyRepository +Remove-Item .\PSFzfHistory +Install-Module -Name PSFzfHistory -Repository MyRepository ``` -And enable the keybind if you want +Make sure you are really installed the module ```pwsh -Set-FzfHistoryKeybind -Chord Ctrl+r +> Get-InstalledModule + +Version Name Repository Description +------- ---- ---------- ----------- +5.5.0 Pester PSGallery Pester provides a framework for running … +0.0.1 PSFzfHistory MyRepository fzf history integration with small code ``` ## Limitations diff --git a/src/PSFzfHistory.psm1 b/src/PSFzfHistory.psm1 index 39ecd85..83b348c 100644 --- a/src/PSFzfHistory.psm1 +++ b/src/PSFzfHistory.psm1 @@ -15,7 +15,6 @@ function AsOrderedSet { $input | Where-Object { $set.Add($_) } } - function Reverse { # Prefer Stack rather than Enumerable::Reverse from the performance # See tools/benchmark.ps1 for detail