When I try to open a file using vim
inside tmux
the whole window freezes. I have to kill the window with C-a &
.
Here are my ~/.vimrc
settings:
:set autoindent
:set ts=4
:set number
:set shiftwidth=4
:set showmode
:filetype on
:filetype plugin on
:syntax enable
:set mouse=a
and ~/.tmux.conf
# I like Ctrl-a as the default hotkey
unbind C-b
set-option -g prefix C-a
# Split window using | and -
unbind %
bind | split-window -h
bind - split-window -v
# Set status bar
set -g status-bg black
set -g status-fg white
set -g status-left ‘#[fg=green]#H’
# Highlight active window
set-window-option -g window-status-current-bg red
# Makes window numbering start from 1, instead of 0
set -g base-index 1
I am facing the problem in RHEL. However the same config works fine in my Mac. I guess, things were working fine till my RHEL box got restarted and I tried to recover a file in from vi swap file.
Any ideas on how to fix this?
[edit]: I tried ssh
to other box inside tmux
and running vi
there. Works fine in remote box !
[added later]
Following the suggestion of @jasonwryan, I added the line set -g default-terminal screen-256color
at the end of tmux.conf
. That prevented programs like less
from working.
echo $TERM
inside tmux is "screen" and outside tmux is "xterm".
Searching for $TERM led me to https://wiki.archlinux.org/index.php/Tmux, from where I added the line set -g default-terminal "screen-256color"
as the first line of tmux.conf
. This made the $TERM
inside tmux to "screen-256color". But now when I start vi
inside tmux, it displays the following error:
E558: Terminal entry not found in terminfo
'screen-256color' not known. Available builtin terminals are:
builtin_riscos
builtin_amiga
builtin_beos-ansi
builtin_ansi
builtin_pcansi
builtin_win32
builtin_vt320
builtin_vt52
builtin_xterm
builtin_iris-ansi
builtin_debug
builtin_dumb
defaulting to 'ansi'
Looks like I have solved the issue. Just added set -g default-terminal xterm
as the first line of my ~/.tmux.conf and it worked !
Best Answer
I solved the issue by adding the line
as the first line of my ~/.tmux.conf and it worked fine.
However as @jasonwryan has pointed out, the TMUX FAQ clearly states that:
I only post this answer as it actually solved my problem. please feel free to add your alternative solutions.