Is there a way to copy text in htop?

39

7

Normally in putty you can just select text to copy it, but I can't seem to select text with my mouse in htop.

Of course there's no right click menu to copy, ctrl+c doesn't work, and I didn't see any copy command in the help menu.

Is it possible to copy text in htop?

Nate

Posted 2014-09-10T21:36:38.587

Reputation: 1 125

You can select and copy text in top, though you have to be quick before the display changes. I don't know what terminal handling is in htop, but as you observe it seems to preclude selecting and therefore copying. I tried Ctrl-z and reset the terminal, but this didn't help when I restarted the task with fg. So at the moment I conclude that the answer to your question is "no". I am not sure why you want to copy text, but screen capture ought to work as a means to save an instantaneous state. – AFH – 2014-09-10T22:01:59.483

Answers

52

In my experience, holding Shift lets you select text in programs that have mouse support (of which htop is one, I assume).

jjlin

Posted 2014-09-10T21:36:38.587

Reputation: 12 964

4It is "alt" under mac – Romain Jouin – 2017-01-02T11:17:39.773

2One caveat, it can only copy visible text. It would still be useful to have a way to copy the command line from htop when it is much longer than the terminal width. – P-Gn – 2018-11-16T14:26:51.870

1

One approach to copy long lines from htop is the following:

step 1. Change the font size of your terminal to something very small (say 6pt).

step 2. Run htop and maximize window

step 3. Run your processes, switch to htop window and carefully do Ctrl + Shift + A to select everything, then release A and hit C (without releasing Ctrl + Shift). It might take some time to be able to do it (some of the times you might kill htop accidentally).

step 4. Open gedit or another text editor and Ctrl + V if the editor is a GUI or hit Ctrl + Shift + V if the editor opened on the terminal (for example nano).

pebox11

Posted 2014-09-10T21:36:38.587

Reputation: 111