PoShFuck
PoShFuck copied to clipboard
Question: where's the StaticDict.xml?
Excuse me if this is a wrong place to ask such a stupid question, but the repository itself doesn't seem to contain one and googling the file name didn't return any result except this repo, plus the original thefuck uses .py files as rules. I was hoping to find some ready-made StaticDict.xml, or an example, or some documentation about how to write one from scratch. Thanks in advance.
Hi,
The static dictionary is not included in the repo because it is only relevant to the user's context. It contains custom entries which are written to disk after a suggestion is accepted by the user.
The format of the file is a hashtable from Export-Clixml. If you want to look at one you can install the module and accept some suggestions, then open the file from the module directory. ( Join-Path (Split-Path (Get-Module -ListAvailable PoShFuck).Path) StaticDict.xml )
Nial
Really thanks for the quick reply!
I guess I still don't understand what that file is, because that just seemed to be the problem preventing me from "accepting some suggestions".
λ peng 8.8.8.8
peng : 无法将“peng”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。
! TRANSLATION: Omitted because not important, just failed to execute that
所在位置 行:1 字符: 1
! TRANSLATION: At line 1 character 1
+ peng 8.8.8.8
+ ~~~~
+ CategoryInfo : ObjectNotFound: (peng:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
λ Invoke-TheFuck
Import-Clixml : 未能找到文件“PATH\TO\CMDER\vendor\psmodules\PoShFuck\StaticDict.xml”。
! TRANSLATION: Import-Clixml: Can't find file "StaticDict.xml".
所在位置 PATH\TO\CMDER\vendor\psmodules\PoShFuck\PoShFuck.psm1:52 字符: 17
!TRANSLATION: At ... character 17
+ $staticdict = Import-Clixml $dictloc
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OpenError: (:) [Import-Clixml], FileNotFoundException
+ FullyQualifiedErrorId : FileOpenFailure,Microsoft.PowerShell.Commands.ImportClixmlCommand
不能对 Null 值表达式调用方法。
! TRANSLATION: Can't invoke method on a null expression.
所在位置 PATH\TO\CMDER\vendor\psmodules\PoShFuck\PoShFuck.psm1:133 字符: 2
! TRANSLATION: At ... character 2
+ $prevmatch = $staticdict.Get_Item($splitcmd)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [],RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Did you mean?
peng 8.8.8.8
[Y] Yes [N] No [?] 帮助 (默认值为“Y”): n
! TRANSLATION: [?] Help (default "Y")
λ
Sorry for the Chinese mixed in the output, but I have no idea what they would be in the en-US version of Windows. I put translations right after them.
I am using PowerShell with Cmder (ConEmu 161022, stable) on Windows 10 Professional (version 15063.296). Installed the module by executing the script, manually added Import-Module PoShFuck
in my $profile. Is the environment causing this, or did I do anything wrong?
Sorry for the late reply mate.
Open powershell without cmder. Ive never used it so guessing it controls the host in some way? Try the same thing then. That path to cmder in the error i think is the cause, can your session write to it?
Maybe it could be related to the chinese locale too, it suggested the same wrong command. Try to fix the dict path first then we'll see if the suggestion works.
Nial
Hi,
Thanks for the reminders. Now I tried in native powershell, this time it is not complaining about the missing StaticDict.xml
, but it still suggests what I exactly typed. I had symlinked my user powershell module folder to the cmder psmodules folder before (for the convenient of syncing settings, and the cmder folder has no need for administrative permissions to read/write) so I checked there again and there's still no StaticDict.xml
(double checked using some third-party full-disk searching tool).
I tried accepting the wrong suggestions for testing purpose, and still there's no StaticDict.xml
appeared. Confirmed this behavior from an elevated session.