Skip to content

Commit

Permalink
add theme(1) script to change between light & dark
Browse files Browse the repository at this point in the history
  • Loading branch information
sunaku committed Oct 18, 2014
1 parent ad5f5d0 commit 4bdf5a7
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .tigrc → .tigrc.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# this file was generated from <%= __FILE__ %> by ~/bin/theme

<% if ENV['theme'] == 'dark' %>
color cursor black green
color title-blur black blue
color title-focus black blue
<% end %>

# http://who-t.blogspot.com/2009/04/git-format-patch-for-single-commit.html
bind generic E !git format-patch -1 %(commit)
Expand Down
21 changes: 20 additions & 1 deletion .tmux.conf → .tmux.conf.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# this file was generated from <%= __FILE__ %> by ~/bin/theme
<% theme = File.read(File.expand_path('~/.theme')).chomp.to_sym %>

bind-key R source ~/.tmux.conf \; display-message 'config reloaded!'

#-----------------------------------------------------------------------------
Expand Down Expand Up @@ -31,6 +34,16 @@ set-option -ag terminal-overrides 'rxvt-unicode*:sitm@'
# Colors from the "lucius" and "bubblegum" themes in the vim-airline plugin:
# https://github.com/bling/vim-airline/blob/master/autoload/airline/themes/lucius.vim
# https://github.com/bling/vim-airline/blob/master/autoload/airline/themes/bubblegum.vim
<% case ENV['theme'] when 'light' %>
set-option -g pane-border-fg colour253 # lucius normal airline_c
set-option -g pane-border-bg colour253 # lucius normal airline_c
set-option -g pane-active-border-fg colour250 # lucius normal airline_b
set-option -g pane-active-border-bg colour250 # lucius normal airline_b
set-option -g status-fg colour238 # lucius normal airline_c
set-option -g status-bg colour253 # lucius normal airline_c
set-window-option -g window-status-current-fg colour231 # lucius visual airline_a
set-window-option -g window-status-current-bg colour67 # lucius visual airline_a
<% when 'dark' %>
set-option -g pane-border-fg colour237 # lucius normal airline_c
set-option -g pane-border-bg colour237 # lucius normal airline_c
set-option -g pane-active-border-fg colour241 # lucius normal airline_b
Expand All @@ -39,6 +52,7 @@ set-option -g status-fg colour188 # lucius normal airline_c
set-option -g status-bg colour238 # lucius normal airline_c
set-window-option -g window-status-current-fg colour236 # bubblegum normal airline_a
set-window-option -g window-status-current-bg colour146 # bubblegum s:cterm_purple
<% end %>

# Common UI interaction cues from Blueprint CSS:
# http://blueprintcss.org/tests/parts/forms.html
Expand Down Expand Up @@ -73,7 +87,12 @@ set-window-option -g window-status-current-format ' #[bold]#I#F#[nobold]#W '
set-window-option -g window-status-separator ''

# show pane title, pane identifier, and hostname on right side of status bar
set-option -g status-right '#{=26:pane_title} #[fg=colour150,bg=colour236] #S:#I.#P #(test -n "$SSH_TTY" && echo "\#[reverse] #H ")'
set-option -g status-right '#{=26:pane_title} <%=
case ENV['theme']
when 'light' then '#[fg=colour231,bg=colour244]'
when 'dark' then '#[fg=colour150,bg=colour236]'
end
%> #S:#I.#P #(test -n "$SSH_TTY" && echo "\#[reverse] #H ")'
set-option -g status-right-length 48

#-----------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions bin/edit-encrypted-file
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ exec vim -u NONE -c 'set '\
'cryptmethod=blowfish '\
'foldmethod=marker '\
'foldlevel=0 '\
"background=$(cat ~/.theme) "\
"$@"
16 changes: 16 additions & 0 deletions bin/theme
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh -ex
#
# Usage: theme [light|dark]
#
# Applies the given theme to terminal-based applications such as tmux and vim.
# If no theme is given, then the currently applied theme is written to STDOUT.
#
if test $# -gt 0 ; then
echo "$1" > ~/.theme
export theme=$1
erb ~/.tigrc.erb > ~/.tigrc
erb ~/.tmux.conf.erb > ~/.tmux.conf
test -n "$TMUX" && tmux source ~/.tmux.conf
else
cat ~/.theme
fi

0 comments on commit 4bdf5a7

Please sign in to comment.