Guest User

Untitled

a guest
Jun 19th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. __get_tmux_pane_contents() {
  2. local cmd='for pane in `tmux list-panes -F "#{pane_id}"`; do tmux capture-pane -p -t $pane; done'
  3. for word in `eval "$cmd"`; do
  4. if [ ${#word} -ge ${FZF_MIN_WORD_LENGTH:-4} ]; then
  5. echo "$word"
  6. fi
  7. done | awk '{ print length, $0 }' | sort -rn | cut -d' ' -f2- | uniq
  8. }
  9.  
  10. __tmux_pane_sel() {
  11. setopt localoptions pipefail 2> /dev/null
  12. __get_tmux_pane_contents | FZF_DEFAUL_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse $FZF_DEFAULT_OPTS" $(__fzfcmd) -m "$@"
  13. local ret=$?
  14. echo
  15. return $ret
  16. }
  17.  
  18.  
  19. fzf-complete-pane-widget() {
  20. LBUFFER="${LBUFFER}$(__tmux_pane_sel)"
  21. local ret="$?"
  22. zle redisplay
  23. typeset -f zle-line-init >/dev/null && zle zle-line-init
  24. return $ret
  25. }
  26.  
  27. zle -N fzf-complete-pane-widget
  28. bindkey '^X^A' fzf-complete-pane-widget
Add Comment
Please, Sign In to add comment