Skip to content

Instantly share code, notes, and snippets.

@johnelliott
Created December 15, 2018 03:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnelliott/e9d74409cfd825bf48894d20c0690895 to your computer and use it in GitHub Desktop.
Save johnelliott/e9d74409cfd825bf48894d20c0690895 to your computer and use it in GitHub Desktop.
vim macOS dark mode example
" capture the current interface style
let g:apple_interface_style=system("defaults read -g AppleInterfaceStyle")
" run code based on the current interface style
if g:apple_interface_style ==? "dark\n"
set bg=dark
elseif g:apple_interface_style ==? "light\n"
set bg=light
endif
" add leader commands to change after vim starts
nn <leader>d :!osascript -e "tell application \"System Events\" to tell appearance preferences to set dark mode to true"<CR><CR>
nn <leader>l :!osascript -e "tell application \"System Events\" to tell appearance preferences to set dark mode to false"<CR><CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment