I was wondering if it would be possible to obtain the CPU temperature and embed it into the command prompt.
This is my output for sensors
:
$}-sensors
coretemp-isa-0000
Adapter: ISA adapter
Physical id 0: +55.0°C (high = +87.0°C, crit = +105.0°C)
Core 0: +55.0°C (high = +87.0°C, crit = +105.0°C)
Core 1: +52.0°C (high = +87.0°C, crit = +105.0°C)
Could you please show me how to use the grep
function to embed the temperature into my command prompt?
Best Answer
Yes, it is possible, but the details depend on your system. In most cases, the command
sensors
should show it.Install the necessary package
Run
sensors-detect
and follow the promptsInstall any extra drivers if
sensors-detect
tells you to.Run
sensors
to make sure it worksParse the output to get only the CPU temperature.
As you can see above, the output on my system is different than yours. However, the line we care about here is the same. You can get the CPU temperature with:
Edit your
~/.bashrc
(or equivalent file if you're using another shell) and add a function that runs the command above:Use the function in your prompt. For example: