In order to avoid eyestrain at work, I've chosen to use the ever popular
"solarized" scheme (http://ethanschoonover.com/solarized), which, to keep
things consistent starts off by modifying your terminal colors themselves
through .Xresources or gnome terminal settings.

My basic 16 colors thus remapped, I found that tmux was only displaying
half of them.  The solution to this, oddly enough was found here (
http://rhnh.net/2011/08/20/vim-and-tmux-on-osx):

alias tmux="TERM=screen-256color-bce tmux"

This fixed the color issue allowing all 16 colors to be displayed (the
Solarized theme does have a 256-color fallback mode, but it is not ideal).
 Now, everything is working fine, except for <END> and <HOME> in vim, and
ONLY in vim.  At the terminal, it's fine.  In Vim, <END> inserts 'F' and
<HOME> inserts '\H' above the current line.  This is because, for whatever
reason, vim does not recognize the escape sequences that home and end send
( ^[OH and ^[OF, respectively), and passes them along as commands to the
editor which, in vim means:

<ESC> - exit mode
O - open a line above the cursor
H|F - Add an 'H' or 'F' there.

I have been able to fix this by adding the following to my .vimrc:

""""""""""""""
" tmux fixes "
""""""""""""""
" Handle tmux $TERM quirks in vim
if $TERM =~ '^screen-256color'
    map <Esc>OH <Home>
    map! <Esc>OH <Home>
    map <Esc>OF <End>
    map! <Esc>OF <End>
endif

But there has to be a better way.  I have included my .tmux.conf herein in
hopes that it might further illuminate the problem:
---SNIP---


################################################################################
# Tmux settings
   #
################################################################################

# Set that stupid Esc-Wait off, so VI works again
set-option -sg  escape-time 0

# Automatically try and change window title
set-window-option -g automatic-rename

set-option -g default-terminal "screen-256color"

# Remove italics altogether and replace with reverse
set-option -g terminal-overrides 'rxvt-unicode*:sitm@,ritm@'
set-option -g mouse-select-pane on
set-option -g status-keys vi
set-option -g bell-action any
set-option -g set-titles on
set-option -g set-titles-string '#H:#S.#I.#P #W #T' # window number,program
name,active (or not)
set-option -g visual-bell on

setw -g mode-keys vi
setw -g mode-mouse on
setw -g monitor-activity on

set-option -g status-utf8 on
# set-option -g status-justify centre

set -g history-limit 4096

# 0 is too far from 1 on the keyboard ;)
set -g base-index 1

################################################################################
# Display options
   #
################################################################################

set-option -g status-justify left
set-option -g status-bg black
set-option -g status-fg green
set-option -g status-left-length 40

set-option -g pane-active-border-fg green
set-option -g pane-active-border-bg black
set-option -g pane-border-fg white
set-option -g pane-border-bg black

set-option -g message-fg black
set-option -g message-bg green

#setw -g mode-bg black

setw -g window-status-bg black
setw -g window-status-current-fg white
setw -g window-status-alert-attr default
setw -g window-status-alert-fg yellow

#set -g status-left '#[fg=red]#H#[fg=green]:#[fg=white]#S
#[fg=green]][#[default]'
set -g status-left '#[fg=red]#H#[fg=green]:#[fg=white]#S
#[fg=green]][#[default]'

# set -g status-right '#[fg=green]][#[fg=white] #T #[fg=green]][
#[fg=blue]%Y-%m-%d #[fg=white]%H:%M#[default]'
set -g status-right '#[fg=green]][ #[fg=blue]%Y-%m-%d
#[fg=white]%H:%M#[default]'

################################################################################
# Mappings
    #
################################################################################

# Screen compatibility
---------------------------------------------------------

set-option -g prefix C-a

unbind-key C-b
bind-key C-a last-window
bind-key ` last-window
bind-key a send-prefix

# other ^A
unbind ^A
bind ^A last-window

# screen ^C c
unbind ^C
bind ^C new-window
unbind c
bind c new-window

# detach ^D d
unbind ^D
bind ^D detach

# kill K k
unbind K
bind K confirm-before "kill-window"
unbind k
bind k confirm-before "kill-window"

# :kB: focus up
unbind Tab
bind Tab select-pane -t:.+
unbind BTab
bind BTab select-pane -t:.-

# Copy mode
--------------------------------------------------------------------

#Vi-like
unbind [
unbind ]
bind Escape copy-mode
unbind p
bind p paste-buffer
unbind-key -t vi-copy Space     ;   bind-key -t vi-copy v begin-selection
unbind-key -t vi-copy Enter     ;   bind-key -t vi-copy y copy-selection
unbind-key -t vi-copy C-v       ;   bind-key -t vi-copy C-v rectangle-toggle

#unbind-key -t vi-copy [       ;   bind-key -t vi-copy [ begin-selection
#unbind-key -t vi-copy ]       ;   bind-key -t vi-copy ] copy-selection

bind-key ] run-shell "tmux show-buffer | xsel -i -b"

# Custommappings
---------------------------------------------------------------

# splits
unbind %
bind | split-window -h
bind \ split-window -h
bind - split-window -v

# window movement
bind-key -n C-Left previous-window
bind-key -n C-Right next-window
bind-key -n M-Left swap-window -t -1
bind-key -n M-Right swap-window -t +1

# pane movement
bind-key -n S-Up select-pane -U
bind-key -n S-Down select-pane -D
bind-key -n S-Left select-pane -L
bind-key -n S-Right select-pane -R

bind r source-file ~/.tmux.conf

---/SNIP---
------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to