Created
April 12, 2022 17:15
-
-
Save dakyskye/65a5505aae5afb08db5880b7c045cacd to your computer and use it in GitHub Desktop.
rename nvim_ostheme.py to nvim_ostheme, put it in /usr/local/bin and update your .zshrc aliases
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias vim="/usr/local/bin/nvim_ostheme; nvim" | |
alias nvim="/usr/local/bin/nvim_ostheme; nvim" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import subprocess | |
import os | |
import re | |
if __name__ == '__main__': | |
cmd = 'defaults read -g AppleInterfaceStyle' | |
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) | |
theme = 'dark' if bool(proc.communicate()[0]) else 'light' | |
with open(f"{os.environ['HOME']}/.config/nvim/plugins.vim", "r+") as f: | |
content = f.read() | |
content = re.sub('set background=(light|dark)', f'set background={theme}', content) | |
f.seek(0) | |
f.truncate() | |
i = f.write(content) | |
if i != len(content): | |
print("it seems we didn't manage to fully write the vim config...") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment