tmux Escape key exits server - bash

I'm using tmux on a macOsX moutain lion (10.8)
Whenever i'm in a terminal, pressing the Escape button results in the connection to the server being lost and tmux actually exiting. I experience the same behavior regardless in iterm2, terminal and while using any of zsh, bash or a normal login shell.
That's how it looks like:
Any hints? :)

I finally figured out that it was related to iterm2-tmux integration.
As you can read here in the Usage section just below the code box, the tmux-iterm2 integration makes the ESC key actually kill tmux, unless you actually use tmux -C.
This effect was actually undersirable for me since I was not using tmux -C and the ESC key is extremely important in programs like vim or mc.

Related

How to copy string from Tmux in an easy way on macOS?

On macOS, if use bash or zsh shell, use Ctrl+C can copy string to clipboard immediately. But at Tmux model, it can’t. Should press option key, then use mouse select string, press Ctrl+C. It’s a little complex. Is there a short way to do if set any option in Tmux config?
I think tmux = terminal multiplexor: some terminals inside another terminal. If Ctrl+C works when zsh is inside a native terminal (iTerm or xterm), but Ctrl+C doesn't work when zsh is inside tmux; then, that Ctrl+C is the feature of that native terminal (iTerm or xterm) not a feature of zsh or bash.
It is impossible to assign a same key shortcut for BOTH native terminal (iTerm or xterm) AND tmux (which runs inside THAT iterm or xterm).
If you prefer to use tmux (nearly) all the time, then you have to disable Ctrl+C key shortcut in the native terminal (iTerm or xterm), then set it in tmux. But I think most of users wont do that. They have to select a different set of key shortcuts for tmux without changing the native terminal settings, which they already get used to for long time.

System default voice doesn't change on `say` command within tmux sessions

Recently I've changed my default system voice via "System Preferences > Dictation & Speech > Text to Speech > System Voice". If I open a new Terminal window and use the say command, the correct voice is used. However, the previous voice is still used if I use the say command within a tmux session.
I've tried restarting, shutting down tmux completely, and opening an entirely new tmux session with tmux new-session -s foobar and still it doesn't pick up the new preferred voice.
This is really a minor issue, but it eats at me that I have no idea why it's happening. Any ideas?
I'm pretty sure this is the same root cause as that other issue: many tools that need to interact with the UI (graphics, sounds...) fail within a tmux session: say, pbcopy/pbpaste, nohup, launchctl export|getenv|setenv, subl (Sublime Text command line tool), Retina rendering of apps launched under tmux, tools trying to access KeyChain (curl, ssh...), etc.
I remember GNU screen used to have the same problem but Apple patched it and now it works fine, but tmux still has the problem.
Solution (2017-05)
Borrowing from answers in linked issue, for tmux you can do this if you have Homebrew:
brew install reattach-to-user-namespace
Then put the following in your ~/.tmux.conf:
set-option -g default-command "reattach-to-user-namespace -l $SHELL"
I reproduced your issue on macOS 10.11.4, and the above fixed it.
See here for more info on the nature of the problem, and its workaround (using undocumented macOS APIs)
Better solution soon?
As mentioned in comment, future versions of tmux might do this dance natively, at least it's being worked on, and current master has the fix.

vi editing crashes within the shell-mode of emacs

Steps to reproduce this:
open emacs
M-x shell RET
vi tmpfile RET
Then you'll see the vi interface is a mess. To quit this, try to blind input :q! or just close the shell buffer.
The reason I use "vi" within emacs is that I use emacs shell-mode heavily and sometimes I ssh to another host within it. On the remote host, i have a reason to use "vi" when i need to edit some file and emacs is absent there.
Your help is appreciated.
I strongly suspect that a proper terminal emulator is necessary for anything like that.
Emacs has one, happily. Try running M-x ansi-term. You can run a shell within that (the default option) and then ssh to the remote host as you were in shell mode.
(If you didn't need to change hosts then you could run vi directly, instead of a shell.)
You might also find Remote ssh connection from within Emacs useful.
You will undoubtedly want to stick to char-mode in the terminal when using vi.
See: C-hig (emacs) Terminal emulator RET

Cannot get delete key to work with tmux and OSX

On OSX with tmux installed through homebrew I cannot seem to get my 'delete' key to work. I am using iterm2 and have my delete mapped to ^H. Without tmux the 'delete' key works fine.
To fix backspace on Apple M1 Pro OSX 12.4, tmux 3.3a
I had to do the following
brew install ncurses
$(brew --prefix)/opt/ncurses/bin/infocmp tmux-256color > ~/tmux-256color.info
tic -xe tmux-256color ~/tmux-256color.info
#https://github.com/tmux/tmux/issues/1257#issuecomment-581378716
#https://gist.github.com/bbqtd/a4ac060d6f6b9ea6fe3aabe735aa9d95
This might be some terminal emulation issue within your shell.
When you are in a tmux session, enter the following in the bash prompt and see if it works:
stty erase ^H
If this helps, check your terminal tty settings.
What worked for me is adding this to .tmux.conf.
# apps should know that this is 'screen' and not xterm. Slight compatibility
# reasons. tmux should be running in xterm-256colors, and set TERM so that
# applications within tmux see screen-256colors tmux does not support -bce
# (background color erase)
set -g default-terminal 'screen-256color'
I came across this and I found a solution for me.
Tmux uses ^? for delete. stty was not sending ^?.
I changed that using stty erase '^?' and then changed my preferences in iTerm2 for delete to send ^?
https://github.com/tmux/tmux/issues/335
I'm a few years late, but for me the problem was my $TERM setting ... changed it to screen-256color and that did the trick
Better solution here: https://gist.github.com/bbqtd/a4ac060d6f6b9ea6fe3aabe735aa9d95

Vim in Emacs

The question does not refer to some Vim-mode in Emacs, but to Vim inside Emacs. I am not waging any Editor-war. I just want to use Vim in Emacs.
http://dl.getdropbox.com/u/175588/emacs.png
You can get to Vim in Emacs with commands "M-x term" and "vim".
When I am using the Vim-Emacs, the typing is awkward. There are odd signs, such as "4m", "4mm" and "^?^?". The backspace and the x-button in insert mode do not work. The odd signs emerge when I press the latter keys. So
How can I get Vim properly working in Emacs?
[Updated Information]
The malfunctioning Vim-Emacs is at least in the following OSs:
Mac OS 10.5.6
What you're seeing is that the terminal setting $TERM in your shell/Vim session doesn't match what the EMACS terminal is doing. Mine works fine, with the exception that the delete key is mapped to DEL, 0x127, while Vim wants ^H, 0x8. Mine shows the $TERM setting to be "eterm-color".
Check what you have as $TERM
$ echo $TERM
and check the Vim docs for how to fix the backspace issue.
For backspace,
stty crt erase <CTRL-V><BACKSPACE>
Worked for me.
As for the rest, I don't know. Suppose it is something the shell outputs that the terminal doesn't handle. (Never used emacs 'term' before... prefer iTerm or Terminal.app for shell-related stuff. emacs 'term' has been called an "imperfect terminal emulator")

Resources