216 字
1 分钟
Linux 终端复刻 PowerShell 历史命令选择功能
原生 Bash 实现「输 git 弹出历史」(Windows PowerShell 同款体验)
一、直接给你能复制的配置(一步到位)
1. 打开配置文件
vim ~/.bashrc2. 把下面这段代码,粘贴到文件最底部
# ======================# 原生 Bash:输 git 按上箭头 弹出历史(PowerShell 同款)# ======================# 上下箭头:只搜索以当前输入开头的历史命令bind '"\e[A": history-search-backward'bind '"\e[B": history-search-forward'
# 让历史记录更强大(不重复、立即保存)HISTCONTROL=ignoredups:ignorespaceshopt -s histappendPROMPT_COMMAND="history -a; history -c; history -r"3. 按 ESC → 输入 :wq 保存退出
4. 立即生效
source ~/.bashrc二、现在直接能用!效果演示
1、输入:git2、按 上箭头 ↑3、自动弹出 所有你之前输过的 git 开头的历史命令4、找到想要的 → 直接回车执行,或左右键修改完全和你在 Windows PowerShell 里的体验一模一样! Linux 终端复刻 PowerShell 历史命令选择功能
https://fuwari.vercel.app/posts/指南/linux复刻powershell历史命令选择功能/