Problem with collapsed mode in Tmux on Ubuntu 14.04

190 views
Skip to first unread message

Krisztian Kovacs

unread,
Mar 30, 2015, 1:00:14 PM3/30/15
to pyrosco...@googlegroups.com
Hi All!

First of all, thank you for your great modifications, Pyroscope! rTorrent became really useable in this way :)
I have just installed Ubuntu 14.04 and your compiled package on it, set it up and it's running perfectly in Screen with the following .screen.rc :

startup_message off
defscrollback
1000
defbce on                        
# erase background with current bg color
defflow off                    
# disable Ctrl-S/Ctrl-Q "flow control"
nonblock on                    
# If a window goes unresponsive, don't block the whole session waiting for it.
defutf8 on
encoding  UTF
-8                  #UTF-8
defencoding UTF
-8
setenv LANG en_GB
.UTF-8
term xterm
-256color

With this I get (even in Putty 0.64b on Windows! :) ):
- bold and normal fonts in the collapsed list
- full horisental blue lines at the top and bottom
- correct donw/up scrolling

I wanted to use Tmux instead of screen, but the above mentioned point isn't working in the Ubuntu terminal nor in Putty on Windows. .tmux.conf :

# Rebind to Ctrl-a
set -g prefix C-a
unbind C
-b
# Allows us to use C-a a <command> to send commands to a TMUX session inside another TMUX session
bind a send
-prefix
bind C
-a last-window
bind
'"' choose-window

# Rebind pane splitting
unbind
%
bind
- split-window -v
bind _ split
-window -h
#bind-key | split-window -h

# Set status bar
set -g status-bg colour236
set -g status-fg white
set -g status-left ""
set -g status-right "#[fg=green]#H"

# Highlight active window
set-window-option -g window-status-current-bg colour164

# use UTF8
set -g utf8
set-window-option -g utf8 on

# Allows for faster key repetition
set -s escape-time 0

# Rather than constraining window size to the maximum size of any client
# connected to the *session*, constrain window size to the maximum size of any
# client connected to *that window*. Much more reasonable.
setw
-g aggressive-resize on

# Activity monitoring
setw
-g monitor-activity on

# Refresh the status bar every 30 seconds. Try to keep the nzb folder to a reasonable number
set-option -g status-interval 10

set -g status-right "#[fg=yellow]#(free -m | grep '+' | awk '{ print \"Ram Used: \"$3\" MB, Ram Free: \"$4\" MB\";}')#(free -m | grep 'Swap' | awk '{ print \",Swap: \"$3\" MB\";}') #[fg=cyan]%m-%d-%Y #(uptime)"

set-option -g status-right-length 200

#reduce memory and scrollback buffer
set -g history-limit 1000

#mouse - allows selct pane and resize with mouse
set -g mode-mouse on
set -g mouse-resize-pane on
set -g mouse-select-pane on
set -g mouse-select-window on

bind m
\
 
set -g mode-mouse on \;\
 
set -g mouse-resize-pane on \;\
 
set -g mouse-select-pane on \;\
 
set -g mouse-select-window on \;\
 display
'Mouse: ON'

bind M
\
 
set -g mode-mouse off \;\
 
set -g mouse-resize-pane off \;\
 
set -g mouse-select-pane off \;\
 
set -g mouse-select-window off \;\
 display
'Mouse: OFF'



Can you advise a config which is working fine for you?
Thanks!


pyroscope

unread,
Apr 8, 2015, 5:07:46 PM4/8/15
to pyrosco...@googlegroups.com
Can you advise a config which is working fine for you?


I also noticed non-bold and otherwise "unusual" rendering on newer distros, interesting that screen does it "right". And I don't have any putty involved, just Linux.

Krisztian Kovacs

unread,
Apr 15, 2015, 5:46:25 AM4/15/15
to pyrosco...@googlegroups.com


2015. április 8., szerda 22:07:46 UTC+1 időpontban pyroscope a következőt írta:


