Show current git branch in macbook pro touch bar?

528 views
Skip to first unread message

Michael Clagett

unread,
Jan 8, 2018, 7:57:04 PM1/8/18
to iterm2-discuss
Hi!  The touch bar documentation is very sparse.  It says the following:

If you install Shell Integration and Utilities, then you'll get a command it2setkeylabel that lets you configure what the status control says. For example, it could display the git branch of the current directory.

However, it does not really explain how to achieve that . Can anybody help me out?

Also how can I send the enter key in a "send text" touch bar command?  I'd like to have a touch bar key for "vagrant up<enter key>". 

George Nachman

unread,
Jan 12, 2018, 2:30:30 AM1/12/18
to iterm2-...@googlegroups.com
1. View > Customize Touch Bar
2. Drag "Your Message Here" button into the touch bar
3. Modify PS1 to include \[$(it2setkeylabel set status $message)\]. For example:

PS1='\s-\v\$\[$(~/.iterm2/it2setkeylabel set status $(git rev-parse --abbrev-ref HEAD))\] '

That's kind of rough because it won't do the right thing if the current directory isn't a git branch. So in practice you'll want something like

PS1='...\[$(~/bin/print_status)\]'

and a script ~/bin/print_status that outputs whatever you want to show in the touch bar, and can handle errors and so on.


To send the enter key, use the action "Send text with 'vim' special chars" and then you can use \n for newline.

--
You received this message because you are subscribed to the Google Groups "iterm2-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to iterm2-discuss+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages