![]() ![]() As long as you're only using the light/dark variants of a single colorscheme, it should work decently.Īs you can see in this screenshot, it's not perfect (front is terminal, rear is MacVim - note the differences in the airline text, as well as the illegible block of black near the middle, which is supposed to be light text on a dark background), but it gets 99% of the way there without having to touch any vim/tmux/vim-airline settings. If in your light terminal color scheme, you invert the definitions of ANSI black & white ( i.e., set black/brightblack as the light background colors and white/brightwhite as the dark foreground colors), tmux and vim will follow suit. What I've found is that both tmux and vim borrow the 16 ANSI color values defined in your terminal color scheme (black, red, green, yellow, blue, magenta, cyan, white, and all their ‘bright’ variants). I've landed on an imperfect, hacky semi-solution, but from what I've gathered, taming terminal colors is not exactly a trivial problem. Thus the roundabout path of setting up keyboard shortcuts and using them to switch profiles. Just ways to create new tabs, windows, or splits with a specified profile, or get the (read only) name of the current session's profile. vimrc to make toggling even easier.ġ iTerm2 does have a proper AppleScript API of its own, however, I could not locate any means of directly changing the current tab's profile. You can, of course, add a mapping to your. Now, from within Vim, just run :SolarSwap and Vim, tmux, and iTerm2 should all toggle between Solarized Light and Dark. ! silently replaces any existing command of the same name. endfunctionĪnd finally, we close the function and define a command called SolarSwap, which calls the function we just made. Note that if you had two different shortcuts to switch iTerm2 you'll need to move this line up into the if's branches, and change the keystrokes to match. 1 You may need to modify the line to fit your choice of shortcut. The line that we're running is one to send that keyboard shortcut from step 2 to the active application, which should, as far as the operating system is concerned, be iTerm2. e means to execute the following argument as one line of a script. osascript will run some AppleScript for us. Silent !osascript -e 'tell app "System Events" to keystroke "s" using ' shellescape(expand('~/tmux-colors-solarized/nf')) shellescape(expand('~/tmux-colors-solarized/nf'))Įxecute "silent !tmux source-file ". vimrc, and optionally a command: function! Solar_swap()Įxecute "silent !tmux source-file ". Since we've set the 16 ANSI colors to the Solarized values in the iTerm2 profiles, we can use the standard Solarized color scheme, rather than the degraded 256 color version.Īdd a function to your. Install Solarized for Vim via your preferred method. I'll refer to it's location on your computer as ~/tmux-colors-solarized. I used the ones from this repository on Github. And I'm only showing Solarized Dark here, but don't forget to set it up for both profiles. Feel free to pick something different, but remember it, we'll need it later. In case you're not familiar with the glyphs, that's Control- Option- Shift- s. You can use different shortcuts if you want, you'll just need to make a small modification to a later step. I used the same shortcut for both, so it just toggles between them. The color presets are very helpful here, since they include both versions of Solarized.Īdd a keyboard shortcut to each profile to switch to the other (dark switches to light, light switches to dark). Set up two profiles in iTerm2's preferences, one with the Solarized Dark color scheme, and one with the Solarized Light color scheme. ![]() I've figured out a method to simultaneously toggle Solarized between light and dark for iTerm2, tmux, and Vim, with a single command from within Vim: ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |