å æ¥ãshellåå¼·ä¼ã§ãzawã使ã£ã¦ã·ã§ã«æä½ãå¿«é©ã«ãã¨ããã話ãè´ãã¦ãèªåãããå°ããã®ãããã®ç°å¢ãæ´ããããã¨æãç«ã£ãã
èªåã使ãé¸æãããã®ã¯ zaw ã§ã¯ãªã percol ã
軽ã調ã¹ã¦ã¿ããããã§ã¯ zawã£ã¦ã®ã¯è¨å®ãã¦ãã(ãããã¯èªä½ãã)決ããããsourceã使ã£ã¦æ±ºããããæä½ãè¡ããã®ã§ãzshã«å¯æ¥ã«çµã³ä»ãã¦ãããã¼ã«ã§ãpercolã¯ããããã®ã§ã¯ãªãç´ç²ã«ãå
¥åããã£ã«ã¿ãªã³ã°ãããã ãã®ãã¼ã«ãªã®ã§ããã¤ããªã©ã使ã£ã¦åã³ãã³ãã¨çµã¿åããããã¨ã§è²ã
ãªä½¿ãæ¹ãã§ãããã
percolã®å°å ¥
Python製ã®ãã¼ã«ãªã®ã§ãsudo pip install percol
ã¨ãã§å
¥ãã
READMEã«æ¸ãã¦ããéãã~/.percol.d/rc.py
ã«è¨å®ãã¡ã¤ã«ãç¨æãããã¨ã§ããã³ããããã¼ããããã«ã¹ã¿ãã¤ãºã§ããã
èªåã¯ã§ããã ãEmacsã® helm ã¨åããããªæä½æã«ãããã ãããªãããã«ãã¦ä½¿ã£ã¦ãã
percol.view.PROMPT = ur"<green>Input:</green> %q" percol.view.RPROMPT = ur"[%i/%I]" percol.import_keymap({ "C-f" : lambda percol: percol.command.forward_char(), "C-b" : lambda percol: percol.command.backward_char(), "C-p" : lambda percol: percol.command.select_previous(), "C-n" : lambda percol: percol.command.select_next(), "C-h" : lambda percol: percol.command.delete_backward_char(), "C-d" : lambda percol: percol.command.delete_forward_char(), "C-k" : lambda percol: percol.command.kill_end_of_line(), "C-a" : lambda percol: percol.command.beginning_of_line(), "C-e" : lambda percol: percol.command.end_of_line(), "C-v" : lambda percol: percol.command.select_next_page(), "M-v" : lambda percol: percol.command.select_previous_page(), "C-j" : lambda percol: percol.finish(), "C-g" : lambda percol: percol.cancel(), })
ã¡ãªã¿ã«ãç¾å¨ããã¨åæ§ãªãã¼ã«ã¨ãã¦goã§æ¸ãããpeco
ã¨ãããã®ãä½ããã¦ããã®ã§ãããããããå°æ¥çã«ãã¡ãã«ç§»è¡ãããããããªãã
percolã§ã³ãã³ãå±¥æ´ã®æ¤ç´¢ã»çµãè¾¼ã¿
READMEã«æ¸ãã¦ããããã©ã
ã·ã§ã«ã®historyãpercolã«æµãè¾¼ããã¨ã§ ããç´ æ©ãç°¡åã«ã³ãã³ãå±¥æ´ãé¡ããã
zshã®å ´åã¯fc -l -n 1
ã§å
¨å±¥æ´ã表示ã§ãããã®ããªã
function percol_select_history() { local tac if which tac > /dev/null; then tac="tac" else tac="tail -r" fi BUFFER=$(fc -l -n 1 | eval $tac | percol --query "$LBUFFER") CURSOR=$#BUFFER # move cursor zle -R -c # refresh } zle -N percol_select_history bindkey '^R' percol_select_history
ã¨è¨å®ãæ¸ãã¦ããã°ãCtrl+Rã§ã®å±¥æ´æ¤ç´¢ãanything likeã«å¿«é©ã«è¡ããã¨ãã§ããã
ãã¨ãéè¤ããã³ãã³ãå±¥æ´ã¯å¿
è¦ãªãã®ã§
setopt hist_ignore_all_dups
ãæå®ãã¦ãããã
percolã§ãã£ã¬ã¯ããªç§»å
ã®è¨äºã®éãããä¸åº¦ã§ãcdãããã¨ã®ãããã£ã¬ã¯ããªã«å¹çããcdãããããã«ã autojump ã z ã使ããã¨ãpercolã§ãã£ã¬ã¯ããªè¨ªåå±¥æ´ãçµãè¾¼ãã§é¸æãã¦ç§»åãã¨ãããã¨ãã§ããã
自分はしばらくzを使ってきてた ãã©ãpercol使ã£ãã»ããå
¨ç¶ä¾¿å©ã ãï¼
ä¸è¨åç
§è¨äºã§ã¯chpwd_functions
ã«å±¥æ´ã®è¨é²ãä»è¾¼ãã§ããããã©ãz.shã使ã£ã¦ããã°å±¥æ´ãã¼ã¿ã~/.z
ã«æ®ã£ã¦ããã®ã§ æè§ãªã®ã§ããã使ããã¨ã«ããã
function percol_select_directory() { local tac if which tac > /dev/null; then tac="tac" else tac="tail -r" fi local dest=$(_z -r 2>&1 | eval $tac | percol --query "$LBUFFER" | awk '{ print $2 }') if [ -n "${dest}" ]; then cd ${dest} fi zle reset-prompt } zle -N percol_select_directory bindkey "^X^J" percol_select_directory
_z -r
ã§ã©ã³ãã³ã°é ï¼ã«sortããã¦æè¿è¨ªåãããã£ã¬ã¯ããªä¸è¦§ãåºåãããã®ã§ããããpipeã§percolã«æ¸¡ãã¦é¸æã
percolã§tmuxã®windowé¸æã»åãæ¿ã
ãããREADMEã«æ¸ãã¦ããããã©ã
bind b split-window "tmux lsw | percol --initial-index $(tmux lsw | awk '/active.$/ {print NR-1}') | cut -d':' -f 1 | xargs tmux select-window -t"
ã®ããã«tmux.conf
ã«æ¸ãã¦ããã¨ãtmuxã®ç¾å¨ã®sessionã§éãã¦ããwindowãpercolã§çµãè¾¼ã¿ãé¸æãã¦åãæ¿ããã§ããã
ããã©ã«ãã§"w"ãã¼ã«bindããã¦ããtmux choose-window
ã§ãä¼¼ããããªãã¨ãåºæ¥ãã®ã ãã©ãwindowæ°ãå¤ãã¨ãã«percolãªãã¤ã³ã¯ãªã¡ã³ã¿ã«ã«çµãè¾¼ã¿ãã§ããã®ã¨ãtmux split-window
ã使ããã¨ã§ç¾å¨ã®windowãé ãããã¨ãªãé¸ææä½ãã§ããããã«ãªãã®ãå©ç¹ã ã¨æãã
ã¡ãªã¿ã«ãtmux list-windows
ã§è¡¨ç¤ºãããæ
å ±ã¯window nameãpaneæ
å ±ã ã£ããããã®ã ãã©ãpercolã§çµãè¾¼ãã¨ããªã©ã¯ç¹ã«ããã®windowã¯ã©ã®ãã£ã¬ã¯ããªã§ä½æ¥ãã¦ãããã®ãããªã©ããã£ãæ¹ãå¬ããã®ã§ã
tmux list-windows -F '#{window_index}: #{window_name}#{window_flags} (#{window_panes} panes) #{pane_current_path} #{?window_active, (active),}
ã®ããã«#{pane_current_path}
ãå«ãformatãæå®ãã¦è¡¨ç¤ºãããããã«ãããæçµçã«tmux.confã«ã¯
bind-key C-t split-window -c '#{pane_current_path}' "tmux list-windows -F '#{window_index}: #{window_name}#{window_flags} (#{window_panes} panes) #{pane_current_path} #{?window_active, (active),}' | percol --initial-index $(tmux lsw | awk '/active.$/ {print NR-1}') | cut -d':' -f 1 | xargs tmux select-window -t"
ã¨(é·ãï½)ã
ãã¨ãwindow nameã«ã¯é常ã¯å®è¡ä¸ã®ã³ãã³ãåã表示ããã¦ããã®ã ããã©ãssh
ã§ä»hostã«ãã°ã¤ã³ãã¦ããå ´åã¯ãã "ssh"ã¨ã ãåºãã®ã§ã¯ãªã ãã®hostæ
å ±ãªã©ã表示ããããã«ããæ¹ãåãããããã誤æä½ãé²ããããã¨ãããã¨ã§
ãªã©åèã«ãã¤ã¤ãèªåã§ã¯sshã³ãã³ããã©ããããã·ã§ã«ã¹ã¯ãªãããç¨æããã
#!/bin/sh if [ -n "$TMUX" ]; then local_command='tmux rename-window $(echo "%r@%n(%h:%p)")' fi command -p ssh -o PermitLocalCommand=yes -o LocalCommand="${local_command}" "$@" if [ -n "$TMUX" ]; then tmux set-window-option -u automatic-rename fi
tmuxä¸ã§sshãå©ããã¨ãã ããæ¥ç¶å
ã®hoståãªã©ã®æ
å ±ãå«ãwindow nameã«æ´æ°ããçµäºãããå
éãã«ãtmux rename-window
ã§å¤æ´ããå ´åã¯automatic-rename
ãªãã·ã§ã³ãoffã«ãªããããªã®ã§ããããæ»ãã¦ãããã®ãæ£ãã復å
æ¹æ³ã ã¨æãã
percolã§weechatã®bufferé¸æ
IRCç°å¢ã¨ã㦠weechatを使っている ããã©ãããã®channelé¸æãªãããpercolã§ã§ããã¨å¬ããã
ã®è¨äºãçä¼¼ã¦ã¿ããã¨ããã
WeeChat ã¯ããã©ã«ãã§Fifo pluginãæå¹ã«ãªã£ã¦ãã¦ãèµ·åä¸ã®weechatã«å¯¾ãã¦ä»»æã®ã³ãã³ããéããã¨ãã§ããã
ãããå
é¨ã®æ
å ±ãåå¾ãããããªãã¨ã¯ã§ããªããã§ããããã¨ããã¨ãããã£ãæ©è½ãæã¤pluginãä½ããªãå°å
¥ãããªãããå¿
è¦ãããããã ã£ãã
è¦èã®çã¨ãã¦ããã³ãã³ãéä¿¡ã«ãã£ã¦ç¾å¨ã®channel(buffer)ä¸è¦§æ
å ±ããã¡ã¤ã«ä¿åããããã®ãã¡ã¤ã«ãèªã¿è¾¼ããã¨ããæ¹æ³ã§ä¸è¦§ãåå¾ãããã¨ã«ããã
for fifo in $HOME/.weechat/weechat_fifo_*; do echo '*/mute layout store' > $fifo echo '*/mute save weechat' > $fifo done
ã®ããã«FIFO pipeã«å¯¾ãlayout store
ã¨save
ãéããã¨ã§ãç¾å¨ã®bufferæ
å ±ã~/.weechat
以ä¸ã«ä¿åããã(æ¯åãã®çµæãweechatã®bufferã«åºåãããã®ãé²ãããã«mute
ã³ãã³ãçµç±ã§)ã
ãã¨ã¯ããã§ä¿åãããè¨å®ãã¡ã¤ã«ãèªã¿è¾¼ãã§percolã«æ¸¡ããé¸æçµæã使ã£ãbufferåãæ¿ãã³ãã³ããå度FIFO pipeã«æµãã°ããã
BUFFER=$(grep 'default.buffer' $HOME/.weechat/weechat.conf | cut -d'"' -f2 | percol | cut -d';' -f3) if [ -n "$BUFFER" ]; then for fifo in $HOME/.weechat/weechat_fifo_*; do echo '*/mute buffer' $BUFFER > $fifo done fi
ããã§ã ãã¶æãã