itermocil icon indicating copy to clipboard operation
itermocil copied to clipboard

Using iTerm's profile

Open hisplan opened this issue 7 years ago • 4 comments

I've already set up a bunch of profiles in iTerm2 (pane name, badge, ssh command, colors, font, and etc.), and would like to reuse this profile by specifying in itermocil's yaml file. Is this possible?

hisplan avatar Apr 27 '17 13:04 hisplan

@hisplan If you mean you would like to be able to create a layout and have each pane/etc follow a different profile, I'm unclear if that is supported on itermocil's end.

A Risky Solution...

However, I was able to find a proprietary [CAUTIONED] iTerm command you can run to dynamically change profiles on the fly, and I believe (haven't tested) that this will work in the yaml.

^[]1337;SetProfile=NewProfileName^G Taken from here

So your yaml might look like this:

windows:
  - name: _tiled_4_panes
    root: ~
    layout: tiled
    panes:
      - ^[]1337;SetProfile=NewProfileName^G
      - ^[]1337;SetProfile=NewProfileName^G
      - ^[]1337;SetProfile=NewProfileName^G
      - ^[]1337;SetProfile=NewProfileName^G

Just replace the NewProfileName with what you need.

A Safer Solution...

...is to setup iTerm with Automatic Profile Switching via Shell Integration (same resource linked above, just search), and thereby avoid any unintended consequences when using tmux or other services. In this way, your terminal panes will adjust their profile based on available information, like the current directory etc. For instance this...

windows:
  - name: _tiled_4_panes
    root: ~
    layout: tiled
    panes:
      - cd js/
      - cd py/
      - cd tests/
      - [your editor command] ./README.md

...with automatic profile switching, would have your Javascript profile, Python profile, Testing profile, and Editing profile active in each of the respective panes, as iTerm would recognize the directory/file pattern without you needing to programmatically swap to the profile with a [CAUTIONED] escape code.

Cheers. If this solves your issue, please remember to close the issue!

jlhall avatar Jun 22 '17 20:06 jlhall

Just a 'me too' on the proposed solution. I use this function (gleaned from the web somewhere) to achieve the desired profile switch, as per the 'Risky' solution above. It is exported into my environment, and called in each iTermocil profile. I set the ITERM_PROFILE var on advice also gleaned from the web somewhere.

# it2prof PROFILENAME
it2prof() { echo -e "\033]50;SetProfile=$1\a"; export ITERM_PROFILE=$1 }

jonathanaamiller avatar Sep 21 '17 10:09 jonathanaamiller

did not seems to work under 3.1.5? Is is changed? @jonathanaamiller sorry, It is woking except for being in tmux

soulomoon avatar Jan 01 '18 09:01 soulomoon

I wanted a configuration that I wasn't able to get via itermocil, so I ended up creating itermp, which allows you to set the profile per pane.

Didericis avatar May 20 '18 03:05 Didericis