---
title: "Post #54518878156"
date: 2013-07-03 16:11:00 +00
tags: tumblr
---

![mirrored image from https://66.media.tumblr.com/bd2987bff9bec9c2cb7e6c97da48b757/tumblr_inline_mpj10uWXun1qz4rgp.jpg without alt text, sorry](./54518878156_0.jpg)

# Xterm Inception

or, _How to Use Xterm Mice and Colors in Fish Through iTerm2 Over Mosh (over ssh) in Tmux on Remote Vim and Weechat Terminals_.

### Inception levels

1.  Reality
2.  [iTerm2](http://www.iterm2.com)
3.  [fish](http://fishshell.com)
4.  [ssh](http://openssh.org)
5.  [mosh](http://mosh.mit.edu)
6.  [fish](http://fishshell.com)
7.  [tmux](http://tmux.sourceforge.net)
8.  [vim](http://www.vim.org), [weechat](http://weechat.org), etc
9.  Dream level 1 and so on.

### Configuring it all

1.  Configure [iTerm2](http://www.iterm2.com) to report itself as an xterm-256color and enable mouse control codes.
    
2.  Ensure your shell’s $TERM recognizes it. You shouldn’t have to force this with any shell init junk.
    
3.  Execute [this perl one liner](https://github.com/keithw/mosh/issues/101#issuecomment-12317162) to print the [XTerm control sequences](http://invisible-island.net/xterm/ctlseqs/ctlseqs.html) to “Use Cell Motion Mouse Tracking” (1002) and “Enable UTF-8 Mouse Mode” (1005). Consider wrapping mosh in something that does this for you.
    
    ```
    perl -E ' print "\e[?1005h\e[?1002h" '
    ```
    
4.  mosh to the remote host.
5.  Configure remote [tmux](http://tmux.sourceforge.net) to support mice. Add the following to ~/.tmux.conf
    
    ```
    set -g default-terminal "screen-256color"   # use 256 colors
    set -g status-utf8 on                       # enable utf-8
    set -g mode-mouse on
    ```
    
6.  Configure [vim](http://www.vim.org) to follow suit. Add the following to your ~/.vimrc
    
    ```
    set mouse=a
    set ttymouse=xterm2
    ```
    
7.  Configure [weechat](http://weechat.org) to do the same in ~/.weechat/weechat.conf.
    
    ```
    mouse = on
    ```
    

### A Weird olde tip

Hold option to use your mouse on your local terminal instead of the remote one.

July 3rd, 2013 9:11am