9
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Zsh の history を fish で使えるものに変換する

Last updated at Posted at 2017-04-05

Zsh => fish に移行するときに Zsh の history も移行したいときに変換したメモ。

fish の history ファイルは ~/.local/share/fish/fish_history にあるが、中を見ると基本的にコマンドとタイムスタンプを記録した YAML だったので Ruby のワンライナーで簡単に変換できた (パスの情報とかも含まれるようだったが無視した) 。

$ fc -lni 1 | ruby -rtime -r yaml -e 'puts STDIN.inject([]) { |a, l| a << { "cmd" => l[16..-1].strip, "when" => Time.parse(l[0..15]).to_i } }.to_yaml(options = { line_width: -1 })' > history-from-zsh.yml

これを Zsh で実行してできたファイルを ~/.local/share/fish/fish_history にコピー (もしくは合体) させればいい。

9
3
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
9
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?