Current behaviour is to switch profile when a rule matches, but the profile is not returned to the Default (or previous) profile when the rule no longer matches.
Example:
Profile directory rule: /Users/example/git
~ example$ cd gitgit example$ cd ~
Profile changes as expected when moving into the ~/git directory, but intuitively the new profile should no longer apply and the previous profile should be restored on leaving the directory (i.e., when the rule no longer matches). This is currently not the case.
The same example holds true for host- and user-based rules.
Designs
Child items
...
Show closed items
Linked items
0
Link issues together to show that they're related.
Learn more.
Interesting idea: so we'd treat APS as a stack of profiles, and when the current one is no longer matched we'd pop the stack until we find one that does (or run out of stack). Seems useful and also likely to break some use cases, but now's the time to break things :)
That's exactly what I had in mind. If current behaviour is desired for some use cases, perhaps an option would be to add a checkbox to make the profile "sticky"; once a sticky profile is selected it won't be popped if the rule no longer matches (but presumably another profile would replace it if a different rule matched).
Effectively when a sticky profile is triggered, you'd replace the current profile stack with a new one containing only the sticky profile and it becomes the new "default" for that session.
Conceptually it makes sense to think of this as a stack, but does this need to be implemented as such? I'm not familiar with the implementation of profile switching, but could one simply re-evaluate all the profile rules when the environment changes? If a profile no longer matches, presumably the next profile in the (conceptual) "stack" would still match so that would become the active profile anyway.
As your example -
SSH to A.
Set profile for A.
SSH to B.
Profile A no longer matches. Set profile B.
SSH to A. Profile B no longer matches. Set profile A.
The exception being that if you've previously applied a sticky profile, that profile isn't replaced with a new one (perhaps unless the newly matching profile is also sticky)
SSH to A.
Set profile for A.
SSH to B.
Profile A no longer matches but is sticky. Profile B not sticky; Keep profile A.
SSH to C. Profile A no longer matches but is sticky. Profile C is also sticky. Set profile C.
On second thoughts, I'm fairly sure what I described above is exactly equivalent to your proposed algorithm in terms of behaviour. Is there any benefit in keeping a history of applied profiles in the stack over re-evaluating the rules? Presumably the rules have to be checked again every time the environment changes in some way anyway?
The stack is a nice bit of polish when you make a temporary change to a session.
ssh example.com. APS triggers and now I'm my example.com profile.
I increase the font size with Cmd-+. Note that doing so does not modify the profile, but only changes the session's copy of the profile. Changes made with Edit > Edit Session… do this too.
ssh iterm2.com. APS triggers and now I'm on my iterm2.com profile.
Log out of iterm2.com.
Thanks to the stack, I return to the example.com profile modified to have a bigger font. If there were no stack, the font would revert to its default size. I think that violates the user's expectation.
The sticky profiles were in reference to my previous comment addressing your concerns that this may break some use cases; essentially a way to retain the previous behaviour.
Yes, of course. Well, let's see if we can get away without adding yet more complexity here. At least for the use cases that I have in mind this ought to work.
I, too, am strongly interested in the feature mentioned by Matt. Specifically, that changing (say) directories will trigger APS re-evaluation. That is, events will trigger the APS evaluation without reference to a stack, per se. If no specific rules match then the default profile should be activated.
Further, under this change, it would be good if the directory matching accepted wildcarding such that subdirectories will match a wildcard like "/Users/me/workspace/acme/*", but can be overridden by more specific directory specifications. Extending my example, setting an additional profile switch for "/Users/me/workspace/acme/documentation/admin/" could override the wildcard when going to this specific directory. Specificity wins.
I find I'm unable to use the switching in it's current form. (But I think that iTerm is fantastic overall - don't get me wrong)
@s5b I have a change to support wildcard directories in the works. It sounds like that's not sufficient for your case; can you give me an example of how?