Skip to content

Instantly share code, notes, and snippets.

@hackugyo
Created October 10, 2018 09:40
Show Gist options
  • Save hackugyo/e7fd4af4e1876aab712030159d172921 to your computer and use it in GitHub Desktop.
Save hackugyo/e7fd4af4e1876aab712030159d172921 to your computer and use it in GitHub Desktop.
Goのpecoを使って,シェルスクリプトを簡単に選択する方法を作った
#!/bin/sh
# Goのpecoを使って,シェルスクリプトを簡単に選択する方法を作った
set -e # stop when an error happens
set -x # show commands in strderr before execute it
COMMANDS=$(cat <<'__EOT__'
ls
pwd
__EOT__
)
# COMMANDSをechoした結果をpecoして絞り、その結果をevalする
eval `echo "${COMMANDS}" | peco`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment