Skip to main content

Baty.net

A blog about everything by Jack Baty 👋

Tag: Fish

Zoxide and Fish Shell

I’m happy using Fish for my shell. One thing I’d not gotten around to after switching is finding a good directory jumper. The original z doesn’t work well with Fish. I used to use fasd and autojump, but thought I’d look around for something new.

For some reason, I’d never heard of zoxide: A smarter cd command. Combined with zoxide.fish: Tab completion and initialization for zoxide in fish shell, zoxide does the job nicely.

Adding weather to my Fish welcome message

Fish shell welcome message showing weather conditions

Fish shell welcome message showing weather conditions

For some reason, I always want to know the weather conditions. I barely go outdoors, but I still like to know what’s happening. I have a few shell scripts that kick out some version of the weather. Here’s the one I use most:

    #!/bin/sh
    # Jack Baty, 2023 (https://baty.net)
    # Grab and parse weather info using WeatherAPI.com
    
    jq=/opt/homebrew/bin/jq
    
    # Save the response to temporary file
    # TODO: shouldn't this just be a variable or something instead?
    weatherfile=`mktemp`
    curl -s "https://api.weatherapi.com/v1/forecast.json?key=[SNIP]&q=49301&days=1&aqi=no&alerts=no" > $weatherfile
    
    now=`${jq} -r .current.condition.text ${weatherfile}`
    temp=`${jq} -r .current.temp_f ${weatherfile}`
    condition=`${jq} -r .forecast.forecastday[0].day.condition.text ${weatherfile}`
    high=`${jq} -r .forecast.forecastday[0].day.maxtemp_f ${weatherfile}`
    low=`${jq} -r .forecast.forecastday[0].day.mintemp_f ${weatherfile}`
    
    echo "${now} ${temp} | Low ${low}, High ${high}"

Right now, this returns: Light snow 21.9 | Low 20.1, High 26.4