Save current layout of top

<Shift + W>
'top' has fancy layout modes where you can have several windows with different things displayed. You can configure a layout and then save it with 'W'. It will then be restored every time you run top. E.g. to have two colored windows, one sorted by CPU usage, the other by memory usage, run top top then press the keys <A> <z> <a> <-> <a> <z> <a> <-> <a> and then as you don?t want to repeat this the next time: <W>

By: hfs
2009-09-23 13:51:22

What Others Think

v. nice tip!
Escher · 584 weeks and 1 day ago
Good tip! Bad top(1). That is, this tip is useful, but exemplifies why the user interface of top needs to be revamped. "" is not a command line, it's a keystroke for an interactive program, necessary to mention on because 'top' is actually very command line unfriendly. Qualification: In the following rant, I'm speaking of top from procps version 3.2.8. It's been bothering me for a long time that one of the first introductions people have to UNIX is with a program that doesn't follow the UNIX philosophy. Tools should be small and precise, not duplicating function; they should use each other's strengths and work together harmoniously in ways the original designer hadn't imagined. Top, as a command line tool, does not play well with others. For example, it irks me that I can't use $EDITOR to write the .toprc. Yes, I know it's ASCII, but what's the syntax? The manpage for top doesn't say, except to tell one to use 'W' in the interactive interface as if it was a binary file. Another problem with 'top' is that it allows only one configuration file per user. I want it to show fewer columns of information when I log in from a serial console with a 40x16 screen. I figured it'd be simple, a single line in .bashrc specifying some command line options. I was wrong. Top has no way to configure it from the command line and it only allows one configuration file, which *must* be called ".toprc" and *must* be in the user's home directory. I had to kludge around top's deficiencies by creating a fake $HOME directory containing a specially crafted ".toprc" in it. (Gross!) if [ "$TERM" = "td200" ]; then alias top='HOME=/root/.td200 top' fi Wait, did I say top has "no" way to configure it from the command line? I meant to say, top has a completely f'brain-damaged way of configuring it from the command line. The options are not absolute, but relative "toggles" which reverse the settings in the .toprc. So, instead of having one option to disable showing idle processes and another option to enable showing them, there is only "-i" which does both, and one can't know which without knowing the contents of the .toprc. Hmmm... this seems to be something that bothers me more than I thought. I've spent quite a bit of time cutting examples of problems in top to keep this rant short and it's still too long. Sorry about that.
hackerb9 · 576 weeks and 3 days ago
Erratum: The emptiness in quotes in my second sentence was supposed to be "〈Shift+W〉" in angle brackets. I wish commandlinefu had a preview button...
hackerb9 · 576 weeks and 3 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: