You are not logged in.

#1 2016-09-27 08:58:08

woodape
Member
Registered: 2015-03-25
Posts: 159

Base16 Colors, Tmux, Urxvt, Vim - Attaching Tmux session loses Base16

I use the following command bound to a hotkey to launch a new urxvt terminal with a new tmux session, and also to launch a urxvt terminal to attach an already open tmux session:

wname="SomeName"
urxvt -sl 0 -T "$wname" -e /bin/bash -c "TERM=screen-256color tmux -2 new-session -A -s \"$wname\""  &

I'm using the Base16 shell script to set my terminal colors, and the Base16 Vim script to set my vim colorscheme. I have the following in my bashrc as per the Base16-shell instructions:

BASE16_SHELL=$HOME/.config/base16-shell/
[ -n "$PS1" ] && [ -s $BASE16_SHELL/profile_helper.sh ] && eval "$($BASE16_SHELL/profile_helper.sh)"

And the following in my vimrc as per the same instructions:

if filereadable(expand("~/.vimrc_background"))
  let base16colorspace=256
  source ~/.vimrc_background
endif

If I open a urxvt terminal all by itself, the colorscheme in the terminal and in vim work just fine. If I use my hotkey command above to open a new terminal with a NEW tmux session, the colorscheme in the terminal and in vim still work fine.
But if I close that urxvt/tmux terminal and use the same hotkey to open a new terminal window and attach the session, I lose the colorscheme in both the terminal and in vim UNTIL I make a split pane, or open a new window in tmux at which point the colorscheme returns. for all open panes and windows

What's going on here? I think it has something to do with my bashrc not being sourced until I make a new tmux pane - where bashrc is sourced.

Here's the "profile_helper.sh" script:

#!/bin/bash
script_dir=$(cd $(dirname ${BASH_SOURCE[0]}) && pwd)

. $script_dir/realpath/realpath.sh

if [ -f ~/.base16_theme ]; then
  script_name=$(basename $(realpath ~/.base16_theme) .sh)
  echo "export BASE16_THEME=${script_name}"
  echo ". ~/.base16_theme"
fi
for script in $script_dir/scripts/base16*.sh; do
  script_name=$(basename $script .sh)
  theme=${script_name#*-}
  func_name="base16_${theme}"
  cat <<FUNC
$func_name()
{
  [ -f $script ] && . $script
  ln -fs $script ~/.base16_theme
  export BASE16_THEME=${theme}
  echo "colorscheme base16-$theme" > ~/.vimrc_background
}
FUNC
done;

Offline

#2 2016-10-04 03:06:52

danielgreve
Member
Registered: 2015-12-11
Posts: 11

Re: Base16 Colors, Tmux, Urxvt, Vim - Attaching Tmux session loses Base16

Sounds annoying, but I believe that is the behavior you should expect. Your bashrc is sourced automatically when a new shell starts. Attaching to an existing tmux session does not start a new shell; however, opening a new pane does. You could re-source your bashrc after reattaching or configure urxvt's colorscheme in .Xresources.

Offline

#3 2016-10-05 08:49:36

woodape
Member
Registered: 2015-03-25
Posts: 159

Re: Base16 Colors, Tmux, Urxvt, Vim - Attaching Tmux session loses Base16

Thanks danielgreve, I figured it was something like that. I actually put the colorscheme in Xresources which fixes the terminal colors, but for some reason the vim colorscheme was still broken. This is a deal breaker for me, so I've moved back to my gruvbox colorscheme.

Offline

Board footer

Powered by FluxBB