abgox / PSCompletions

A completion manager for better and simpler use completions in PowerShell. 一个补全管理模块,更简单、更方便的在 PowerShell 中使用命令补全。
https://pscompletions.pages.dev
MIT License
78 stars 4 forks source link

PSC not working #1

Closed LuuKhoaHoc closed 10 months ago

LuuKhoaHoc commented 10 months ago

I followed you to add install PSC and Import PSC to PWSH, all thing ok but when i type psc and press space then tab. It's not working at well image image

abgox commented 10 months ago

demo

abgox commented 10 months ago

psc

LuuKhoaHoc commented 10 months ago

with me it triggered and told me update new version, and then it still not work. I deleted remove all module from before ver in Powershell module at Document then Reinstall that. It still not work. image image image image image

LuuKhoaHoc commented 10 months ago

image image

abgox commented 10 months ago

You removed all the modules, and they included PSCompletions? If not,You can try removing PSCompletions by running 'Uninstall-Module PSCompletions' and reinstall it.

LuuKhoaHoc commented 10 months ago

Yes, i did it, but im reinstall all of this but still now work

LuuKhoaHoc commented 10 months ago

Oh it get some error when i reinstall PSComplete image

abgox commented 10 months ago

I can't reappear this bug. We do the same thing, but the results are different. demo

LuuKhoaHoc commented 10 months ago

Still error bro. It told me update to 3.0.3 then i press enter and this happend image

abgox commented 10 months ago

Are you using Windows Powershell? The problem is a lack of permissions. You should follow the prompts and use -Scope or restart the command line with administrator privileges.

LuuKhoaHoc commented 10 months ago

Im using Window powershell bro, this my $NOTEPAD image It have any problem?

abgox commented 10 months ago

It's not their problem. It's that in Windows PowerShell, you need to have enough permissions to install and update PowerShell modules smoothly.

LuuKhoaHoc commented 10 months ago

I just updated and this appear image

LuuKhoaHoc commented 10 months ago

But still not working image

abgox commented 10 months ago

Maybe I know. Do you try running the following command and see what the result is? $PSCompletions.fn_download_list()

LuuKhoaHoc commented 10 months ago

image That is result

abgox commented 10 months ago

I need you to change some code,Since I can't reappear the bug. Change the 148-line throw statement to throw $_ Snipaste_2023-12-10_20-27-50

LuuKhoaHoc commented 10 months ago

