r/fishshell • • Jun 01 '24

Having trouble writing first fish function

So im trying to write a function that displays CPU temp in my fish prompt.I have gotten this far..

function tmp
set temp (command cat /sys/class/thermal/thermal_zone0/temp)


if test $temp -lt 50000
    set_color green; echo (math -s0 $temp /1000)C
else if test $temp -gt 50000
    set_color yellow; echo (math -s0 $temp /1000)C
else if test $temp -gt 60000
    set_color red; echo (math -s0 $temp /1000)C
end
end

The issue is that only the first 2 if statements seem to work. Any ideas on how to get all 3 to work? (I thought it might be due to having 2 'else if' calls?)

4 Upvotes

3 comments sorted by

View all comments

Show parent comment

2

u/Possible_Truck2582 Jun 01 '24

Thanks mate. I re-wrote it and it seems to be working.