
TCSHにコマンドライン履歴を保存しますが、頻繁に使用する単純なコマンド(例: "exit"、 "cd")がレコードに含まれないようにしたい(記録は固定数のコマンドだけを保存するので保存したい)。便利なコマンド)。
現在の履歴ファイルに追加されていないコマンドのリストである「除外リスト」を指定する方法はありますか?これにより、記録で最も関連性の高いコマンドのみを維持し、記録を妨げたくないコマンドをフィルタリングできます。
答え1
これはまさに望むものではありませんが、次のことが役に立ちます。
histdup (+)
Controls handling of duplicate entries in the history list. If set to `all' only unique his-
tory events are entered in the history list. If set to `prev' and the last history event is
the same as the current command, then the current command is not entered in the history. If
set to `erase' and the same event is found in the history list, that old event gets erased
and the current one gets inserted. Note that the `prev' and `all' options renumber history
events so there are no gaps.
したがって、.tcshrcに "set histdup = all"を入れると、履歴にはまだマイナーなコマンドが表示されますが、各コマンドのインスタンスは1つだけインポートされ、少なくとも混乱を減らすことができます。
答え2
bashの変数を意味する場合HISTCONTROL
とHISTIGNORE
HISTCONTROL=ignorespace
前にスペースがあるコマンドは履歴にロードされません。
HISTIGNORE=ls:cd:exit
リストされているすべてのコマンドが履歴に追加されるのを防ぎ、いいえ - その機能はtcsh自体にはありません
答え3
これに対する素晴らしい答えがあります。これは、各端末を終了する前にプログラムで記録をフィルタリングすることを含むことができる。ただし、これを行わないで、代わりにレコードサイズを増やしてください。シェル起動スクリプトで「set History = XXX」と「set savehist = YYY」を作成します。ここで YYY<=XXX です。 「記録」は、すべてのセッションにわたって保存されたコマンドとともにセッションに保存されたコマンドの数です(端末を閉じるときに保存されます)。バラよりhttp://unixhelp.ed.ac.uk/shell/tcsh_hist1.htmlそしてhttp://unixhelp.ed.ac.uk/shell/tcsh_hist2.html。
システム全体のデフォルト値を編集するには、tsch.defaults(/usr/share/init/tcsh/tcsh.defaults)を参照してください。次のようになります。
# History
set history = XXX
set savehist = YYY
set histfile = ~/.tcsh_history # History file