Reading this changelog I discovered that htop has a config file and a config menu. I started using it years ago as a drop-in replacement for top and I never went beyond the default but there are some very nifty things hidden in the option, such as being able to display process trees and custom thread names among many other things.
If like me you never bothered to look into it just hit F2 in a running htop and start browsing the options.
Upvoted, this took me years to do myself. However, the config file annoys me now because every time I do something like toggling tree view with T or changing sort between CPU and memory with P and U it pops up in my dotfile repo’s list of modified files. I wish it only stored the stuff that’s buried down in the setup menu like what meters are at the top.
Agreed, I feel like there should be a way to mark changes as temporary instead of commiting to file every time.
I found a workaround that seems to work though, once you're happy with your defaults you can do:
chmod a-w ~/.config/htop/htoprc
This way you make the file read-only and prevent htop from changing it.
Also I had to add "vim_mode=1" directly in the rc file because I couldn't find the option in the menus.
Unfortunately it seems that git only stores the eXecutable bit of the files in the index, so you can't really commit a file as read-only, so you have to remember to do it one every one of your machines (or script it in a git hook I suppose).
I have an /etc/htoprc so I can maintain it with the same tool that maintains my other /etc config files. Unfortunately htop also copies this over to ~/.config/htop/htoprc on every startup even if I don't change any configs, and then it gets out of sync if I ever update /etc/htoprc.
Thank you! I might try this on some other things too.
mpv is one tool I think handles a kind of similar thing nicely: it has a main config file for long term settings, but also allows you to use Q instead of q to quit and save state (eg. playback position, speed, volume, etc.) in .config/mpv/watchlater/hashofurl (a separate file for each URL you play).
htop could save the single-keypress-changeable settings in, say, .config/htop/viewstate and only keep the other stuff that’s buried in the setup menu in the htoprc
Comments
Reading this changelog I discovered that htop has a config file and a config menu. I started using it years ago as a drop-in replacement for top and I never went beyond the default but there are some very nifty things hidden in the option, such as being able to display process trees and custom thread names among many other things.
If like me you never bothered to look into it just hit F2 in a running htop and start browsing the options.
Upvoted, this took me years to do myself. However, the config file annoys me now because every time I do something like toggling tree view with T or changing sort between CPU and memory with P and U it pops up in my dotfile repo’s list of modified files. I wish it only stored the stuff that’s buried down in the setup menu like what meters are at the top.
Agreed, I feel like there should be a way to mark changes as temporary instead of commiting to file every time.
I found a workaround that seems to work though, once you're happy with your defaults you can do:
This way you make the file read-only and prevent htop from changing it.Also I had to add "vim_mode=1" directly in the rc file because I couldn't find the option in the menus.
Unfortunately it seems that git only stores the eXecutable bit of the files in the index, so you can't really commit a file as read-only, so you have to remember to do it one every one of your machines (or script it in a git hook I suppose).
I have an /etc/htoprc so I can maintain it with the same tool that maintains my other /etc config files. Unfortunately htop also copies this over to ~/.config/htop/htoprc on every startup even if I don't change any configs, and then it gets out of sync if I ever update /etc/htoprc.
So I have a /usr/local/bin/htop that does
Thank you! I might try this on some other things too.
mpv is one tool I think handles a kind of similar thing nicely: it has a main config file for long term settings, but also allows you to use Q instead of q to quit and save state (eg. playback position, speed, volume, etc.) in .config/mpv/watchlater/hashofurl (a separate file for each URL you play).
htop could save the single-keypress-changeable settings in, say, .config/htop/viewstate and only keep the other stuff that’s buried in the setup menu in the htoprc
just fyi, classic top also has config file https://man7.org/linux/man-pages/man1/top.1.html#6._FILES