#!/usr/bin/env bash set -eu declare -r red='\e[31m' declare -r yellow='\e[33m' declare -r blue='\e[34m' declare -r magenta='\e[35m' declare -r cyan='\e[36m' declare -r normal='\e[39m' echo -e "${magenta}========================================" echo -e "${magenta}= ${blue}Copy Tmux Config to Remote Machine${magenta} =" echo -e "${magenta}========================================" echo -e "${normal}" declare -a args=($@) if $(test ${#args[@]} -lt 1); then echo -e "${red}[error]${normal} missing arg: TARGET" echo -e "${normal}" exit 1 fi declare -r target="${args[${#args[@]}-1]%%:*}" unset args[${#args[@]}-1] set -- "${args[@]}" echo -e "${blue}TARGET: ${cyan}${target}" echo -e "${normal}" declare -r config_file="${HOME}/.tmux.conf" if [[ -f "${config_file}" ]]; then echo -e "${blue}Copying ${cyan}~/.tmux.conf${normal}" echo -e "${normal}" scp $@ "${config_file}" "${target}:~/" echo -e "${normal}" fi declare -r config_directory="${XDG_CONFIG_HOME:-${HOME}/.config}/tmux" if [[ -d "${config_directory}" ]]; then echo -e "${blue}Copying ${cyan}~/.config/tmux/${normal}" echo -e "${normal}" ssh $@ ${target} 'mkdir -p ~/.config/tmux' scp $@ -r "${config_directory}" "${target}:~/.config/" echo -e "${normal}" fi echo -e "${magenta}Done!${normal}"