LoginSignup
20
11

More than 5 years have passed since last update.

どーしても忘れるbashシェルの履歴補完で前方一致

Last updated at Posted at 2017-02-08

はじめに

ターミナルで操作するUNIX系サーバーや、MAC...
新しく構築したり、買ったとき便利だから シェルの履歴補完で前方一致 を設定するのだが、いつもやり方というか、設定文字列をわすれる・・(´・ω・`)ショボーン

なので、覚え書きしておく・・・

あ・・・
これを設定すると、コマンドプロンプトにコマンドの途中まで入力し↑(上矢印キー)を押すたび、入力しかけたコマンド文字と同じ過去の入力したコマンドが表示されます。
過去のコマンドを再実行したいけど、全部覚えてなかったり、全部入力するのが手間なとき非常に便利です。

設定ファイル

以下のいずれか

  • ~/.bashrc
  • ~/.bash_profile

設定文字列

bind '"\C-n": history-search-forward'
bind '"\C-p": history-search-backward'
# 上矢印キー
bind '"\e[A": history-search-backward'
# 下矢印キー
bind '"\e[B": history-search-forward'

関係ないけど、いつもおまけにつけるalias設定

alias ll='ls -la'
alias h='history 25'

急いで反映させるには〜

  • source ~/.bashrc
  • source ~/.bash_profile

最後に

  • わすれんじゃねーぞ・・・
20
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
20
11