Use Ctrl + Left/Right to move forward/back one word in tmux within Mobaxterm - bash

When using tmux within Mobaxterm, Ctrl + Left/Right just moves the cursor forward/back one character, not one word.
In the following cases, Ctrl + Left/Right does behave as expected:
in bash within Mobaxterm
in screen within Mobaxterm
in tmux within Cygwin
in screen or bash within Cygwin
So it seems to be an issue only when combining tmux with Mobaxterm.
In all cases, I am ssh-ing to a remote linux machine, within either Cygwin or Mobaxterm. My /etc/inputrc is set as it should for the shortcuts to work.
Any clue?

Old question. But in case someone find his way here. This is sgzmd's answer:
Edit your ~/.tmux.conf and add lines:
set-window-option -g xterm-keys on
If you don’t want to make it permanent just yet, do:
C-b :set-window-option xterm-keys on
Reload your config in tmux by doing:
C-b :source-file ~/.tmux.conf
It worked for me.
original answer here

Related

macos iterm2 tmux remap ctrl-b to right option/alt-a

I thought this was a no brainer. I am using tmux with iterm2 (latest version) on maxOs on a MacBook.
Using ctrl-b as prefix is a terrible key combination for a MacBook, since the MacBook has only one control key, which is placed on the left hand side. So pressing these two buttons at the same time is almost painful for me. But tmux is awesome, so it lets you remap the prefix.
So, quite naively, I entered this line into my ~/.tmux.conf in order to set the prefix to option/alt-a:
set-option -g prefix M-a
However, that line didn't change a thing.
Entering tmux show-options -g still outputs
prefix C-b
Has anyone ever solved this?
BTW: I know I could use iterm2's tmux integration. But I don't want that. I want a plain text mode solution.
Yeah, so I found a solution:
1 # change ctrl-a to alt-a
2 unbind C-b
3 set-option -g prefix M-a
4 bind C-a send-prefix
And then in iterm2 -> profiles -> [your profile] > Keys
for Right Option/Alt Key
click Esc+
I'm sorry. I found this solution, after having posted the question.

history-limit is not working after C-l in tmux

My environment is Fedora20 (32-bit) + Yakuake + fish + tmux.
Months ago, I started to use tmux, it is a great terminal multiplexer, but the scrollback (Use prefix then PageUp to scroll back) is not working as expected, the history limit is always under 2000 (around 1980 on the right above corner) even if I already set the scrollback limit to "unlimited scrollback" in Yakuake Setting.
Finally I could take it anymore and started to goole it for solution, found out that I could put set -g history-limit 30000 int my tmux.conf file, then check again, it worked, but I realized that every time I typed C-l to clear the screen(and I use it a lot), the scrollback history will be only under/around 30.
Then I found out at How do i clear tmux screen while tailing logs? that I could put bind l send-keys -R into .tmux.conf and use prefix-l to clear the terminal history buffer temporarily and still be able to scroll back, it worked just as I wanted. But What I really want is I use only C-l to do the trick without the prefix key, replacing the shell built-in C-l to do it...
Update:
Short ask, after setting a bind in .tmux.conf, in tmux, you have to type the prefix key before typing that key, then how to bind a key without the need to add the prefix key by default??
In order to bind a key without the need to add the prefix, use the -n flag for the tmux bind command.
Here's the example that should be put in tmux.conf:
bind -n C-l display-message 'foo'
The example binding is triggered when Ctrl-l is pressed (no prefix) and it displays message 'foo' in the tmux prompt.
All that said, be careful & conservative with setting these "direct" key bindings because the key will become unusable for any other terminal program.

tmux key bind C-Tab (Ctrl + Tab) to switch/cycle to the next pane

I'm trying to bind Ctrl + Tab to cycle to the next tab.
I've added this to my ~/.tmux.conf file:
bind -n C-Tab select-pane -t :.+
But it doesn't work,
however it i change it to Ctrl + a it works fine:
bind -n C-a select-pane -t :.+
Any ideas?
My first thought is my terminal maybe hijacking it but i cant see anywhere, and nothing happends with Ctrl + Tab normally for me in the terminal, just a tab space is inserted.
I'm using xfce4-terminal if that helps, else maybe im doing something wrong in my tmux conf.
Terminal wont sent key. You have the same issues for vim, and so on. The seams to work because the terminal grabs its, but it wont send to your current job inside it. I strongly recommend to use other mappings, ( i know, sounds stupid .... ).
take a look at this post, might help:
vim cant map <C-Tab> to :tabnext

Using Alt-left/right to switch between windows in tmux

I am trying to configure tmux to switch between windows using alt-left, alt-right sequences. This is what I have in my .tmux.conf
bind-key -n M-Left previous-window
bind-key -n M-Right next-window
Unfortunately, it doesn't work. On my machine, alt-left and alt-right are bound to ^[[1;3D and ^[[1;3C respectively. I think I have to use terminfo override to tell tmux to use these sequences, but I have no idea how. So, any help will be appreciated.
Thanks!
If the xterm-keys option was off, tmux would ignore the keys (because it would recognize them and discard them when the option was not set). Users of tmux have been confused by this distinction for a while, and at the end of 2016, the developer changed the default for the option:
Change the xterm-keys option to default to on, so that tmux will generate xterm(1) escape sequences for function keys with modifiers.
With the option off most of these keys are ignored by default, except
for ctrl + arrows which use a variant that nothing else seems to use and
I don't remember why we chose. The xterm escape sequences are now the
most common.
This still relies upon the terminal description, as I pointed out in tmux on remote machine not getting correct prefix + arrow keys

Using keyboard to navigate the OS X terminal scrollback buffer

I hate using the mouse. When working in the OS X terminal, sometimes I want to navigate to a line in the bash shell a few rows up, copy a word or two. For this I always end up using the mouse. Any solution for this? Perhaps the terminal supports a key combination that puts it in to navigation/select/copy mode, where I can use the usual C-F, C-B, C-N and C-P keys.
If you feel comfortable with Vi key combinations, you can use this command to switch to vi-mode and use key strokes:
$ set -o vi
Or use C-xC-e to open current line in your $EDITOR.

Resources