Browse Source

Dynamically detect session theme and set vim theme

master
ViViDboarder 4 years ago
parent
commit
ba2afb7df0
  1. 55
      assets/default/bin/get_vim_colorscheme.sh
  2. 2
      assets/default/dotfiles/bash_profile
  3. 2
      assets/default/fish/init/env.fish

55
assets/default/bin/get_vim_colorscheme.sh

@ -0,0 +1,55 @@
#! /bin/bash
# Gets the current settings for the given terminal window
function get_terminal_settings {
case "$TERM_PROGRAM" in
Apple_Terminal)
osascript <<EOD
set current_tty to "$(tty)"
tell application "Terminal"
repeat with win in windows
repeat with the_tab in tabs of win
set tab_settings to the current settings of the_tab
if current_tty is equal to the tty of the_tab then
return the name of tab_settings
end if
end repeat
end repeat
end tell
EOD
;;
iTerm.app)
echo "$ITERM_PROFILE"
;;
*)
echo "Unknown terminal $TERM_PROGRAM"
exit 1
esac
}
# Mappings of Terminal themes to color schemes
function get_vim_colorscheme {
local term_theme="$1"
case "$term_theme" in
"Hotkey Window Wombat")
echo "wombat256mod"
;;
Wombat*)
echo "wombat256mod"
;;
Solarized*)
echo "solarized"
;;
"Yosemite Light"*)
echo "morning"
;;
"Yosemite Dark"*)
echo "vividchalk"
;;
*)
echo "default"
;;
esac
}
get_vim_colorscheme "$(get_terminal_settings)"

2
assets/default/dotfiles/bash_profile

@ -70,7 +70,7 @@ export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad
# Vim colors
[ -z "$VIM_COLOR" ] && export VIM_COLOR='wombat256mod'
[ -n "$VIM_COLOR" ] || export VIM_COLOR=$(eval $HOME/bin/get_vim_colorscheme.sh) || export VIM_COLOR='wombat256mod'
# Set file as having been loaded to avoid looping
#IS_BASH_PROFILE_LOADED=true

2
assets/default/fish/init/env.fish

@ -6,4 +6,4 @@ set -gx FZF_DEFAULT_COMMAND 'ag -g ""'
set -gx FZF_CTRL_T_COMMAND "$FZF_DEFAULT_COMMAND \$dir"
# Vim Colors so that they can be set by env
set -q VIM_COLOR; or set -gx VIM_COLOR wombat256mod
set -q VIM_COLOR; set -gx VIM_COLOR (eval $HOME/bin/get_vim_colorscheme.sh); or set -gx VIM_COLOR wombat256mod

Loading…
Cancel
Save