Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is a super-clunky hack, but it works for copying the last line of output from the last run command in a terminal using only the keyboard (and a python script), and it can work over ssh.</p> <p>Here's how you use it.</p> <ol> <li>In gnome-terminal (or the like), Alt+E, A. This is to Select All.</li> <li>If you're in ssh, open a different terminal on your local machine.</li> <li>Run the attached script, which i call lastline on my machine.</li> </ol> <p>Then you've got one line of text with no newline on your gtk clipboard. The script works by using the x selection clipboard from selecting all the terminal's text and putting the third-to-last line of it on the gtk clipboard. This script can be modified to select different parts of the x selection, which would correspond to different parts of the terminal's text buffer. However, it's still a long ways from an interactive cursor :(</p> <p>It'd be great if gnome-terminal integrated keyboard-driven selection support.</p> <p>This example puts "/usr/bin/gcc" on the gtk clipboard (remember to Select All before running lastline):</p> <pre><code>$ which gcc /usr/bin/gcc $ lastline </code></pre> <p>Here's the script i call lastline:</p> <pre><code>#!/usr/bin/env python import sys, subprocess import optparse __version__ = "0.1" def main(): try: process = subprocess.Popen(["xsel"], stdout=subprocess.PIPE) except OSError: sys.exit("you must install xsel") (stdout, _) = process.communicate() lines = stdout.split("\n") if len(lines) &lt; 3: text = "" else: text = lines[-3] import gtk clipboard = gtk.clipboard_get() clipboard.set_text(text) clipboard.store() if __name__ == "__main__": parser = optparse.OptionParser(version=__version__) (options, args) = parser.parse_args() main() </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload