Run shell and type output
Open iTerm2 preferences and go to Profiles tab. Select your desired profile and go to Keys tab. Tap plus sign (+) and type the following:


Keyboard Shortcut: ⌘cmd+B
Action: Send Text
In the next line add the following command: git name-rev --name-only HEAD\n




After that, when you hit ⌘cmd+B, iTerm send that command to your terminal and will return your current branch.

$ git name-rev --name-only HEAD
master