Fork me on GitHub

Лупайте сю скалу...

Іван Франко

 RSS | Atom

19 June 2015


Selected projects See all »

Banalize: Bash static code analyzerDBIx::Report::ExcelShell settings, AKA dotfilesNagios Monitoring for Couchbase serverNagira: RESTful API for NagiosStartpack for Github pages developmentWeb iPhoto

Travel Blog Витрішки »

Україномовний блог Витрішки - блог про все, крім роботи. Цикл статей "Літо на півночі Японії" з цього блогу тепер опублікований у Витрішках

Computer Blog All posts »

iPhoto and files permission Is MacOSX 10.9 == MacOS 9.x? Running Chef roles from Capistrano und Capiche Github & Jekyll: Speeding up Jekyll siteGithub & Jekyll: More experience with Jekyll and setup changesBuild new hosts with Capistrano and Chef Request Tracker: More about custom CSS for RT4Ruby 2 test drive Nagira v0.2.5 release It's UNIX my dear Watson

Slides See all »

Nagira @TLUG, 2012Rspec and Guard


Ярило Yarylo, Jarilo me @ github me @ CPAN Dmytro (CV)

Now I've got my environment ...

It looks like I finally have an environment I am satisfied with and I have tools to manage it.

Long previous years I had set of my own configuration files that I carried with me from one environment (usually associated with new job) to another. These were huge .emacs file, even bigger .fvwm2rc file, lot of additional e-Lisp files, .bashrc and so on.

Management system was simple: got a job → send yourself email from home with lot of attachments → save to home directory → add changes. Usually after ‘add changes’ step, one had to copy changes back to home files.

Now, I’ve got my own copy of dotfiles on Github and that makes life enjoyable again. There’s README file that explains most what you need to know to start using it.

At about the same time I’ve discovered several new things – iTerm2 and tmux.

iTerm2 + tmux + emacs

Making navigation in all three of the above if not the same then at least similar makes life much easier. Just to make things clearer: I am not a mouse person, and by navigation I mean using keyboard.

Since I am mostly in the Mac now, I am using FWVM much less, and navigating in it is less concern for me.

Additionally navigation includes more things then jst switching from window to window. There’s navigating on command line: search command history, search and scroll forth/back in scrollback buffer, etc.

Navigating in iTerm2 and tmux

Most of the keys set by default in iTerm2 (Cmd-, Cmd-End?Home etc.) are unused when iTerm2 used in combination with tmux. For example, when using tmux scroll buffer, iTerm2 scoll buffer cannot be used and only messes things up. So, I actually set iTerm2 buffer size to 0 — this removes iTerm2 scroill bar as well, and this also gives a bit more screen space.

Similarly with all other features. To say the truth I actually use only 2 features of iTerm2: full-scrrn mode and ability to map keys to send text strings or sequences of hex codes.

I’ve deleted all default key mappings from iTerm2 and remapped them to send tmux commands instead. There are 2 places you have to do this:

Profiles keymaps

By default iTerm2 loads xterm default key mappings. They intervene with global key mappings and override them. The simplest solution I’ve found to be simply delete all of them. I haven’t run into any problems as of yet related to this, YMMV.

Go to iTerm2 preferences

Default (global) keymaps

Same with the global key mappings — I use none of them in tmux — I deleted all defaults and set my own.

However, here instead of doing all manually, on all macs, I can reuse my config by saving presets to file, and by re-imporing it into iTerm2 preferences. I can also use github and dotfile repository to track changes and share presets across all environments.

I’ve added 2 Rake tasks for exporting, importing iTerm2 global key presets:

    rake iterm:keys:export  # Save global key mapping to file
    rake iterm:keys:import  # Load global key mapping from file to iTerm2 defaults

Actual command that is executed uses McOSX defaults command:

    defaults read ~/Library/Preferences/com.googlecode.iTerm2 GlobalKeyMap > iTerm2/GlobalKeyMap

Navigation key mappings

This is a list of key mappings configured. In the table below ‘screen’ refers to:

  • pane for tmux
  • window for emacs

Since emacs does not do distiction between Option and Command keys on Mac, ‘M-’ in emacs column refers to Meta key, which is Option or Command. For the same reason for screen jumping I had to use Ctrl- in Emacs.

Navigating windows

Go screen left ` Left Cmd-Left Ctrl-Left
Go screen right ` Right Cmd-Right Ctrl-Right
Go screen up ` Up Cmd-Up Ctrl-Up
Go screen down ` Down Cmd-Down Ctrl-Down
Go previous screen ` ; Cmd-` and Cmd-; Cmd-Up
Word forward Option-Right M-Right Option-Right
Word backward Option-Left M-Left Option-Left
Delete word forward Cmd-d M-d Cmd-d
Delete word backward Cdm-Delete M-Delete Cmd-Delete

Windows operations

Go to window Number ` number Cmd-“number”
Toggle panes sync ` S Cmd-S
Split horizontally ` “-” Cmd-“-”
Split vertically ` \ Cmd-“\”
Next window ` n Cmd-Option-Right
Prev window ` p Cmd-Option-Left
Tmux Help ` ? Cmd-h

Tmux selection mode

Mouse selection ON `+m Cmd-m
Mouse selection OFF `+M Cmd-M
Start tmux selection mode `+[ Cmd-[
Copy tmux selection to system clipboard `+Ctrl-] Ctrl-Cmd-]
Paste tmux selection `+] Cmd-]
Start selection mode, scroll page up `+PgUp (TODO)

Various tmux actions

Prefix `
Change prefix to Ctrl-o F12
Change prefix to “`” F11

Note: It is good to have option of disabling “`” as tmux prefix key for cut-and-paste shell scripts into terminal. Most of the mappinngs will not work when prefix changed to Ctrl-o, since in many cases iTerm2 keystrokes send text “`”+something.


Dmytro Kovalov (

Source code

дмитро ковальов
dmytro @ github