無限のバッシュ履歴[閉じる]
4670 ワード
本文の翻訳は以下の通りである:Unlimited Bash History[closed]
I want my
参照先:https://stackoom.com/question/dgG1/無限のバッシュ履歴-オフ
Set
In bash 4.3 and later you can also use
After many large, ugly iterations and weird edge cases over the years, I now have a concise section of my .bashrc dedicated to this. 長年にわたって多くの大型、醜い反復と奇妙なエッジ状況を経て、私は今これに特化しています.bashrcの簡潔な部分.
First, you must comment out or remove this section of your .bashrc (default for Ubuntu). まず、コメントを削除するか削除する必要があります.bashrcのこのセクション(Ubuntuのデフォルト).If you don't,then certain environments(like running
Second, add this to the bottom of your .bashrc:次に、それを追加します.bashrcの下部:
Note: every command is written immediately after it's run, so if you accidentally paste a password you cannot just "kill -9 %%"to avoid the history write, you'll need to remove it manually. 注意:各コマンドは実行後すぐに書き込まれるため、パスワードを誤って貼り付けた場合は、履歴の書き込みを避けるために「-9%%を殺す」だけではいけません.手動で削除する必要があります.
Also note that each bash session will load the full history file in memory, but even if your history file grows to 10MB (which will take a long, long time) you won't notice much of an effect on your bash startup time. また、各bashセッションではメモリに完全な履歴ファイルがロードされますが、履歴ファイルが10 MBに増加しても(これには時間がかかります)、bashの起動時間に大きな影響を及ぼすことはありません.
There are(at least)two relevant env vars here:ここには少なくとも2つの環境変数があります. HISTSIZE:the number of entries in the history file HISTSIZE:履歴ファイルのエントリ数 HISTFILESIZE:the number of lines in the history file HISTFILESIZE:履歴ファイルの行数 I think that we can agree that the term unlimited is often the same as very big (or do you have unlimited file storage?). 無期限という言葉は通常非常に大きい(あるいは無限のファイルストレージがある?)ことに同意できると思います.So just set the values very large. したがって、非常に大きな値を設定するだけです.
As Jörg Beyer mentioned above,
In addition, you should definitely check out the environmental variable
Links: here , and working with bash history . リンク:ここでbash履歴を使用します.The bash Variable FAQ is also worth browsing . bash Variable FAQも閲覧する価値があります.
I want my
.bash_history
file to be unlimited. 私の.bash_history
ファイルに制限がないことを望んでいます.eg So I can always go back and see how I built/configured something, or what that nifty command was, or how some command broke something weeks ago. 例えば、私はいつも帰って、私がどのように何かを構築/構成しているか、あるいはそのきれいなコマンドが何なのか、あるいは数週間前にいくつかのコマンドがどのように破壊されたのかを見ることができます.How do I change this setting? この設定を変更するにはどうすればいいですか?1階
参照先:https://stackoom.com/question/dgG1/無限のバッシュ履歴-オフ
2階
Set
HISTSIZE
and HISTFILESIZE
in .bashrc to an empty string:そう.bashrcのHISTSIZE
とHISTFILESIZE
は空の文字列に設定されています.HISTSIZE=
HISTFILESIZE=
In bash 4.3 and later you can also use
HISTSIZE=-1 HISTFILESIZE=-1
:bash 4.3以降では、HISTSIZE=-1 HISTFILESIZE=-1
も使用できます.n. Setting HISTSIZE to a value less than zero causes the history list to be
unlimited (setting it 0 zero disables the history list).
o. Setting HISTFILESIZE to a value less than zero causes the history file size
to be unlimited (setting it to 0 causes the history file to be truncated
to zero size).
#3階
After many large, ugly iterations and weird edge cases over the years, I now have a concise section of my .bashrc dedicated to this. 長年にわたって多くの大型、醜い反復と奇妙なエッジ状況を経て、私は今これに特化しています.bashrcの簡潔な部分.
First, you must comment out or remove this section of your .bashrc (default for Ubuntu). まず、コメントを削除するか削除する必要があります.bashrcのこのセクション(Ubuntuのデフォルト).If you don't,then certain environments(like running
screen
sessions)will still truncate your history:そうしないと、screen
セッションを実行するなど、一部の環境では履歴が切断されます.# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
# HISTSIZE=1000
# HISTFILESIZE=2000
Second, add this to the bottom of your .bashrc:次に、それを追加します.bashrcの下部:
# Eternal bash history.
# ---------------------
# Undocumented feature which sets the size to "unlimited".
# http://stackoverflow.com/questions/9457233/unlimited-bash-history
export HISTFILESIZE=
export HISTSIZE=
export HISTTIMEFORMAT="[%F %T] "
# Change the file location because certain bash sessions truncate .bash_history file upon close.
# http://superuser.com/questions/575479/bash-history-truncated-to-500-lines-on-each-login
export HISTFILE=~/.bash_eternal_history
# Force prompt to write history after every command.
# http://superuser.com/questions/20900/bash-history-loss
PROMPT_COMMAND="history -a; $PROMPT_COMMAND"
Note: every command is written immediately after it's run, so if you accidentally paste a password you cannot just "kill -9 %%"to avoid the history write, you'll need to remove it manually. 注意:各コマンドは実行後すぐに書き込まれるため、パスワードを誤って貼り付けた場合は、履歴の書き込みを避けるために「-9%%を殺す」だけではいけません.手動で削除する必要があります.
Also note that each bash session will load the full history file in memory, but even if your history file grows to 10MB (which will take a long, long time) you won't notice much of an effect on your bash startup time. また、各bashセッションではメモリに完全な履歴ファイルがロードされますが、履歴ファイルが10 MBに増加しても(これには時間がかかります)、bashの起動時間に大きな影響を及ぼすことはありません.
#4階
There are(at least)two relevant env vars here:ここには少なくとも2つの環境変数があります.
#5階
As Jörg Beyer mentioned above,
HISTSIZE
and HISTFILESIZE
are key. HISTSIZE
が上述したように、HISTSIZE
およびHISTFILESIZE
が重要である.In addition, you should definitely check out the environmental variable
HISTCONTROL
, which lets you do cool things like not store duplicate history commands ( HISTCONTROL=erasedups
). また、環境変数HISTCONTROL
を確認する必要があります.重複した履歴コマンドを格納しないなど、クールなことをすることができます(HISTCONTROL=erasedups
).There's no point having unlimited history if you have to browse through hundreds of lines of cd ..
or similar. 数百行cd ..
などのコンテンツを参照する必要がある場合は、無限の歴史は意味がありません.Links: here , and working with bash history . リンク:ここでbash履歴を使用します.The bash Variable FAQ is also worth browsing . bash Variable FAQも閲覧する価値があります.