相关疑难解决方法(0)

每次登录时 BASH 历史记录被截断为 500 行

出于某种原因,我无法让我的系统在重新启动后保留我的 BASH 历史记录。以下是我的相关部分~/.bashrc

shopt -s histappend
PROMPT_COMMAND='history -a; updateWindowTitle'
export HISTCONTROL=ignoredups
export HISTSIZE=9999
export HISTFILESIZE=999999
export HISTFILE="$HOME/.bash_history"
Run Code Online (Sandbox Code Playgroud)

据我所知,这些是所有必要的选项(我知道过去我可以在多次重新启动后保留历史记录,而过去没有所有这些)。但是,尽管在几次重新启动之前添加了这些选项,但在重新启动后我仍然丢失了大部分历史记录。它不是空的,但它没有我重新启动之前的 9999 行。

在有人抱怨之前,是的,我已经阅读了这些问题。我已经实施了他们上面列出的一些建议,其余的要么没有帮助,要么不相关:

如果那里可能有其他相关命令,您可以~/.bashrc 在此处查看我的全部内容。

那么,我错过了什么?为什么我的历史没有保存?如果有人认为另一个文件可能相关,请告诉我,我会发布它。我通过grep -i hist \.*在 my$HOME中运行来检查它显示唯一.包含字符串hist或的相关文件HIST.bashrc.

我正在运行 Linux Mint Debian 版,GNU bash,版本 4.2.36(1)-release (x86_64-pc-linux-gnu) 和我最喜欢的终端模拟器(如果相关)是terminator.


更新:

按照@mpy 在评论中的建议,我将 my 更改 …

linux terminal bash shell history

23
推荐指数
2
解决办法
8178
查看次数

如何坚持bash历史?

我不知道这是否符合预期,但我的历史记录不会跨会话保存。这就是说,如果我关闭窗口,那么当我再次打开它时,历史记录是空的。我怎样才能跨会话坚持它?

以下是您询问的命令的输出:

 set -o | grep history
history         on

$ grep -i history ~/.bashrc ~/.bash_profile ~/etc/bash.bashrc ~/etc/profile ~/.profile
/cygdrive/c/cygwin/home/car/.bashrc:# Make bash append rather than overwrite the history on disk
/cygdrive/c/cygwin/home/car/.bashrc:# History Options
/cygdrive/c/cygwin/home/car/.bashrc:# Don't put duplicate lines in the history.
/cygdrive/c/cygwin/home/car/.bashrc:# export PROMPT_COMMAND="history -a"
grep: /cygdrive/c/cygwin/home/car/etc/bash.bashrc: No such file or directory
grep: /cygdrive/c/cygwin/home/car/etc/profile: No such file or directory
/cygdrive/c/cygwin/home/car/.profile:if [ "x$HISTFILE" == "x/.bash_history" ]; then
/cygdrive/c/cygwin/home/car/.profile:  HISTFILE=$HOME/.bash_history

$ ls -la ~/ | grep history -> no output

$ echo $HISTFILE …
Run Code Online (Sandbox Code Playgroud)

linux cygwin bash command-line bashrc

12
推荐指数
2
解决办法
8628
查看次数

如何在 Bash 中重置已编辑的历史记录行?

在 Bash 中,您可以按向上(和向下)箭头来遍历历史记录。然后,您可以在执行该命令之前对其进行修改。有时我错误地修改了命令,并希望将其重置为最初的历史记录。有没有办法做到这一点?

我试过执行一个空行,然后再次遍历历史记录,但相关行仍处于编辑状态。

bash history command-line

9
推荐指数
1
解决办法
735
查看次数

bash:每个命令的历史记录。它是如何工作的?

好的。我家里有一台运行 Leopard 的旧 G5 和一台运行 Ubuntu 10.04 的戴尔,还有一台 MacPro 在工作时也运行 Leopard。

我经常使用 Terminal.app/bash。在我的家用 G5 上,它展示了一个很好的功能:使用?导航历史记录我得到最后一个命令,以我输入的几个字母开头。

这就是我的意思(|代表插入符号):

$ ssh user@server
$ vim /some/file/just/to/populate/history
$ ss|
Run Code Online (Sandbox Code Playgroud)

所以,我输入了“ssh”的两个首字母,?结果如下:

$ ssh user@server
Run Code Online (Sandbox Code Playgroud)

而不是这个,这是我在其他地方得到的行为:

$ vim /some/file/just/to/populate/history
Run Code Online (Sandbox Code Playgroud)

如果我继续点击??,我可以浏览这样的历史ssh

$ ssh otheruser@otherserver
$ ssh user@server
$ ssh yetanotheruser@yetanotherserver
Run Code Online (Sandbox Code Playgroud)

它适用于任何命令,例如catvim或其他任何命令。

这太酷了。除了我不知道如何在我的其他机器上模仿这种行为。

这是我的.profile

export PATH=/Developer/SDKs/flex_sdk_3.4/bin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/sw/bin:/sw/sbin:/bin:/sbin:/bin:/sbin:/usr/bin:/usr/sbin:$HOME/Applications/bin:/usr/X11R6/bin
export MANPATH=/usr/local/share/man:/usr/local/man:opt/local/man:sw/share/man
export INFO=/usr/local/share/info
export PERL5LIB=/opt/local/lib/perl5
export PYTHONPATH=/opt/local/bin/python2.7
export EDITOR=/opt/local/bin/vim
export VISUAL=/opt/local/bin/vim
export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home

export …
Run Code Online (Sandbox Code Playgroud)

terminal bash history macos

7
推荐指数
1
解决办法
912
查看次数

标签 统计

bash ×4

history ×3

command-line ×2

linux ×2

terminal ×2

bashrc ×1

cygwin ×1

macos ×1

shell ×1