4
4

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 3 years have passed since last update.

bash/zshで「入力途中の履歴補完」(not インクリメンタルサーチ)

Last updated at Posted at 2020-05-25

インクリメンタルサーチは謎のモードに突入するのが面倒なので、
私は「入力途中の履歴補完」を利用する。

こちらを使うと、既に入力済みの内容以降をそのまま履歴補完してくれる。
(謎のモード遷移はない)

設定方法がイマイチまとまっていなかったので、
備忘録代わりに記載する

bash

.bashrc
bind '"\C-n": history-search-forward'
bind '"\C-p": history-search-backward'

# ついでに履歴の件数も上げておく
HISTSIZE=100000

zsh

こっちの情報がなかなか出てこず苦労した;

.zshrc
autoload history-search-end
zle -N history-beginning-search-backward-end history-search-end
zle -N history-beginning-search-forward-end history-search-end
bindkey "^p" history-beginning-search-backward-end
bindkey "^n" history-beginning-search-forward-end

# ついでに履歴の件数も上げておく
export SAVEHIST=100000

参考サイト

https://qiita.com/wankoromaru/items/92a85bd84bb3e3a08c71
https://qiita.com/isao_e_dev/items/8db0be6f2c1aacd30ed9
https://mollifier.hatenablog.com/entry/20090318/1237302243
https://qiita.com/syui/items/c1a1567b2b76051f50c4

4
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
4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?