AutoKey Ctrl+Meta bind not working in xterm - xterm

This is my AutoKey script:
keyboard.send_keys("<up>")
It works perfectly in the default Ubuntu terminal and everywhere else.
But when I try to use it in xterm nothing happens.

See here for details: https://github.com/autokey/autokey/issues/132
AutoKey does not work with xterm by default, because xterm ignores "synthetic" key presses.
You can enable AutoKey in xterm by holding [CTRL]+[Left Mouse Button] to show xterm’s main menu and checking the allow SendEvents option.

Related

open xterm with allow-send-events set to True

I would like to open xterm from a terminal with the command
xterm
and specify the parameter
allow-send-events(toggle)
set to true (without having to do ctrl+click and set it to True manually once xterm is open)
Yet, reading through the term documentation I can't figure out what argument I have to specify to do this. Could someone kindly point it out?
EDIT
I would also be happy if there is a way to toggle this setting directly in the xterm with a typed command e.g.
xterm > allow-send-events("ON")
Would this be possible?
This command sets the resource allowSendEvents when starting xterm:
xterm -xrm '*allowSendEvents:true'
There also is a menu entry (control-button-one shows the menu).

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.

tmux is not using screen-256color even it is set in the config file

I am trying to get tmux to use screen-256color instead of xterm-256color, as it is not recommended. But when I am not using tmux, I would like to keep it as xterm-256color
A little bit of my setup, I am currently using iTerm2 and ssh to my development linux box, which is using zsh.
In my ~/.zshrc, I have:
export TERM="xterm-256color"
In my ~/.tmux.conf, I have:
set -g default-terminal "screen-256color"
With this configuraiton, without tmux, echo $TERM returns xterm-256color (which is right) and with tmux, echo $TERM is still returning xterm-256color instead of screen-256color.
Is there anything else I need to set in order for this to work?
Thanks!
The reason this does not work as expected is, that the zsh session that is started inside tmux overwrites TERM.
You should not set TERM from within in your shell. TERM is the way the terminal informs the shell and other applications about its capabilities (number of colors, key sequences for special keys, etc.). If you change TERM inside the shell, you change the what features the shell and applications expect from the terminal without the terminal itself knowing about it. Oftentimes this may not be an actual issue, but it is better to change the terminal configuration and set the desired value there.
You already did so when setting screen-256color in the configuration of tmux, which is essentially a terminal emulator, too. To do it for iTerm2 (tested with version 3.0.10):
Open the Preferences dialog (in the Menu: iTerm2 → Preferences, or press ⌘+,).
In the dialog go to Profiles → Terminal.
There you can choose the desired value for TERM under Report Terminal Type.
You could modify your .zshrc file to check if you are running in tmux:
[ -z "$TMUX" ] && export TERM=xterm-256color

Multiple tabs with tmux / tmuxinator and iTerm2

I would like to open all my useful stuff like here in iTerm2:
Not like this:
I'm using tmuxinator I've defined some tabs. I wonder if it's possible to get the former behaviour at all.
I just tried with tmux 1.8. Not totally obvious, but it works.
Here's what you do:
Open iTerm2 (latest, be sure to have at least tmux 1.8 installed).
In iTerm2, run command tmux <your tmuxinator profile>. Then detach ^b d.
In iTerm2, run command tmux -CC attach -t <your session>. You will see your tabs open in different windows.
Open menu Shell->Tmux->Dashboard
Select and hide all the windows.
Select all the hidden windows, and click Open in Tabs.
I'd like to know how to avoid the part about hiding and opening in tabs.
Just wanted to add some comments onto what justingordon mentioned (1).
This all works great. But I found how to streamline step 4-6 so it happens automatically.
Go to iTerm2's Preferences, under General, you will see a section titled tmux. There's an option that says When attaching, open unrecognized windows in. If you change the current selection from Windows to Tabs.
Two extra tips.
If you want you could select the option Automatically hide the tmux client session after connection. This will minimize the iTerm2 window in which you typed
tmux -CC attach
I also enabled the option Focus follows mouse. You can find this option under Preferences then Pointer. It should be the first option on the bottom left.
To use tmuxinator with iterm2 panes, use the following configuration:
attach: false
in combination with
on_project_exit:
- tmux -CC attach -t way
It looks like an issue in the documentations as told here
This is an example that I normally use:
# ~/.tmuxinator/way.yml
name: way
root: ~/learn/ruby/ruby-way/
attach: false
on_project_exit:
- tmux -CC attach -t way
# Runs before everything. Use it to start daemons etc.
on_project_start:
- export EDITOR="emacsclient --server-file=way -c"
- export VISUAL=$EDITOR
- emacs --daemon=way --title=RUBY-WAY
- $EDITOR &
windows:
- console:
- echo "A currar"
- testing:
- echo "A testear"
I hope that this helps.
Add this to your tmuxinator config:
attach: false
post: tmux -CC attach
https://github.com/tmuxinator/tmuxinator/pull/293

tmux Escape key exits server

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.

Resources