LoginSignup
3
4

More than 3 years have passed since last update.

別シェル(bash)で履歴を共有

Last updated at Posted at 2018-05-06

~/.bashrcに以下スクリプト追加

 # セッションクローズ時の.bash_historyへの書き込みをoff
 shopt -u histappend
 # .bash_historyとメモリ上のコピーを頻繁に同期
 share_history(){
   history -a
   history -c
   history -r
 }
 PROMPT_COMMAND='share_history'

・historyオプション

-a : bashのセッションが開始されてから現在までに入力されたコマンド行を履歴ファイルに追加する
-c : コマンドの実行履歴を消去する
-r : 指定された履歴ファイルを読み出し,現在の履歴と置き換える

・PROMPT_COMMAND

関数やコマンドがセットされていると、Bash でプロンプトを表示する直前に、毎回それが実行される。

引用元:まんがでわかるLinux シス管系女子
引用元:http://tech.nikkeibp.co.jp/it/article/COLUMN/20060227/230795/

3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4