Make cmd the meta key in emacs running in iTerm - emacs

I run Mac OSX 10.9 (Mavricks) and use EmacsMac installed via macports package emacs-app-mac (emacs version 24.3.1). The GUI uses cmd as the meta key, which is what I want. But I also run the same binary (emacs points to Emacs -nw) in my iTerm2 terminal (Build 1.0.0.20131116), where meta-key is alt instead of cmd.
In iTerm preferences i've tried the different settings for "left option key acts as ..." but no joy there. Is there a way I can get emacs in iTerm to recognise cmd as my meta key?

Preferences -> Profiles -> Keys has what you want.
Mine is set to +Esc. I know, meta looks like what you want but it is not it.

Related

Sending commands prefixed with `Shift`-`Alt` to VSCode's integrated terminal in Windows 11

Is it possible to send keyboard shortcuts prefixed with Shift-Alt to VSCode's integrated terminal in Windows 11?
I'm using Tilish, a nifty tmux plugin that by default uses several shortcuts prefixed with Shift-Alt (e.g. Shift-Alt-q to close a panel). Unfortunately, commands prefixed with Shift-Alt don't seem to get propagated to the terminal.
Ideally I'd prefer all input go to the terminal while my input focus is there.
Thanks!

How to transfer VSCode key mapping on windows to ubuntu

I use vs-code as my go-to editor on Windows. Recently I've installed on Ubuntu and now the default key mapping is different.
Is there any way I can set the key mapping on Ubuntu similar to what they were for Windows, or at least a subset of it?
I have created an extension that provides the default Windows keybindings. It is on the VSCode extension marketplace and called Windows Default Keybindngs.
I have tested it on Linux with VSCode 1.38.0 and 1.36.1.
The new bindings take precedence where there is a conflict, but existing, non-conflicting bindings are still available.
Basically all I did was use HolyBlackCat's suggestion to run "Preferences: Open Default Keyboard Shortcuts (JSON)" and stuff the result into the appropriate place in package.json. (Plus document it and figure out how to publish it!)
Update 2020-06-05: In response to a question in a comment, I did a search and found LinuxKeybindings, an extension that provides the default Linux bindings. I have not tried it myself but this could be useful for those wanting the Linux bindings instead of Windows bindings.
A quick way to transfer the default keymap without an extension:
VS Code Windows (source)
open "Show All Commands" / Ctrl+Shift+P
select Open Default Keyboard Shortcuts (JSON) (docs)
Note: #Ville Venäläinen's answer did not work for me for default key bindings.
copy everthing to clipboard or a temporary file (like you need it)
VS Code Linux (target)
open user keybindings / CTRL + K CTRL + S → click Open Keyboard Shortcuts (JSON) button
paste all previously copied settings to this file. If you already have custom user settings, make sure to don't overwrite them. Also preserve the file JSON structure [{}, {}, ...].
Additional notes
You can make a backup of the keymaps before. Default file locations analogue to settings.json:
Linux: $HOME/.config/Code/User/keybindings.json
Windows: %APPDATA%\Code\User\keybindings.json
If needed, also copy custom user keyboard shortcuts in source and append them in the target keybindings.json file (as explained above).
This worked well for me with a Debian target distro. If you should happen to get a key conflict, just delete or change the relevant key binding for this case.
At least with the latest VSCode, you can go to File -> Preferences -> Keyboard Shortcuts. On that page, there is a text under the search field: For advanced customizations open and edit keybindings.json. That will open you a view showing the default keybindings on the left and an empty file on the right for your own bindings. You can try to copy those bindings from Windows and save the to your Ubuntu one.
If you're not customizing your keymap, look through VSCode Keymaps for keymaps and install on both Windows and Ubuntu.
I personally use the code-settings-sync extension.
Synchronize Settings, Snippets, Themes, File Icons, Launch, Keybindings, Workspaces and Extensions Across Multiple Machines Using GitHub Gist.

Integrated Terminal Setting VS Code and iTerm returns zsh

