Is there a way to copy text in htop?
Solution 1
In my experience, holding Shift lets you select text in programs that have mouse support (of which htop
is one, I assume).
Solution 2
If it's a linux server I'd just use the ps -ef command and pipe it to grep. For instance if you wanted to check on a rsync command you'd do this:
ps -ef | grep rsync
And that would spit out any process with the word rsync in it. Though it always will include the grep search as well. To exclude that just run:
ps -ef | grep rsync | grep -v grep
This will exclude grep itself from the search results.
Remember, htop is great software, but it's not the best for grabbing really long strings of text. In that case use ps -ef
Solution 3
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).
Related videos on Youtube
Nate
I'm a senior in college, majoring in EE and minoring in CS, with a passion for electronics and programming. I'm an entrepreneur and started a small hobby electronics company called FoxyTronics a few years ago, and am now working on launching a shopping website called PriceWombat.
Updated on September 18, 2022Comments
-
Nate almost 2 years
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?
-
AFH almost 10 yearsYou 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 inhtop
, 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 withfg
. 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. -
Admin about 2 yearsCtrl + C in terminal? This terminates the running process.
-
-
Romain Jouin over 7 yearsIt is "alt" under mac
-
P-Gn over 5 yearsOne 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.
-
yurenchen over 4 yearsmagic operation : )
-
michal-michalak over 2 yearsIn my case it was
fn
key for MacOS 12.2 (Monterey), htop 3.1.2 that give me the ability to select text.