LoginSignup
0
0

ctrl + r で検索しやすいようにpecoの導入

Posted at

pecoのインストールと設定手順

  1. /tmpディレクトリに移動します。

    cd /tmp
    
  2. pecoのバイナリをダウンロードします。

    wget https://github.com/peco/peco/releases/download/v0.5.3/peco_linux_amd64.tar.gz
    
  3. ダウンロードしたアーカイブを解凍します。

    tar -zxvf peco_linux_amd64.tar.gz
    
  4. 解凍したディレクトリに移動します。

    cd peco_linux_amd64/
    
  5. pecoバイナリをシステムの/usr/local/binディレクトリにコピーします。

    sudo cp peco /usr/local/bin/
    
  6. ~/.bashrcファイルを編集します。

    vi ~/.bashrc
    
  7. 以下の内容をファイルの一番下に追加します。

    peco-select-history() {
        declare l=$(HISTTIMEFORMAT= history | \
                    sort -k1,1nr | \
                    perl -ne 'BEGIN { my @lines = (); } s/^\s*\d+\s*//; $in=$_;
                            if (!(grep {$in eq $_} @lines)) { push(@lines, $in); print $in; }' |\
                    peco --query "$READLINE_LINE")
        READLINE_LINE="$l"
        READLINE_POINT=${#l}
    }
    bind -x '"\C-r": peco-select-history'
    
  8. ~/.bashrcを再読み込みして変更を反映させます。

    source ~/.bashrc
    
  9. Ctrl + rを押して、pecoが起動しコマンド履歴が表示されるか確認します。

スクリーンショット 2024-06-23 21.07.21.png

以上の手順を実行すれば、Cloud9環境にpecoを導入し、Ctrl + rでコマンド履歴を検索できるようになります。

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