Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
10
Help us understand the problem. What is going on with this article?
@hamaco

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

More than 5 years have passed since last update.

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

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
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
hamaco
<(-_-)>

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
10
Help us understand the problem. What is going on with this article?