← Back to Upcase

Tmux Part 3: Navigation

(Robert Eshleman) #21

In case anyone else encounters this issue in Terminal in OS X, setting the following Terminal preferences allowed me to use Chris’s tmux key bindings with both vim (w/ thoughtbot/dotfiles) and zsh.

In Terminal -> Preferences -> Profiles -> [Your Current Profile] -> Keyboard, add the following Key -> Action mappings:

<Shift><Cursor Up>: \033[1;2A
<Ctrl><Cursor Up>: \033[1;5A

<Shift><Cursor Down>: \033[1;2B
<Ctrl><Cursor Down>: \033[1;5B

(Captain Zoom) #22

Per the video, I have the following in my tmux.conf:

bind-key -n C-h select-pane -L
bind-key -n C-l select-pane -R
bind-key -n C-j select-pane -D
bind-key -n C-k select-pane -U

They all work fine except for C-h, which does nothing. I figured this has something to do with the Delete sends Ctrl-H setting, but toggling that (in either iTerm or Terminal) seems to have no effect. Presumably I must have it bound to something else before tmux gets it, but I have no idea what. (It’s not a conflict in .tmux.conf itself; i.e., moving the offending line to the end of the file doesn’t help.) Ideas?

Tmux Part 4: Vim Integration
(eternal44) #23

Is anybody else getting an error when setting up tat? I get the following:

tmux: unknown option – A
usage: new-session [-d] [-n window-name] [-s session-name] [-t target-session] [-x width] [-y height] [command]

(Chris Toomey) #25

@eternal44 my guess is that this is a version issue. It looks like the -A flag was added to the new-session command in version 1.8 (March 2013).

You can check your version by running tmux -V (note the big v). Should be 1.8 or higher to work with tat, but I’d recommend upgrading to 1.9a or 2.0 via your package manager anyway.

(eternal44) #26

@christoomey indeed it was! I saw your answer in the forum and upgrading solved the problem.

(David) #28

@christoomey regarding pane_current_path, I’m on tmux version 2.1 and it looks like this may be deprecated? Adding the -c flag with pane_current_path doesn’t seem to do anything for me.

I did some digging and found people proposing this solution as recently as last year but then I came across this question on Unix & Linux Stack Exchange where one of the responders mentions pane_current_path but then writes that “there are [sic] an upstream commit removing it from the manpage so it might not be available in the future.”

Do you know if this was added in 1.9 and then removed again?? I also tried the suggested “pre-1.9 solution” from another responder on the same question above (setting and resetting default-path) but that doesn’t seem to be working for me either.


After reading some of the tmux man pages and realizing that not even splitw -c "/Users/davidpell" was working (my new windows always went to one particular directory instead of my current directory), I realized the problem was that I forgot I had a cd at the very bottom of my .zshrc! I guess the shell is being re-initialized in every new window. Once I commented that line out, pane_current_path worked as laid out here.

(Enrique Salceda) #29

@aaronmcadam, @acandael, @ChrisLegg if you still have the problem guys, I found this solution. Now I can resize all the panels.

  1. Terminal > Preferences…
  2. Settings top-level tab
  3. pick the profile you want to modify
  4. Keyboard tab
  5. click the plus button to add a new binding
    5.1. pick a cursor key
    5.2. set the modifier to control
    5.3. use the Send Text: action
    5.4.type Escape (will show up as \033) followed by [1;5 and one more character:
    5.4.1. A for Up,
    5.4.2. B for Down,
    5.4.3. C for Right, or
    5.4.4. D for Left
    5.5. click OK to add the binding

For example, the final sequence for Control-Up should end up looking like \033[1;5A.

These sequences are the ones that XTerm generates (see the ctlseqs documentation for details).

Repeat the last step for the other arrow keys.

Source this link

(David) #30

Anyone else finding that these bindings…

bind-key -n C-j select-pane -D
bind-key -n C-k select-pane -U

…are overriding the ability to move up and down within the vim plugin ctrlp fuzzy find results? Any recommendations for what to remap those to with the ctrlp options?

(Chris Toomey) #31

Tmux wraps all other processes, so it makes sense that it would “win” and handle C-j. I’m using vim-tmux-navigator covered in Video 4 - Vim Integration, which will pass C-j and C-k through to Vim if Vim is active, and CtrlP list navigation works as a result.

(Paul Kruger) #32

This was really awesome! Thanks so much for the great info…

(Michael Anhari) #33

Anyone know how to go about doing this: “Mark this as executable and place anywhere on your path and then you can use tat to create new sessions.”?

(Chris Toomey) #34

@mpanhari sorry, I should have been more clear about that. Two steps to that:

  1. Mark as executable - Run chmod +x tat while in the directory that has the tat script. This “changes the mode” to add “executable”
  2. Place it on your PATH: Your PATH is a shell variable that lists all the potential directories to look in for a given executable. So we you type a command like ruby, your shell searches through these directories to find a matching executable. If you have executable files in ~/bin, you can add that to your path by adding the following to your shell startup file (~/.bashrc or ~/.zshrc depending on your shell):
export PATH="$HOME/bin:$PATH"

You’ll need to resource your shell init file after adding that line, or open a new shell. That’s a start, but please post any other questions you have if you still can’t get it there.

(Michael Anhari) #35

That did the trick. Your explanation was great. Thanks Chris!

(Peter Northup) #36

If anyone else is having trouble getting the copy-mode to work with the system clipboard in Linux (since reattach-to-user-namespace and pbcopy are for OSX), here’s what I did:

# Use vim keybindings in copy mode
setw -g mode-keys vi

# Setup 'v' to begin selection as in Vim
bind-key -t vi-copy v begin-selection
bind-key -t vi-copy y copy-pipe "xclip -selection clipboard"

# Update default binding of `Enter` to also use copy-pipe
unbind -t vi-copy Enter
bind-key -t vi-copy Enter copy-pipe "xclip -selection clipboard"

I’m still seeing a weird issue where gibberish appears on the opposite pane when I Copy, but it disappears when I switch back. A bit annoying, but no big deal.

(Robin Clark) #37

@eudinaesis Thank you for posting this, it’s working perfectly for me on Debian Jessie.

(Fabricio Quagliariello) #38

life changing lesson!
Thanks @christoomey !

(Chris Toomey) #39

So glad you enjoyed it, @fmquaglia!

(thedanotto) #40

@christoomey Hey Chris, 2 quick questions.

  1. Split window has the command split-window. Does the zoom function have an alias like that? I want to map the key from C-s z to C-z. Basically I want to be able to zoom and unzoom without hitting the prefix using the -n flag, but do not know how to target the zoom.

  2. In Copy Mode, sometimes I have an error that goes longer than 1988 lines. Is it possible to increase the amount of lines available in that mode?

(Chris Toomey) #41

Hi @thedanotto,

  1. Zoom is a commend +arg, resize-pane -Z. You can bind to C-z with bind-key -n C-z resize-pane -Z. That said, I would recommend against this particular binding as it by default is “background current process”. You many not use this now, but if you find yourself wanting it down the road or pairing, you may find you regret it.

  2. Sure is! I have this in my ~/.tmux.conf:

    Keep plenty of history for scrollback

    set -g history-limit 10000

(thedanotto) #42

Thanks a bunch!