Last active
December 12, 2018 18:56
-
-
Save ericktucto/0bac5d7ac5ed4b677e471ac6a1358bb0 to your computer and use it in GitHub Desktop.
Script to change base16 shell themes
This file contains hidden or 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
def base16(arg): | |
# Helpers | |
def s(cmd): | |
return cmd.strip('\n') if type(cmd) is str else cmd | |
def l(cmd): | |
return cmd.split("\n")[:-1] if type(cmd) is str else cmd | |
def all_themes(): | |
for theme in l(s($(ls -1 $BASE16_SHELL/scripts))): | |
yield theme[7:-3] | |
# Declaration of variables | |
if not arg: | |
return 'Dont select theme. Write \033[0;32mlist\033[0;0m to list the themes.' | |
theme = arg[0] | |
if (theme == 'list'): | |
themes = [theme for theme in all_themes()] | |
return '\n'.join(themes) | |
script = $BASE16_SHELL + "scripts/base16-" + theme + ".sh" | |
# Checking if exist theme | |
if (isfile(script)): | |
bash @(script) | |
ln -fs @(script) ~/.base16_theme | |
$BASE16_THEME = theme | |
template = f"if !exists('g:colors_name') || g:colors_name != 'base16-{theme}'\n colorscheme base16-{theme}\nendif" | |
echo -e @(template) > ~/.vimrc_background | |
return True | |
else: | |
print("Not exists theme.") | |
return False | |
# TODO: Terminate Hooks | |
# code ... | |
aliases['base16'] = base16 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment