pecoを導入する際に参考にさせていただいた記事です。
http://qiita.com/samurai20000@github/items/8d77f4b5a503ca58b64e
一部うまくいかなかったので修正しました。
ansibleのunarchiveとcopyコマンドがlocalのファイルを扱うものだということが原因だと思います。
http://docs.ansible.com/ansible/unarchive_module.html
http://docs.ansible.com/ansible/copy_module.html
改修したやつ
playbook
- name: Get latest peco version
shell: >
curl -sI https://github.com/peco/peco/releases/latest | awk -F'/' '/^Location:/{print $NF}'
register: peco_latest_version
- name: Download latest peco
get_url: url=https://github.com/peco/peco/releases/download/{{ peco_latest_version.stdout }}/peco_linux_amd64.tar.gz dest=/tmp/peco_linux_amd64.tar.gz
register: download_peco
- name: Extract peco
when: download_peco.changed
command: tar zxvf /tmp/peco_linux_amd64.tar.gz chdir=/tmp/
- name: Copy to /usr/bin/
when: download_peco.changed
command: cp /tmp/peco_linux_amd64/peco /usr/bin/
- name: chmod peco
when: download_peco.changed
file:
path: /usr/bin/peco
mode: 0755
- name: Add peco-history
when: download_peco.changed
copy: src=.bashrc.j2 dest=/home/deployer/.bashrc
files/.bashrc.j2
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific aliases and functions
## peco-history
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}
}
if [ -t 1 ]
then
bind -x '"\C-r": peco-select-history'
fi
- これでCtrl+rでpecoコマンド使えると思います