Skip to content

Instantly share code, notes, and snippets.

@ericktucto
Last active December 12, 2018 18:56
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 ericktucto/0bac5d7ac5ed4b677e471ac6a1358bb0 to your computer and use it in GitHub Desktop.
Save ericktucto/0bac5d7ac5ed4b677e471ac6a1358bb0 to your computer and use it in GitHub Desktop.
Script to change base16 shell themes
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