10
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

zsh + tmux で端末に表示されてる文字列を補完する

Posted at

===============================================

zsh + screen で端末に表示されてる文字列を補完する - 2nd life の tmux 版。

tmux に移ったころもう不要だと思ってなにもしなかったけど、これ意外と使いたい時があるのよねぇ。

コピペして.zshrcにでも貼れば動くと思う。

HARDCOPYFILE=/tmp/tmux-hardcopy
touch $HARDCOPYFILE

dabbrev-complete () {
  local reply lines=80

  tmux capture-pane && tmux save-buffer -b 0 $HARDCOPYFILE && tmux delete-buffer -b 0
  reply=($(sed '/^$/d' $HARDCOPYFILE | sed '$ d' | tail -$lines))

  compadd -Q - "${reply[@]%[*/=@|]}"
}

zle -C dabbrev-complete menu-complete dabbrev-complete
bindkey '^o' dabbrev-complete
bindkey '^o^_' reverse-menu-complete

ほぼ、screen のコマンド部分を tmux に変えただけ。
一応変更点として、ファイル保存先 /tmp にしたのと~/Documentsみたいなのの~\~にならないようにしたはず。

10
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?