Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am using the Solarized color scheme in iTerm2 and it comes with two themes: one with a light background for daytime hours and one with a dark background for nighttime hours.

I am currently switching between them by going to the iTerm2 preferences, clicking Profiles, then Colors, and finally selecting the theme from the Load Presets menu.

My question is: is there a way to bind this to a keyboard shortcut?

share|improve this question
2  
I’d love to know this as well :) –  mikl Apr 22 '12 at 20:21
    
As a hack you could write an apple script and bind it to a key in iterm. In general I think if they're just those 2 you could define different profiles and just redefine one of the shortcut keys in iTerm to switch to that (you can use any menu item). –  ranman Aug 16 '12 at 6:42
    
@ranman As far as I can tell, selecting a different profile from the menu item creates a new shell using that profile; it doesn't change the color scheme on your existing shells. Am I missing something? –  toasterlovin Aug 16 '12 at 17:16
add comment

2 Answers 2

Note: This is not a complete solution, since it isn't entirely keyboard based, but it's the fastest method I have found to switch between color schemes. Hopefully others find it useful.

  1. Create a profile for each color scheme you want to use (iTerm -> Preferences -> Profiles)
  2. Switch between profiles in your current session (Command-I or View -> Edit Current Session)

One keyboard chord and one mouse click.

share|improve this answer
add comment

Here's what I'm doing to solve this issue. This won't be a good solution if you don't use tmux or screen because it involves quitting and relaunching iTerm. In Preferences -> General there is a checkbox for "Load preferences from a custom folder or URL." Check that box and save your settings (make a copy of ~/.iterm). Then change to the other color scheme and save again. Then I made a script that toggles between the two. If you're using tmux, iTerm quitting and reopening is totally inconsequential so it works for me.

pkill iTerm
sleep 0.2
rm -r ~/.iterm

if [[ -z $SOLARIZED_TOGGLE ]]; then
    export SOLARIZED_TOGGLE=1
fi

if [ $SOLARIZED_TOGGLE = "1" ]; then
    cp -rf ~/.iterm_dark ~/.iterm
    export SOLARIZED_TOGGLE=0
else
    cp -rf ~/.iterm_light ~/.iterm
    export SOLARIZED_TOGGLE=1
fi

env -i open -a iTerm
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.