From: Bernhard Tittelbach Date: Wed, 20 Jul 2011 16:44:54 +0000 (+0200) Subject: zshrc: provide screen hardcopy feature to complete word from words currently displaye... X-Git-Tag: v0.4.00~12 X-Git-Url: http://git.grml.org/?a=commitdiff_plain;h=8cd07c97d3060a4360418345e43bd5264ce68e15;hp=01fe02eb822310ffaace189928cfa9108c4fc1ab;p=grml-etc-core.git zshrc: provide screen hardcopy feature to complete word from words currently displayed in Screen. --- diff --git a/etc/zsh/zshrc b/etc/zsh/zshrc index abe6a22..1827e6b 100644 --- a/etc/zsh/zshrc +++ b/etc/zsh/zshrc @@ -1013,6 +1013,27 @@ zstyle ':completion:hist-complete:*' completer _history #k# complete word from history with menu bindkey "^X^X" hist-complete +## complete word from currently visible SCREEN buffer. +if check_com -c screen ; then + _complete_screen_display() { + [[ "$TERM" != "screen" ]] && return 1 + + local TMPFILE=$(mktemp) + local -U -a _screen_display_wordlist + trap "rm -f $TMPFILE" EXIT + + screen -X hardcopy $TMPFILE + # fill array with contents from screen hardcopy + _screen_display_wordlist=( ${(QQ)$(<$TMPFILE)} ) + # remove PREFIX to be completed from that array + _screen_display_wordlist[${_screen_display_wordlist[(i)$PREFIX]}]="" + compadd -a _screen_display_wordlist + } + #k# complete word from currently visible GNU screen buffer + bindkey -r "^XS" + compdef -k _complete_screen_display complete-word '^XS' +fi + # }}} # {{{ history