bind S command-prompt -p 'SSH to:' "new-window -n %1 'ssh %1'"
ClusterSSH is cool but when I VPN into work, a lot of hosts are firewalled from the VPN. Trying to X11 forward 10 or 12 xterms, or hack something together with dynamic SSH forwarding and send the clusterssh command over a tunnel was more trouble than it was worth.
This script uses the tiled pane layout and the synchronize-panes window option to send the same keystrokes to every pane at once.
#!/bin/sh
#
# Script Name: tssh
# Description: Emulates clusterssh natively in tmux
# Usage: tssh host1 host2 host3 ...
#
################################# FUNCTIONS ##################################
function cur_win () {
echo `tmux list-windows -F '#I:#{window_active}' | grep '1$' | cut -f1 -d:`
}
function build_target_arg () {
while getopts 't:' option; do
case $option in
t) target_window=$OPTARG;;
esac
done
if test -n target_window; then
echo " -t :${target_window}"
fi
}
function cur_pane () {
target_arg=$(build_target_arg $@)
echo $(tmux list-panes -F '#P:#{pane_active}'${target_arg} | grep '1$' | cut -f1 -d:)
}
########################### MAIN SCRIPT EXECUTION ############################
if [ -z "$TMUX" ]; then
echo Must be run from within an active tmux session 1>&2
exit 1
fi
# find index of starting window
win_init=$(cur_win)
tmux set-window-option -t $win_init quiet on
# create new tmux window
tmux new-window -n tssh
# get index of new window
win_new=$(cur_win)
# get initial pane number for cleanup later
initial_pane=$(cur_pane -t $win_new)
for host in $@; do
tmux split-window "/usr/bin/ssh $host"
tmux select-layout tiled
done
# cleanup
tmux kill-pane -t $initial_pane
tmux select-layout tiled
tmux set-window-option -t $win_new synchronize-panes on
tmux set-window-option -t $win_init quiet off
Are you setting TERM anywhere in any of your shell rc files? If so, then you need to comment out (or better yet, delete) any lines where you are exporting TERM. Then logout and log back in to make sure that your login session isn't polluted with that. You should almost never set TERM manually.
Have you exited all tmux windows and started a new tmux server since adding the default-terminal parameter? The .tmux.conf is only read when the server starts. If you have any other sessions (attached or not) when you exit a session, the server continues to run, so tmux won't read the config file when you open a new terminal and start a new tmux session. Either exit all tmux sessions and start a new one or run tmux source ~/.tmux.conf to reload the config.
]]>If I run tmux automatically on startup ( after editing my .bashrc) it doesn't support 256 colors. 8-bit again.
I think its some problem with my .tmux.conf.
]]>In a new, non-tmux terminal, what is the value of TERM?
]]>The output of tput colors is : xterm-256
I have already : set -g default-terminal "screen-256color" ## in my ~/.tmux.conf
and : set t_Co=256 ## in my ~/.vimrc
I don't seem to have a ~/.profile
export TERM="xterm-256color"
alias tmux="tmux -2" ## in ~/.bashrc did not help either.
thanks.
]]>EDIT: Solved, I made bash script as explained here, only without line which creates new detached session.
]]>Four-window conf:
$ alias
...
alias tmux4='tmux -f ~/.tmux4 attach
...
$ cat .tmux4
set -g default-path /home/testing/bin
unbind C-b
set -g prefix ^A
new -n bash
splitw -h -p 50 -t 0
splitw -v -p 50 -t 0
splitw -v -p 50 -t 1
selectp -t 0
bind v splitw\; selectl main-vertical
bind h splitw\; selectl main-horizontal
Fixed in testing.
]]>Anyone experienced that as well. or is it just me?
]]>setw -g window-status-format '#[fg=white,bright]#I:#P)#W#F'
It turns out that setting any color attribute here causes the problem. I even removed the bright attribute, changed the color, and the result was the same.
]]>