#!/bin/bash # curl -sL "https://vim.chan15.info/download/get_tmux.sh" | bash yellow='\033[1;33m' no_color='\033[0m' # No Color bashrc_config='alias tmux="tmux -2"' tmux_config=$(cat << EOF # ~/.tmux.conf set -g default-terminal "xterm" setw -g mode-keys vi set -g pane-border-status top set -g mouse on # List of plugins set -g @plugin 'tmux-plugins/tpm' set -g @plugin 'dracula/tmux' set -g @dracula-plugins "git cpu-usage ram-usage time" set -g @dracula-show-powerline true set -g @plugin 'tmux-plugins/tmux-sensible' set -g @plugin 'tmux-plugins/tmux-pain-control' set -g @plugin 'tmux-plugins/tmux-copycat' bind-key -T copy-mode-vi 'v' send -X begin-selection run '~/.tmux/plugins/tpm/tpm' EOF ) config_not_in_bashrc() { counter=$(grep "$bashrc_config" ~/.bashrc | wc -l) if [[ "$counter" -gt 0 ]]; then return 1 fi return 0 } dracula_not_in_tmux_conf() { counter=$(grep "dracula/tmux" ~/.tmux.conf | wc -l) if [[ "$counter" -gt 0 ]]; then return 1 fi return 0 } insert_tmux_conf() { echo "$tmux_config" >> ~/.tmux.conf } get_distribution() { lsb_dist="" if [[ -r /etc/os-release ]]; then lsb_dist="$(. /etc/os-release && echo "$ID")" fi echo "$lsb_dist" } dispatch() { cd /tmp || exit 1 if [[ ! -d /tmp/tmux ]]; then git clone https://github.com/tmux/tmux.git fi cd tmux || exit 1 sudo sh autogen.sh sudo ./configure && sudo make sudo make install } go_ubuntu() { echo install tmux in ubuntu sudo apt purge -y tmux sudo apt install -y git make gcc autoconf automake pkg-config libevent-dev libncurses-dev bison dispatch } go_centos() { echo install tmux in centos sudo yum install -y git sudo yum remove -y tmux sudo yum install -y git make gcc autoconf automake pkg-config bison libevent-devel ncurses-devel dispatch } distribution=$(get_distribution) case "$distribution" in ubuntu) go_ubuntu ;; centos) go_centos ;; *) echo not compatible OS esac if [[ ! -d ~/.tmux/plugins/tpm ]]; then git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm fi if [[ ! -f ~/.tmux.conf ]]; then touch ~/.tmux.conf insert_tmux_conf else if dracula_not_in_tmux_conf; then insert_tmux_conf fi fi if config_not_in_bashrc; then echo -e "\n$bashrc_config" >> ~/.bashrc echo -e "${yellow}Added tmux alias to ~/.bashrc. Please run 'source ~/.bashrc' or restart your terminal to activate it.${no_color}" fi echo -e "${yellow}$(tmux -V)${no_color} installed"