I also noticed non-bold and otherwise "unusual" rendering on newer distros, interesting that screen does it "right". And I don't have any putty involved, just Linux.

Thank you , so it's not me :)

Krisztian Kovacs

unread,
Jul 8, 2015, 11:12:49 AM7/8/15
to pyrosco...@googlegroups.com
I have figured it out how it should work properly in tmux (ubuntu 14.04): it's just all about the terminal settings (and it's working fine in putty as well, see below).

All we have to add this 1 line in our .tmux.conf file:
set -g default-terminal "screen-256color"

I have tried out lot's of other terminfo files, but this one was the only that was working well with different apps (like 'mc') and in different conditions.

We don't have to put anything TERM variable related not just in our init script, but either of any other startup scripts (like, .profile , .bashrc), but I call tmux every time with the switch '-2u' (see below):
- force 256 colors and unicode charset

Finally in putty, we have to specify the terminfo file to use under: Settings->Ssh->data:
- terminal: putty-256color

And all will be fine.

Some config samples:

1. .tmux.conf (we can use CTRL+A + CTRL+D to power detach our tmux session, like we can with srceen):
# Rebind to Ctrl-a
set -g prefix C-a
unbind C
-b

# Allows us to use C-a a <command> to send commands to a TMUX session inside another TMUX session
bind a send
-prefix
bind C
-a last-window
bind
'"' choose-window

# Bind Power detach and logout to C-a C-d
bind C
-d detach -P

#set 256 color display
set -g default-terminal "screen-256color"


2. /etc/init.d/rtorrent init script (a part of it)

isRunning() {
   
if [ -s ${sessiondir}/rtorrent.lock ] ; then
        pid
=`cat ${sessiondir}/rtorrent.lock | awk -F: '{print($2)}' | sed "s/[^0-9]//g"`
       
# make sure the pid doesn't belong to another process : this will match lines containing rtorrent, which grep '[r]torrent' does not!
        ps aux
| grep -sq ${pid}.*[r]torrent && echo true
   
fi
}

d_start
() {
   
[ -d "$base" ] && cd "$base"
   
# if STDIN is a terminal (we are using interactive mode)
   
[ -t 0 ] && stty stop undef && stty start undef
   
# start the default 2 tmux window (bash and mc) if there isn't tmux session called rtorrent
   
if ! su -c "tmux ls | grep -sq ${NAME}: " $user ; then
        su
-c "tmux -2u new-session -d -s ${NAME} -n 'shell1'" $user
        su
-c "tmux -2u new-window -t ${NAME}:1 -n 'mc1' 'mc'" $user
   
fi

   
# start rtorrent in another tmux window if it's not running
   
if [ ! "$(isRunning)" = true ]; then
        su
-c "tmux -2u new-window -t ${NAME}:2 -n ${DESC} ${DDIR}/${DAEMON} ${options}" $user
   
fi
}

d_stop
() {
   
if [ "$(isRunning)" = true ]; then
        kill
-s INT ${pid}
   
fi
}


3. .profile (we can put this at the end of our profile file to invoke our tmux session automatically):
# Automatically reattach the rtorrent session or create a new one only if STDIN is a terminal (we are using interactive mode)
if [ -t 0 ] && [ -z "$TMUX" ]; then
    tmux
-2u new-session -A -s rtorrent
fi


So, I got perfect rendering in:
- linux native terminal
- ssh from putty (set putty-256color for terminal under Ssh->Data)
- ssh from Mac OS X 10.10.x native terminal (no configuration is needed)


(I have tried out the same thing with openwrt, tmux and mc. It's the same there as well (I had to modify the makefile of ncurses package, recompile it, copy the missing putty* and screen* terminfo files into the router, and it's working fine.))


2015. április 8., szerda 22:07:46 UTC+1 időpontban pyroscope a következőt írta:
Reply all
Reply to author
Forward
0 new messages