Skip to content

Commit

Permalink
Write whole installation steps
Browse files Browse the repository at this point in the history
Update #4
  • Loading branch information
kachick committed Mar 4, 2024
1 parent 65338dc commit 9b53e3f
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 13 deletions.
6 changes: 3 additions & 3 deletions PSFzfHistory.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
Expand Down Expand Up @@ -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')
Expand Down
61 changes: 52 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,86 @@

## 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

```pwsh
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
Expand Down
1 change: 0 additions & 1 deletion src/PSFzfHistory.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9b53e3f

Please sign in to comment.