I'm trying to use iterm as my focus terminal inside vscode. I've setup "terminal.external.osxExec": "iTerm.app", but I get zsh instead of iTerm.
I'm able to right click on a file and open in iterm but I love the integrated terminal, and want to use iTerm here.
How do I use iterm as my terminal?
You cannot set iTerm as the integrated terminal for VS Code. I have explained below why.
iTerm is not a shell but a terminal emulator which in your case is running the zsh shell.
I believe you are confusing the terms Shell and a terminal emulator.
iTerm is a terminal emulator. Some examples of terminal emulator are Gnome terminal, Guake, Xterm etc. They provide a display to the shell which is installed in the OS.
A shell is a command line interface that reads and interprets your commands. Examples of shell are bash which comes by default in Linux and other shells like zsh, fish, sh.
Visual Studio Code integrated terminals use the shell itself and not the terminal emulator. In Windows OS the distinction between shell and terminal emulator is not present so Powershell and Command Prompt are both the shell and the emulator.
But for Unix like OSes there is a distinction.
I believe you use iTerm as the terminal emulator and the shell used is zsh (pronounced Z Shell which is a fork of bash Bourne Again Shell).
Here is a wikipedia article on Unix Shell. This talks about what a Unix shell really is.
This link is about Terminal emulators which also talks about the history of terminals.
This link gives a list of terminal emulators
that are available. iTerm is a terminal emulator for Mac OS.
Though you can customize your normal terminal using this
then later remember to go to settings then assign the new configurations to override the default ones
"terminal.external.osxExec": "iTerm.app",
"terminal.integrated.fontFamily": "Meslo LG S DZ for Powerline",
"terminal.explorerKind": "external",
The accepted answer has precisely addressed the question.
Here I will add a side note:
Why do you want iterm2 in integrated shell?
My answer is: I want the "copy on selection" feature of iterm2.
Actually vscode has this setting for the integrated terminal!
Settings > Terminal > Integrated: Copy On Selection
By the way, vscode also allows you to split the terminal, which is like iterm2.

How Can I Get MinTTY (Cygwin Terminal) to Open Emacs in a New Window?

I can't figure out why this isn't easy to find on Google, but after searching for about 10 minutes, I just decided to give up and post here.
The subject basically says it all. I'm running MinTTY as a cygwin terminal on a Windows XP desktop. All I want to do is have emacs open up in a new window rather than inside my terminal. What would be best is a switch for this, so I could toggle it depending on my current needs. This seems like something that would be useful to a lot of people, and I know I've done it before on Linux boxes, so I imagine there must be a way to do this in cygwin too. Anyone know how?
Just start a new mintty, telling it to invoke emacs:
mintty emacs
There are a couple of scenarios that you might clarify:
Running the cygwin version of emacs within a standard windows environment will call emacs within the current shell
If the Cygwin X-Windows server (i.e., “XWin Server”) has been started and the DISPLAY environment variable has been set in the mintty terminal (e.g., export DISPLAY=":0"), calling emacs will start it in its own window.
running the Windows version of emacs within the cygwin terminal should launch the new frame you are seeking.
If you want a separate emacs 'window', you would be best served by installing the Windows native version of emacs (I use the gnu emacs precompiled binaries), and calling it from the cygwin terminal.

windows key in emacs in -nw mode

I add the following line to my ~/.emacs
(global-set-key (kbd "") 'other-window)
It works on emacs GUI mode. But if I open emacs in terminal (Ubuntu 10.04) with the option
-nw, then Win + Right just give right. I tried many key
combinations with the windows key, it seems that windows key doesn't function in the
terminal. I guess that the default terminal in Ubuntu doesn't recognize teh Win
key at all. If I want to use Win key in the terminal, I have modify the source
code of termianl. Is this right?
The win key under ubuntu becomes the modifier Super, I don't think that the terminal recognizes this as a key modifier. You could switch the windows key to something else or just use ctrl or meta keys.