s-2_nw
Last Updated: June 07, 2016
·
4.086K
· erasmospunk
091c84731b4eb7e0f7613b9071c28771

Change iTerm2 color profile from the CLI

Have you ever worked with iTerm2 late in the evening with some dark colored tabs and the next morning you don't want to reopen them all with a different profile?

It turns out that iTerm2 can detect a printed special sequence and change the color profiles. To do it, simply put the following in you .bashrc or .zshrc (or any other shell you happen to use)

# Change iterm2 profile. Usage it2prof ProfileName (case sensitive)
it2prof() { echo -e "\033]50;SetProfile=$1\a" }

You're done! Just open a new tab and type it2prof DarkProfile or it2prof SomeOtherProfileName

Enjoy!

Say Thanks
Respond

5 Responses
Add your response

18700
None

It really helps!

over 1 year ago ·
18844
8b836ad1cd8807ca747fe5c5cf6e1839

thanks this is amazing

over 1 year ago ·
22564
29522427a9b95e331353b7f8379ff694

helps to also re-export ITERM_PROFILE if you're using it in anything else, i.e. vim to set a colorscheme there.

over 1 year ago ·
27758
Ec fish

Does this still work for iTerm 3.0? When just calling echo -e "\033]50;SetProfile=PROFILE_NAME\a" from the command line, where PROFILE_NAME is one of the names listed under Preferences > Colors > Color Presets..., it echoes a blank line but does not change the profile. I've tried everything from copying the name verbatim to replacing spaces with dashes or underscores to no avail.

over 1 year ago ·
27759
Ec fish

W.R.T my previous question, I made the foolish mistake of conflating iTerm color schemes with profiles. Once I made new profile with a different color scheme, this worked.

over 1 year ago ·
Filed Under