We can use an AppleScript to both retrieve and set the profile of the foremost Terminal window:
echo 'tell application "Terminal" to return name of current settings of first window' | osascript
We can similarly set the profile:
echo 'tell application "Terminal" to set current settings of first window to settings set "Basic"' | osascript
Replace "Basic" with the name of the profile you wish to adopt.
These commands will apply to the current/foremost tab or window of Terminal.app
I've also written a script that will get/set the profile depending on whether a profile name is provided: https://github.com/starbase527/dotfiles/blob/master/local/bin/term-profile . Example usage:
# Gets profile name
> term-profile
Basic
# Sets profile to Basic
> term-profile Basic
>