LoginSignup
10

More than 5 years have passed since last update.

fish shell で history を複数端末間で共有

Posted at

fish 便利なんだけど複数端末感で history 共有できなくて、それだけで zsh に戻ろうかと思ってたけど、調べたら大体できた。

function history-merge --on-event fish_preexec
  history --save
  history --merge
end

--on-event fish_preexec でコマンド実行前に処理を挟めるので、そこで history を save して他のを merge してるだけ。

これだけだと peco での検索時に一回何か実行しないと反映されないので

function peco_sync_select_history
  history-merge
  peco_select_history $argv
end

function fish_user_key_bindings
  bind \cr 'peco_sync_select_history (commandline -b)'
end

みたいな感じで反映されるようにした。
だいたい満足なんだけど、もっといい方法あったら教えてもらいたいです!

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