nrfutil completion install powershell

When executing:

nrfutil completion install powershell

The output suggests adding this to $PROFILE

# From nrfutil completion install
# WARNING: nrfutil tab-completion may become slow because of Windows Defender
if ( Test-Path -Path ${USERPROFILE}\.nrfutil\share\nrfutil-completion\scripts\powershell\setup.ps1 ) {
    . ${USERPROFILE}\.nrfutil\share\nrfutil-completion\scripts\powershell\setup.ps1
}

I did some debuging to find out why the tab-completion does not work.
If I am not wrong the variable ${USERPROFILE} should be $env:USERPROFILE.
At least on my system (Windows 11, PowerShell 7.4) that was the solution.

Am I doing something wrong?

Parents
  • I am just opening a PowerShell Terminal.
    This opens in my $HOME directory, C:\Useres\myuser

    This also the location of .nrfutil
    I installed nrfutil with:

    winget install NordicSemiconductor.nrfutil
    
    Get-Command -Name nrfutil
    
    CommandType     Name                                               Version    Source
    -----------     ----                                               -------    ------
    Application     nrfutil.exe                                        0.0.0.0    C:\Users\timur\AppData\Local\Microsoft\WinGet\Packages\NordicSemiconductor.nrfutil_Microsoft.Winget.Source_8wekyb3d8bbwe\nrfutil.exe

    This is my $PROFILE where I had to add the $USERPROFILE manualy.

    # Set USERPROFILE
    $USERPROFILE = $env:USERPROFILE
    
    Invoke-Expression -Command $(gh completion -s powershell | Out-String)
    # Aliases
    Set-Alias -Name ll -Value Get-ChildItem -Force
    
    # Powershell Modules
    Import-Module posh-git
    
    Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete
    
    # WARNING: nrfutil tab-completion may become slow because of Windows Defender
    # From nrfutil completion install
    if ( Test-Path -Path ${USERPROFILE}\.nrfutil\share\nrfutil-completion\scripts\powershell\setup.ps1 ) {
        . ${USERPROFILE}\.nrfutil\share\nrfutil-completion\scripts\powershell\setup.ps1
     }
    else {
        Write-Host "⚠️ The nrfutil completion script does not exist."
        exit
    }

Reply
  • I am just opening a PowerShell Terminal.
    This opens in my $HOME directory, C:\Useres\myuser

    This also the location of .nrfutil
    I installed nrfutil with:

    winget install NordicSemiconductor.nrfutil
    
    Get-Command -Name nrfutil
    
    CommandType     Name                                               Version    Source
    -----------     ----                                               -------    ------
    Application     nrfutil.exe                                        0.0.0.0    C:\Users\timur\AppData\Local\Microsoft\WinGet\Packages\NordicSemiconductor.nrfutil_Microsoft.Winget.Source_8wekyb3d8bbwe\nrfutil.exe

    This is my $PROFILE where I had to add the $USERPROFILE manualy.

    # Set USERPROFILE
    $USERPROFILE = $env:USERPROFILE
    
    Invoke-Expression -Command $(gh completion -s powershell | Out-String)
    # Aliases
    Set-Alias -Name ll -Value Get-ChildItem -Force
    
    # Powershell Modules
    Import-Module posh-git
    
    Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete
    
    # WARNING: nrfutil tab-completion may become slow because of Windows Defender
    # From nrfutil completion install
    if ( Test-Path -Path ${USERPROFILE}\.nrfutil\share\nrfutil-completion\scripts\powershell\setup.ps1 ) {
        . ${USERPROFILE}\.nrfutil\share\nrfutil-completion\scripts\powershell\setup.ps1
     }
    else {
        Write-Host "⚠️ The nrfutil completion script does not exist."
        exit
    }

Children
Related