I keep needing these commands when doing pi things, so I thought I'd put them here in one place:
# Edit the wifi config file
# e.g. to add a new router
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
# Reconfigure the wifi on the pi, reloading the config
sudo wpa_cli -i wlan0 reconfigure
# Check the status of the wifi connection
sudo wpa_cli -i wlan0 status