tinted-theming / tinted-fzf

base16 colorschemes for fzf
https://github.com/base16-project/base16
MIT License
135 stars 9 forks source link

Synchronize base16-fzf theme with base16-shell theme #10

Closed Ch00k closed 4 years ago

Ch00k commented 4 years ago

I am trying to find a way to synchronize the fzf theme with the shell theme, so when I execute base16_flat in my terminal, I want my fzf theme also changed to flat. Is there an easy way to do this?

nicodebo commented 4 years ago

Hi, I think you will have to build a custom script to do that. Or maybe you could try the inject sub-command of pybase16 cli. I think it fits your requirements: https://github.com/InspectorMustache/base16-builder-python

fnune commented 4 years ago

For this, I have my own script.

You could remove that last line since it's specific to my setup. Ends up like this:

# Select a base16 theme and also use its base16-fzf counterpart
function theme() {
  if [ -z $1 ]; then
    echo 'Please pass one argument: the name of the base16 theme you want to use.'
    echo 'For example: `theme tomorrow`'
    return 1
  fi
  eval "base16_$1"
  eval "source ~/.config/base16-fzf/bash/base16-$1.config"
}
fnune commented 4 years ago

Closing this since it doesn't pertain to this repo's responsibilities and there are two solutions above.

fnune commented 4 years ago

I've recently found out about this package, which seems to take care of the problem in a different way: https://github.com/base16-manager/base16-manager

kahl-dev commented 4 years ago

base16_shell has hooks for this

my working config:

# zshrc with zinit under ~/.zshrc

zinit light fnune/base16-fzf
export BASE16_SHELL_HOOKS=$DOTFILES/base16_hooks
export BASE16_FZF=${ZINIT[PLUGINS_DIR]}/fnune---base16-fzf/bash/
# hooks file under $DOTFILES/base16_hooks/base16_fzf.sh

#!/usr/bin/env zsh

source $BASE16_FZF/base16-$BASE16_THEME.config
fnune commented 4 years ago

@patrickkahl Awesome, I'll be trying this out soon, it's great that this is documented here.

Woodham commented 3 years ago

I was just trying to do the same thing and I like the idea of the hook based approach but I don't think it works, at least for bash.

base16-shell executes the hooks files and doesn't source them, so the hook script sourcing the fzf-base16 theme has no affect on the currently running shell. As far as I can tell even if it did work it also would need to be re-run if you closed and opened your terminal too since there's no persistenace of the fzf theme env var.

Maybe things work differently for zsh? I haven't really used it.

tummetott commented 3 years ago

I can confirm that this does not work in zsh either. The hook file is executed but there is no effect on the current shell. I really don't get how this is supposed to work..

Woodham commented 3 years ago

I randomly started thinking about this problem again today - for anyone else this still bothers.

I've ended up solving it by creating a couple of wrapper functions for fzf which forces the theme to be set when fzf is run every time.

# force fzf theme change
fzf() {
    [ -f ~/.config/fzf.theme ] && source ~/.config/fzf.theme 
    command fzf $*
}

fzf-tmux() {
    [ -f ~/.config/fzf.theme ] && source ~/.config/fzf.theme 
    command fzf-tmux $*
}

These work in conjunction with my base16 shell hook:

.config/base16-shell-hooks/base16_fzf.sh:

#!/usr/bin/env bash

BASE16_FZF=$HOME/.config/base16-fzf

ln -f $BASE16_FZF/bash/base16-$BASE16_THEME.config $HOME/.config/fzf.theme