iterm2_print_user_vars

392 views
Skip to first unread message

Mike Cannon

unread,
Feb 21, 2016, 2:37:07 AM2/21/16
to iterm2-discuss

Build 2.9.20160206


I installed .iterm2_shell_integration.bash


I defined a Badge: Git: \(user.gitBranch)

and I see 'Git:', as expected since the user var isn't yet defined.


I put this my .bashrc  (same function, w/ 2 different names):

          # For iTerm2 v3

function iterm2_print_user_vars() {

  iterm2_set_user_var gitBranch $((git branch 2> /dev/null) | grep \* | cut -c3-)

}


function iterm2_set_user_vars() {

  iterm2_set_user_var gitBranch $((git branch 2> /dev/null) | grep \* | cut -c3-)

}

then Quit iTerm2 and open it again, and cd to a git repo.  I see the same 'Git:' badge.

I type 'iterm2_print_user_vars' into bash.  No error, no change in the badge.

I type 'iterm2_set_user_vars' into bash.  OK, now I see the badge: 'Git: master'

Is the function name 'iterm2_print_user_vars' special -- supposed to be invoked automatically between commands?

Even so, I don't see why the same function with a different name would work (if invoked manually).

Any help?

Thanks,

Mike

Mike Cannon

unread,
Feb 21, 2016, 1:30:55 PM2/21/16
to iterm2-discuss
Sorry to answer my own post but it seems this was just due to the order of loading .iterm2_shell_integration.bash vs defining my custom function iterm2_print_user_vars.  
It works fine for me when I define that function after loading .iterm2_shell_integration.bash.

Perhaps the default definition could be created only if there is not an existing function by that name.

George Nachman

unread,
Feb 25, 2016, 11:29:16 PM2/25/16
to iterm2-...@googlegroups.com
Good idea. I've updated the scripts for all the shells. I can't push it out yet because there are some other changes I'm testing first, but it should be live in a few days.

--
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-discus...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages