在PowerShell中使用thefuck

使用pip install thefuck -i https://pypi.tuna.tsinghua.edu.cn/simple

安装这个thefuck工具,选择清华镜像源

然后在PowerShell的$ProFile文件中添加环境变量,并定义一个函数。

# fuck
$env:PYTHONIOENCODING='utf-8'
function Invoke-TheFuck {
    $history = (Get-History -Count 1).CommandLine;
    if (-not [string]::IsNullOrWhiteSpace($history)) {
        $fuck = $(thefuck $args $history);
        if (-not [string]::IsNullOrWhiteSpace($fuck)) {
            if ($fuck.StartsWith("echo")) { $fuck = $fuck.Substring(5); }
            else { Invoke-Expression "$fuck"; }
        }
    }
}

Set-Alias -name "fuck" -value "Invoke-TheFuck"
# 来自:https://github.com/nvbn/thefuck/issues/536#issuecomment-350558359

大功告成

powershell encoding warning on every ‘fuck’ execution · Issue #514 · nvbn/thefuck (github.com)

It doesn’t work on Win10 powershell after put alias in $profile · Issue #536 · nvbn/thefuck (github.com)

Powershell, The term ‘thefuck’ is not recognized as the name of a cmdlet · Issue #809 · nvbn/thefuck (github.com)

知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