Completion of words on the screen as in VIM (Bash or Tmux)
I think that feature that OP is looking for is called dabbrev-expand in Emacs world:
Expand the word in the buffer before point as a dynamic abbrev, by searching in the buffer for words starting with that abbreviation (v-expand).
xterm
also has dabbrev-expand
feature but it's a bit less smart than Emacs counterpart but it's very useful to me and one was one of the reasons for which I switched to xterm
. Inside xterm
window one can use a custom keybinding specified in ~/.Xresources
to invoke dabbrev-expand
on a given string. For example, I have the following entry in my ~/.Xresources
(I use uxterm
, an Unicode version of xterm):
UXTerm*VT100.Translations: #override \n\
Meta <Key>/:dabbrev-expand() \n\
Inside xterm
window I can use M-/
(ALT + /
) to invoke dabbrev-expand
. xterm
will look for all strings visible on the screen that start with letters I typed. Example:
$ echo a_very_long_string bye by
$ a_v
If I pressed M-/
now xterm
would expand a_v
to a_very_long_string
. Unfortunately, as I said xterm
is not so smart and its dabbrev-expand
feature will only work on full strings. So, in your case is
would be expanded to issue540
and not issue547314
because issue547314
is a part of origin/issue547314
(think about it as \b
in regular expressions, it's a bit similar although most regular expressions engines would catch both occurrences of issue
strings in \bissue.+\b
). But, you can type or
and then pres M-/
. xterm
will first expand or
to origin/v2.1
, this is not what we want so press M-/
again and xterm
will expand it to origin/issue547314
. Now, if you use Bash you can do M-b
, C-w
and C-e
to remove origin/
part. To sum up, dabbrev-expand
inside xterm
is not as good as in Emacs (and Vim I guess) but it's still faster than rewriting long strings by hand and less typo-prone. And in most cases it will expand directly to the desired string without need to remove redundant parts. You just need to get used to it - look at string you want to have at cursor and see if it's not preceded by something else, and if it is type a preceding part and remove it after expansion.
Note that xterm
is not compiled with dabbrev-expand
feature by default and you have to enable it explicitly. However, version of xterm
in Ubuntu repositories is compiled with dabbrev-expand
and you can use it right away.