image Still not work :(

abgox commented 10 months ago

What I need is the error message after the change.

LuuKhoaHoc commented 10 months ago

I didn't get an error message

LuuKhoaHoc commented 10 months ago

Are you have ultraview or something else?, help me fix that bro. I really want use PSComplete

abgox commented 10 months ago

It should be an unexpected error in the first initialization that caused something to be lost. I need to check some directory structures. Is it different from mine? 1 2 3 4

LuuKhoaHoc commented 10 months ago

image image image image We are same bro

abgox commented 10 months ago

I'm using Windows Terminal. But that shouldn't be a problem, and I tested it on several other computers and PowerShell under Linux.

LuuKhoaHoc commented 10 months ago

image I try to remove PSComplete and i still can add git after that Im using window terminal ver 7.4 too and im using Window 11 too

abgox commented 10 months ago

Try to run 'Uninstall-Module PSCompletions'?

LuuKhoaHoc commented 10 months ago

Ok i just uninstall it and that work. Let me try reinstall

abgox commented 10 months ago

What's the latest situation? After my testing, when there are some old versions in a module, it may make the install, uninstall, and remove commands invalid. I suggest you just delete the PSCompletions folder and then reinstall it.

LuuKhoaHoc commented 10 months ago

still not work bro :(. I alse delete the PSCompletions folder for every time when i use Remove-Module not work

abgox commented 10 months ago

Now, after you delete it, can you restart powershell and use psc command normally? Do you get errors like I do? Snipaste_2023-12-10_21-40-40

LuuKhoaHoc commented 10 months ago

Yes, that sure bro

abgox commented 10 months ago

If you reinstall the module now, it won't report the previous error, just it don't work?

LuuKhoaHoc commented 10 months ago

image

LuuKhoaHoc commented 10 months ago

image

LuuKhoaHoc commented 10 months ago

image image image Full height of report after reinstall PSCompletion

abgox commented 10 months ago

That's the problem here, but it seems that it will only appear on your computer Snipaste_2023-12-10_21-49-11

Try to run the following command and see the result: $PSCompletions.fn_get_config()

abgox commented 10 months ago

It should output : Snipaste_2023-12-10_21-52-45

LuuKhoaHoc commented 10 months ago

image from me

abgox commented 10 months ago

I simulated your environment and found that when I import it, my psc didn't work anymore. There may be a conflict between them. Snipaste_2023-12-10_22-23-11

When I import it,I reappear the bug here. Snipaste_2023-12-10_22-28-38

LuuKhoaHoc commented 10 months ago

Oh god, that why, i will try now

LuuKhoaHoc commented 10 months ago

It work bro, thank a lot. <3 Im really happy. Thank you very much 🥰😭.

abgox commented 10 months ago

For their conflicts, I'll deal with them in the next release. I hope PSCompletions can help your work.

LuuKhoaHoc commented 10 months ago

Thank you very much, it help a lot. I will close issue after this comment

Limborx commented 10 months ago

遇到同样的问题。跟随这个教程跑了一遍,然后才发现大佬的PSCompletions。再使用PSCompletions后tab展示的内容类似上面的反馈,请问大佬,是不是同样的原因导致冲突了,如何消除这个冲突 image

abgox commented 10 months ago

使用的平台呢?Windows? Linux? 使用的是 Powershell 还是 Windows Powershell? 有无报错信息?

Limborx commented 10 months ago

没有报错,除了tab不行,其他看起来都没问题,下面是我的脚本文件。 之前代码中有Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete。 我尝试了Remove-PSReadlineKeyHandler -Key Tab,但是也没恢复正常

image

Limborx commented 10 months ago

平台是window 10,工具是Windows terminal,terminal中配置的是power shell

abgox commented 10 months ago

Powershell的版本呢? Snipaste_2023-12-14_11-14-54

abgox commented 10 months ago

我这里的测试是完全没有问题的,我的配置文件只有这两行也能正常工作。 你的配置文件是否还包含了其他的内容,我需要看一看你完整的配置文件 Snipaste_2023-12-14_11-20-01 Snipaste_2023-12-14_11-18-40

Limborx commented 10 months ago

image power shell版本看起来是有些低。

完整代码如下,其他代码是用于展示当前分支的,不会影响提示

function Write-BranchName () {
    try {
        $branch = git rev-parse --abbrev-ref HEAD
        if ($branch -eq "HEAD") {
            # we're probably in detached HEAD state, so print the SHA
            $branch = git rev-parse --short HEAD
            Write-Host " ($branch)" -ForegroundColor "red"
        }
        else {
            # we're on an actual branch, so print it
            Write-Host " ($branch)" -ForegroundColor "blue"
        }
    } catch {
        # we'll end up here if we're in a newly initiated git repo
        Write-Host " (no branches yet)" -ForegroundColor "yellow"
    }
}

function prompt {
    $base = "PS "
    $path = "$($executionContext.SessionState.Path.CurrentLocation)"
    $userPrompt = "$('>' * ($nestedPromptLevel + 1)) "
    Write-Host "`n$base" -NoNewline
    if (Test-Path .git) {
        Write-Host $path -NoNewline -ForegroundColor "green"
        Write-BranchName
    }
    else {
        # we're not in a repo so don't bother displaying branch name/sha
        Write-Host $path -ForegroundColor "green"
    }
    return $userPrompt
}

$OutputEncoding = [console]::InputEncoding = [console]::OutputEncoding = New-Object System.Text.UTF8Encoding

# Shows navigable menu of all options when hitting Tab
# Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete

# Autocompletion for arrow keys
# Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward
# Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward

# auto suggestions
Import-Module PSCompletions
Set-PSReadLineOption -PredictionSource History
Import-Module PSReadLine