11

On my linux machines, for my terminal shell I have tmux keys mapped to allow me to split windows and then switch between new panes.

With or without these mappings I can't figure out how to remap the key combo's on my mac that let me divide the terminal window and stay in whatever directory I'm currently in, for the new window. This is really handy for all my terminal work.

I can use the Iterm menu itself and/or the shortcut key combos it shows but these all seem to be are Iterm split windows not tmux and the one thing they don't do is set the same directory, they go to the my home directory (~).

Note this is not about switching tmux panes, that works, and it's not about switching Iterm panes as in iterm - what's the key-combo to switch panes? and the advanced configuration didn't seem to take effect either: enter image description here

Does anyone know the key combo or mapping I can use/make to get the 'tmux split and stay in directory' functionality on my mac. Model is about 2 years old.

I thought I had found it for the native window pane splitting within iterm splitting with the settings below, changing Working Directory from Home directory to Reuse previous session's directory:

enter image description here

but it didn't work, I'm still getting my home directory in new panes for Iterm window panes.

[Update - I've found that the original tmux key combo's for this - actionKey + " and actionKey plus % (no wonder I've remapped them!) do actually work on my mac, i.e.

enter image description here

So it seems that my remapping of them in .tmux.conf with

set -g prefix C-a # this just changes my prefix from ctrl-b to ctrl-a
bind \ split-window -h # Split panes horizontal
bind - split-window -v # Split panes vertically

isn't working (the remap of ctrl-a works but the binding of the other two keys for split panes doesn't), why might that be?

My entire .tmux.conf file is:

$ cat .tmux.conf
bind r source-file ~/.tmux.conf \; display "Reloaded!" # Reload with ctrl-r
set -g prefix C-a # prefix from ctrl-b to ctrl-a
unbind C-b # allow ctrl-b for other things
set -sg escape-time 1 # quicker responses
bind C-a send-prefix # Pass on ctrl-a for other apps
set -g base-index 1 # Numbering of windows
setw -g pane-base-index 1 # Numbering of Panes
bind \ split-window -h # Split panes horizontal
bind - split-window -v # Split panes vertically

I've also tried removing my .vimrc file though it shouldn't have been relevant to the terminal shell issue but I did it anyway and it didn't helped.

Info Update:

$ tmux -V
tmux 1.8
[mdurrant@Macintosh ~]
$ tmux list-keys | grep split
bind-key          " split-window
bind-key          % split-window -h

p.s. I've updated the title to reflect my updates.

2
  • 1
    That .tmux.conf works for me (under tmux 1.8): your bindings work when I start a new server using the specified configuration file. Are you sure that you have reloaded your configuration? What does tmux list-keys | grep split show (run inside a tmux session)? Commented Jan 19, 2014 at 7:06
  • tmux 1.8 and output from list keys shown above. Commented Jan 19, 2014 at 13:35

1 Answer 1

4

I needed to reload (perhaps 'apply' is more appropriate) my configuration file.
I had restarted my mac and thought this would have done it but I still needed to do:

$ tmux source-file ~/.tmux.conf

Note: type this exactly as shown. source-file is literally what you type (or copy-paste) it is NOT something you replace with your own value).

3
  • 2
    Given that the above answer was accepted, I wanted to add a note that this is a very common rebinding: bind-key r source-file ~/.tmux.conf \; display "Config reloaded!" Commented Mar 8, 2015 at 19:15
  • 2
    Tangentially related and for future googlers: I wanted to swap my horizontal/vertical keys because intuitively it makes more sense that way, and discovered that in order to remap the double-quotes key ", you have to put it around single quotes in your .tmux.conf. ie. bind '"' split-window -h
    – yiwei
    Commented Nov 6, 2017 at 22:46
  • Thank you! I have to do this the same on macOS 10.14.
    – haxpor
    Commented Mar 23, 2019 at 19:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .