假设我有一个函数:
lsm(){
ls ~/music
}
然后,假设我运行了它:
lsm
之后,如果我按下“向上”键,那么我将看到 lsm
:我运行的最后一个命令。
但是,我的目标是让 Bash 历史写入函数/别名的完整扩展定义。
因此,如果我按“向上”键,我将在之前仅键入 lsm
后在 Bash 历史记录中看到 ls ~/music
。
最佳答案
@Cyrus 有一个实用的建议:
使用 history -s some string
将 some string
写入您的历史记录。
history -s The *args* are added to the end of the history list as a single entry.
(来源:https://www.gnu.org/software/bash/manual/html_node/Bash-History-Builtins.html)
关于linux - 如何将函数/别名定义写入 Bash 历史记录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37351848/