LoginSignup
10
11

More than 5 years have passed since last update.

シェルの履歴を手動で保存する(`history -a`)[組み込みLinux用メモ]

Last updated at Posted at 2016-02-08

普段組み込みLinuxにて開発を行っているが、電源リセット時にshellの履歴が消えていることが多い。(シリアル接続のため?)
なのでshutdown前に履歴を手動で保存しておく。

履歴を手動で保存
$ history -a
$ sync

※syncも一応行っておく

bashであれば基本的に履歴は以下に保存されている。

履歴の保存先
# bashのデフォルト
$ ~/.bash_history

# 変更されている場合は以下で確認する
$ echo $HISTFILE

毎回使用するコマンドは予め ~/.bash_history に書いておくと履歴検索 C-r でほとんど済む。
組み込みLinux開発は環境ごと焼き直しが多いので開発用の ~/.bash_history は取っておいたほうが良いと思われる。

参考

bash - How to save terminal history manually? - Ask Ubuntu

その他 history コマンド に関する参考

シェルのコマンド履歴から再利用、のいろいろ - 元RX-7乗りの適当な日々
特定のコマンドをシェルの履歴に保存しない « サーバーワークス エンジニアブログ
bash - Is it possible to make writing to .bash_history immediate? - Ask Ubuntu

10
11
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
10
11