iwlist seem to be able to do this for me.
nm-tool | grep \*. That should show just the line with the SSID you are connected to.
nm-tool utility had ceased to exist, so in 16.04 and newer releases, please use any of the methods suggested by my esteemed colleagues below.
nmcli -t -f active,ssid dev wifi | egrep '^yes' | cut -d\' -f2 works well.
Although the question has already been answered, the iwconfig tool does display the ESSID of the currently connected Wifi network. Perhaps it does not work with connections managed through NetworkManager but it works with interfaces managed through ifup/ifdown:
iwconfig | grep wlan0
wlan0 IEEE 802.11bgn ESSID:"ahoi"
nmcli -t -f name connection show --active
shows the same output without listing all available SSIDs in vicinity so without delay. if more network interfaces are available and active can be parsed by interface name like so:
nmcli -t -f name,device connection show --active | grep wlp3s0 | cut -d\: -f1