#!/bin/bash

# DEPRECATED in favour of tmux_update_vim.

	# This program is free software: you can redistribute it and/or modify
	# it under the terms of the GNU General Public License as published by
	# the Free Software Foundation, either version 3 of the License, or
	# (at your option) any later version.

	# This program is distributed in the hope that it will be useful,
	# but WITHOUT ANY WARRANTY; without even the implied warranty of
	# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	# GNU General Public License for more details.

	# You should have received a copy of the GNU General Public License
	# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Quick and dirty way to update running instances of Vim inside a Tmux
# session.  This script is part of my dotfiles and is meant to be used
# in tandem with `own_script_update_environment_theme`:
# https://gitlab.com/protesilaos/dotfiles

# TODO add conditional logic
# TODO add relevant documentation

find_vim() {
	tmux list-panes -a -F '#D #T' | \
	sed "/VIM/!d ; s,\(^%[0-9]*\).*,\1 ,"
}

find_vim | while read -r line; do
	tmux send-keys -t "$line" ':source ~/.vimrc' 'Enter'
done
