xdotool output lost in iTerm2 - macos

I am running Mac OS X 10.7.5. I have installed XQuartz v2.7.4, and along with it X11 v2.6.5. I have started iTerm2 with Xserver, and I believe it's working correctly since when I run xdpyinfo, the beginning of the output in xterm and in iterm2 is the same.
█ $xdpyinfo
name of display: :0
version number: 11.0
vendor string: The X.Org Foundation
vendor release number: 11006000
X.Org version: 1.10.6
...
However, when I run any xdotool commands in iTerm2 the output does not show up in the same window:
█ $ xdotool key f
█ - MacBook-Air:~ ()
Whereas, when I run from xterm:
bash-3.2$ xdotool key f
fbash-3.2$ f
So I can tell that in xterm the output from the command is going to the right window, but that doesn't seem to be the case for iTerm2. Please let me know if you have an idea of what I may be doing incorrectly or missing. Thanks!

The problem is that iTerm2 is not an XQuartz client, and while you are typing the commands, there is no current XQuartz window (since MacOS's focus is on the the iTerm2 window — not an XQuartz window.
The xdotool manual page tells you that the key command has an option which would be used to redirect events to other windows:
--window window
Send keystrokes to a specific window id. . You can use "WINDOW
STACK" references like "%1" and "%#" here. If there is a window
stack, then "%1" is the default, otherwise the current window
is used.
If you gave it a valid window id using --window, it likely would work as intended.

Related

VS Code Terminal Won't Map Option Key to Meta

I am trying to enable the option/alt key as Meta in my terminal in VS Code. I set the "terminal.integrated.macOptionIsMeta": true in my settings.json but it is not working.
I made this same change to my system Terminal app and iTerm2.
iTerm is the only one that works. In iTerm the option key is mapped to Meta but not in the VS Code terminal or Terminal.
Does anyone know why this could be or how to correct it?
OS X 10.15.7
VS Code Version: 1.63.2
iTerm2 Build 3.4.12
Terminal Version 2.10 (433)
VS Code
iTerm2
Terminal
This appears to be an issue with how OS X handles tmux-keyboard integration, not VS Code.
The relationship between Option/Alt and Esc/Meta does not work well. Even if this feature is enabled in your terminal emulator. Consequently, when binding the Meta+ to an action in .tmux.conf the resulting behavior is not as expected.
bind -n M-j select-pane -L
bind -n M-k ​select-pane -R
Alt+j and Alt+k work as expected.
However, when binding the Meta+[DirectionKey]:
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
Alt+Left and Alt+Right do NOT work and you need to use Esc+Left and Esc+Right.

How to clear screen in Windows command prompt window with a hotkey?

I have searched a lot to find a way (keyboard shortcut) to clear the screen of the console window of cmd on Windows 10. I tried Ctrl+L and Ctrl+K and ESC, but nothing worked for me and I didn't find any satisfied solution.
Thanks a lot for the AutoHotkey script.
I modified the script to input Python script to clear the screen when using scrapy shell like that
Send from os import system{Enter}
Send cls = lambda: system)'cls'({Enter}
Send cls)({Enter}
It worked well but I noticed the value 0 at the top of the window.
The console window after execution of AutoHotkey script with █ as blinking caret symbol.
0
>>> █
How can I remove that zero?
The simplest way of clear window in command prompt is typing: cls + enter
Ecs is a key to exit input of command prompt, it does noting on clear window
Ctrl + L and Ctrl + K are not correct short key in Linux command prompt. If you really want to make it a short cut key of cls, you can use AutoHotKey to write a short script
; -------------------------------------------------------------------------
; Cntr-L should clear screen
; -------------------------------------------------------------------------
#IfWinActive ahk_class ConsoleWindowClass
^L::
Send cls{Enter}
return
#IfWinActive
Official website of autohotkey: https://www.autohotkey.com/
Windows 10 + python 3.9 clear command prompt script:
import os
os.system('cls')

AutoKey Ctrl+Meta bind not working in 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.

X11: move an existing window via command line?

Given an X client window ID, is there a way to move that window or change its geometry from the command line?
$ xlsclients -a
Window 0x3000001:
Machine: ohm
Name: Terminal
Icon Name: foo
Command: foo
Instance/Class: foo/bar
$ xmovewindow -id 0x3000001 --geometry +100+200 <-- this is what I would like to do
I think xdotool will do the job.
xdotool lets you programatically (or manually) simulate keyboard input and mouse activity, move and resize windows, etc. It does this using X11's XTEST extension and other Xlib functions.
E.g.
$ xdotool windowfocus 0x1a00ad2
will focus the window with id 0x1a00ad2. There's also a windowmove command which is probably the one you're looking for.
wmctrl is slighty more advanced. It is compatible with EWMH/NetWM X window managers as you can read on their website. I don't think you'll need it to be compatible with those though.

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