[twitter:@stillpedant](mooz)ããä½ã®percolã¯ã·ã§ã«ã¨ã¯ç¬ç«ãã¦ããã®ã§ãããã°ã°ãã¨zshã¨å ±ã«ä½¿ã£ã¦ãã人ãå¤ãããã§ããããã¯zshã®å¼·åãªè¡ç·¨éæ©è½ãæä¾ããzleã«å ãã¨ããã大ããããã ã¨æãã¾ãã
bashã§ãpercolã使ã£ã¦ãã人ãããã®ã§ããã
- percolã便å©ã ãã©ãå ¥ããã«ã¯python2ç³»ã®ã»ããè¯ããã - About Digital
- Big Sky :: Windows ã®ã³ãã³ãããã³ããã10å便å©ã«ããã³ãã³ããpecoã
ãçµãè¾¼ãã ãã¹ã¸ã®cdãå®è¡ããããã¨ã¯ã§ãã¦ãããçµãè¾¼ãã ãã¹ãç¾å¨ã®ã³ãã³ãã©ã¤ã³è¡ã«æ¿å ¥ããããã¨ã¯å®ç¾ã§ãã¦ããªããã¤ã¾ãã³ãã³ãå®è¡ã¯ã§ãããã©è¡ç·¨éã¯ã§ãã¦ããªãããã§ããã
ããã§ä»åã¡ãã£ã¨èª¿ã¹ã¦ã¿ãã¨ãããbashã§ãï¼zleã«ã¯åã°ãªãã«ãã¦ãï¼å¤æ°READLINE_LINEã¨READLINE_POINTã§è¡ç·¨éã§ãããã¨ãããã£ãã®ã§ç´¹ä»ãã¾ãããã ããbash 4以ä¸ãå¿ è¦ã§ãã
READLINE_LINEã¨READLINE_POINT
READLINE_LINEã«ã¯ç¾å¨ã®ã³ãã³ãè¡ã®å 容ããREADLINE_POINTã«ã¯ã«ã¼ã½ã«ã®ä½ç½®ãæ ¼ç´ããã¾ãã
ä¾ãã°ã
_readline_test() { { echo "LINE=$READLINE_LINE" echo "POINT=$READLINE_POINT" } >&2 } bind -x '"\C-xx":_readline_test'
ã¨ãã対話ã·ã§ã«ä¸ã§ C-x x ãæã¤ã¨ãã®ãããªçµæã«ãªãã¾ãããâ ãã®ä½ç½®ãã«ã¼ã½ã«ã®ä½ç½®ã示ãã¾ãã
$ â LINE= POINT=0 $ foo bar bazâ LINE=foo bar baz POINT=11 $ foo barâ baz LINE=foo bar baz POINT=7
percol --query ã« $READLINE_LINE å ¨ä½ããã㯠$READLINE_POINT ã¾ã§ã®é¨åæååã渡ãã°ãæ¤ç´¢æååãå ¥ã£ãç¶æ 㧠percol ãå¼ã¶ãã¨ãã§ãããã§ãã
ã¾ããã® READLINE_LINE 㨠READLINE_POINT ã¯å¤æ´ãããã¨ãã§ãã¾ããå¤æ´ããå ´åã対話ã·ã§ã«ä¸ã®ã³ãã³ãã©ã¤ã³è¡ããã®å 容ã¨ã«ã¼ã½ã«ã®ä½ç½®ã«å¤æ´ã§ãã¾ãã
ä¾ãã°ã
_readline_test() { READLINE_LINE="$READLINE_LINE hok" READLINE_POINT=${#READLINE_LINE} } bind -x '"\C-xx":_readline_test'
ã¨ããå ´åãC-x x ãæ¼ã度ã«ã hokãã追å ããã«ã¼ã½ã«ãè¡æ«ã«ç§»åããã¯ãã§ãã
ç¶ãã¦ã¯å®ä¾ã§ãã
ã³ãã³ããã¹ããªã¼
C-r ã percol ã使ããã®ã«ç½®ãæãã¦ãã¾ãã念ã®çºãC-r ã ã£ã reverse-search-history ã C-x r ã«å½ã¦ã¦ãã¾ãã
ãã¹ããªã¼ã¯percolã®çµæã§å®å ¨ã«ç½®ãæãã¦æ¬²ããã®ã§ãREADLINE_LINEã«ã¯ãã®ã¾ã¾çµãè¾¼ã¿çµæãä»£å ¥ããREADLINE_POINTã«ã¯ãã®é·ããä»£å ¥ãã¦ãã¾ãã
_replace_by_history() { local l=$(HISTTIMEFORMAT= history | tac | sed -e 's/^\s*[0-9]\+\s\+//' | percol --query "$READLINE_LINE") READLINE_LINE="$l" READLINE_POINT=${#l} } bind -x '"\C-r": _replace_by_history' bind '"\C-xr": reverse-search-history'
gitã®ãã£ã¬ã¯ããª{ ã«cd | ãæ¿å ¥ }
èªå㯠git clone ãããã£ã¬ã¯ããªã¯ ~/repos ã®ç´ä¸ãããã¯1é層ãµããã£ã¬ã¯ããªãæã£ãä¸ã«ç½®ãã¦ããã®ã§ãpercolã§ãããçµãè¾¼ãã·ã§ã«é¢æ°ã¯ãã®ããã«ãªãã¾ãã
_select_gitdir() { find ~/repos -maxdepth 3 -type d -a -name '.git' | \ sed -e 's@/.git@/@' | \ percol }
ããã¸ç§»åãããå ´åã¯ãåç´ã«cdããã°ããã§ãã
_cd_gitdir() { cd "$(_select_gitdir)" } bind '"\C-xg": "_cd_gitdir\n"'
次ã«ãã³ãã³ãã©ã¤ã³è¡ã®ç¾å¨ã®ã«ã¼ã½ã«ä½ç½®ã«ãçµãè¾¼ãã git ãã£ã¬ã¯ããªã®ãã¹ãæ¿å ¥ããå ´åã¯ãã®ããã«ãªãã¾ãã
ç¾å¨ã®è¡ã®å 容ã®ã«ã¼ã½ã«ä½ç½®ã®ã¨ããã«çµãè¾¼ãã çµæãæãã§ãã«ã¼ã½ã«ä½ç½®ãæãã æ«å°¾ã«ç§»åãã¦ãã¾ãã
_insert_gitdir() { local l=$(_select_gitdir) READLINE_LINE="${READLINE_LINE:0:$READLINE_POINT}${l}${READLINE_LINE:$READLINE_POINT}" READLINE_POINT=$(($READLINE_POINT + ${#l})) } bind -x '"\C-x\C-g": _insert_gitdir'
æè¿ç§»åãããã£ã¬ã¯ããªã®å±¥æ´
èªåã¯æãã Bash ã®å°æé ã§ç´¹ä»ããã¦ãã cdhist.sh ã使ã£ã¦ãã¾ããããã使ã£ã¦ããã¨é åå¤æ° CDHIST_CDQ ã«æè¿ç§»åãããã£ã¬ã¯ããªãè¨é²ããã¦ããã®ã§ãpercolããå©ç¨ãã¦ã¿ã¾ãã
_cd_cdhist() { cd "$(for i in "${CDHIST_CDQ[@]}"; do echo $i; done | percol)" } bind '"\C-xj": "_cd_cdhist\n"'
screenã®ã¢ã¯ãã£ãwindowãé¸æãã
screen 4.1以ä¸ãªã -Q windows ã§ãªã¹ããåãããããªã®ã§ããã§ã§ãããã§ãã
ãã諸è¬ã®äºæ 㧠tmux ã«ä¹ãæãä¸ã§ãï¼ï¼
tmux ã®ä¾ã¯ https://github.com/mooz/percol#tmux ãã©ããï¼
peco
goã§æ¸ããã peco ã¨ããã®ãããããã§ãã
ãã¤ããªã ãã³ãã¼ããã°ä½¿ããã®ã§ãããããªç°å¢ã§ä½¿ãããå ´åã¯ããããããã¾ãããï¼