I crafted a Bash prompt that, When the working directory is a Git repository, displays the name of the current repository. Besides, it contains the current ongoing task and the time spent doing it (from a homebrew timekeeping tool). This, of course, means that just displaying the prompt means running two processes.
This has the drawback that if the system is thrashing for whatever reason, it takes forever to get a prompt to do that necessary killall
to save the system, as just loading the git
binary is too much to ask of the system in such a state.
So, right now, the prompt is disabled by default, and only enabled on demand, but this is not that comfortable. It would be nicer to detect the load in .bashrc
, and only enable the prompt if the system is running fine (i.e. with acceptable disk latency).
In such situations, CPU is fairly cheap, only the disk is expensive. So I need a way that detects thrashing without depending on external utilities.
Hint: /proc
might have something useful. E.g. /proc/loadavg
would solve my problem if it were the CPU that causes the bottlenecks, not the disk.