Something went wrong. Try again.
Mirroring: https://github.com/MunifTanjim/scripts.sh
Something went wrong. Try again.
scripts.sh copy-tmux-config
1.3 kB · 51 lines
at main
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152#!/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 1fi
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}"