macos Mac OS X 中更好的终端——反转控制和命令键映射
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/75533/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Better terminal in Mac OS X -- reversing the control and command key-mappings
提问by someguy
I'm trying to have the same KDE Konsole experience within Mac OS X.
我正在尝试在 Mac OS X 中拥有相同的 KDE Konsole 体验。
Here's my (overly complicated?) setup:
这是我的(过于复杂?)设置:
- I have Control and Command swapped at the System Preferences level. (Can't live without this)
- Parallels lets you, at the Parallels application level, also reverse Control and Command. So I can undo the System Preferences setting (and get the setup I want within virtual Linux)
- 我在系统偏好设置级别交换了控制和命令。(没有这个就活不下去)
- Parallels 还允许您在 Parallels 应用程序级别反转控制和命令。所以我可以撤销系统偏好设置(并在虚拟 Linux 中获得我想要的设置)
I want this same per-application-opt-out for the Mac OS X Terminal app. Is it possible?
我希望 Mac OS X 终端应用程序的每个应用程序选择退出相同。是否可以?
回答by dralthiace
The solution you're looking for is KeyRemap4MacBook. There is a Tiger, Leopard, Snow Leopard, and Lion version.
您正在寻找的解决方案是KeyRemap4MacBook。有虎、豹、雪豹和狮子版本。
Once installed, goto System Preferences-> KeyRemap4MacBook
安装后,转到System Preferences-> KeyRemap4MacBook
Then select the following options:
然后选择以下选项:
- Change Command_L Key (Left Command)
- ---> Command_L to Control_L (except Terminal, Virtual Machine, RDC)
- Change Control_L Key (Left Control)
- ---> Control_L to Command_L (except Terminal, Virtual Machine, RDC)
- 更改 Command_L 键(左命令)
- ---> Command_L 到 Control_L(终端、虚拟机、RDC 除外)
- 更改 Control_L 键(左控制)
- ---> Control_L 到 Command_L(终端、虚拟机、RDC 除外)
You can repeat this for Command_R (Right Command) and Control_R (Right Control) also if you desire. Tested and working on my Macbook.
如果您愿意,您也可以对 Command_R(右命令)和 Control_R(右控制)重复此操作。在我的 Macbook 上测试和工作。
回答by haa
You can simply ssh into the Linux/Unix systemand run X11 programs direct to your Mac screen: ssh -X user@host_or_ipaddress
, login, and just run the X11 programs you want (e.g. emacs&
) and the X11 apps will appear on the Mac display.
您可以简单地通过 ssh 进入 Linux/Unix 系统并直接在您的 Mac 屏幕上运行 X11 程序:ssh -X user@host_or_ipaddress
,登录,然后只需运行您想要的 X11 程序(例如emacs&
),X11 应用程序就会出现在 Mac 显示器上。
Pros:
优点:
- X11 windows work just like any other window, including Exposé goodness, etc...
- No need to work only inside the Parallels console window
- Same solution works with any Linux/Unix system, remote or virtual
- ssh connection is secure even over the internet
- X11 窗口就像任何其他窗口一样工作,包括 Exposé goodness 等...
- 无需仅在 Parallels 控制台窗口内工作
- 相同的解决方案适用于任何 Linux/Unix 系统,远程或虚拟
- 即使通过互联网,ssh 连接也是安全的
Tech info:
技术资料:
- "ssh -X" turns on X11 forwarding for the ssh connection, i.e. the X11 display connection is tunneled through ssh securely
- "ssh -X" also handles X11 authentication tunneling
X11.app
is automagically started on OSX bylaunchd
when needed- X11 can connect to displays over the network, which is one of the few cool things about it ;-)
- “ssh -X”打开 ssh 连接的 X11 转发,即 X11 显示连接安全地通过 ssh 隧道
- “ssh -X”还处理 X11 身份验证隧道
X11.app
launchd
在需要时自动在 OSX 上启动- X11 可以通过网络连接到显示器,这是它为数不多的很酷的事情之一;-)
回答by vikor
回答by dorserg
The 2016 solution is to use Karabineropen-source program which allows you to remap modifier and other keys with very fine granularity, for example
2016 年的解决方案是使用Karabiner开源程序,它允许您以非常细的粒度重新映射修饰符和其他键,例如
- Remap only the left? Cmdor Optionkey.
- Remap a key only for specific applications, e.g. only inside Terminal, Emacs, or virtual machine.
- 仅重新映射左键? Cmd或Option键。
- 仅针对特定应用程序重新映射密钥,例如仅在终端、Emacs 或虚拟机内。
For example, here's how to remap left ? Cmdkey to act as Ctrlonly inside Terminal(and leave the right one unaffected so that you could still use e.g. ? Cmd + Tabto switch between apps):
例如,这里是如何重新映射左键? Cmd以Ctrl仅在终端内充当(并使右键不受影响,以便您仍然可以使用 eg? Cmd + Tab在应用程序之间切换):
回答by dorserg
You can customize the command keys used for an individual application in System Preferences > Keyboard & Mouse > Keyboard Shortcuts. I think (if I understand correctly what you're trying to do) that this might allow you to accomplish your goal. You could remap all of Terminal's command keys to use control instead of command, to get them out of your way... but then you might need to do a lot of customization on the machines you ssh into, so that they use Command instead of control
您可以在“系统偏好设置”>“键盘与鼠标”>“键盘快捷键”中自定义用于单个应用程序的命令键。我认为(如果我理解正确的话)这可能会让你实现你的目标。您可以重新映射所有终端的命令键以使用控制而不是命令,使它们不受您的影响……但是您可能需要在 ssh 进入的机器上进行大量自定义,以便它们使用命令而不是控制
It seems that you're going to have to do an ENORMOUS amount of work just to allow you to use your pinky instead of your thumb for the modifier key.
似乎您将不得不做大量的工作才能让您使用小指而不是拇指作为修饰键。
Another possibility: user preferences can be manipulated by the "defaults" command. I haven't been able to find a way to use this to control they modifier key mappings, but it should logically be possible (if you're willing to do a lot of digging). If so, then you could write short scripts to switch back and forth between Mac default and your swapped mode. Trigger the scripts with Quicksilver, and whenever you use Terminal you can call one script, and whenever you leave it you can call another. Again, a big pain to achieve what you want, but it mightbe possible.
另一种可能性:用户首选项可以通过“defaults”命令进行操作。我一直无法找到一种方法来使用它来控制它们的修饰键映射,但从逻辑上讲应该是可能的(如果您愿意进行大量挖掘)。如果是这样,那么您可以编写简短的脚本在 Mac 默认和交换模式之间来回切换。使用 Quicksilver 触发脚本,无论何时使用终端,您都可以调用一个脚本,而无论何时离开它,您都可以调用另一个脚本。再一次,实现你想要的东西是一个很大的痛苦,但它可能是可能的。
I don't think there's a clean and simple solution.
我不认为有一个干净和简单的解决方案。
I've seen third-party programs that give more control over manipulating modifier keys, if you're willing to install them (probably kernel extensions). They mightbe able to do what you want, but I don't recall the names. If you google for programs to fix emacs and vi keys you might find them.
如果您愿意安装它们(可能是内核扩展),我已经看到第三方程序可以更好地控制修改键的操作。他们也许可以做你想做的事,但我不记得名字了。如果您在谷歌上搜索修复 emacs 和 vi 键的程序,您可能会找到它们。
Good luck.
祝你好运。
回答by Mario F
I had exactly the same problem as you. I've remapped Command to CAPS Lock, and Control to Command, but as a frequent Linux user I want both setups to be as similar as possible. This is how I solved it:
我和你有完全一样的问题。我已经将 Command 重新映射到 CAPS Lock,将 Control 重新映射到 Command,但作为一个经常使用 Linux 的用户,我希望这两种设置尽可能相似。我是这样解决的:
- Install Keyboard Maestro(not free, but totally worth it), and set it up to run at login.
- Inside KM, define macros to send CMD+{key}to CTRL+{key}inside Terminal.
- 安装Keyboard Maestro(不是免费的,但完全值得),并将其设置为在登录时运行。
- 内部KM,定义宏发送CMD + {}键以CTRL + {}键内的终端。
If you want to remap a lot of keys this is a lotof work. But I've already done it myself, you can just download this file kmmacros. Double-clicking is enough to install it. A couple of caveats:
如果您想重新映射很多键,这是一项大量工作。但是我自己已经做了,你可以下载这个文件kmmacros。双击就足以安装它。几个警告:
- You need to set Terminalto use option as a meta key (Terminal > Preferences > Keyboard).
- The bindings are only for emacs-mode. Thischeat sheet should be helpful.
- Most default shortcuts don't work anymore (CMD-N, CMD-C, ...), and the menu in Terminaldoes not reflect this. For some conflicts (New Window, Close Window), I've taken the ones from Gnome.
- 您需要将终端设置为使用选项作为元键(终端 > 首选项 > 键盘)。
- 绑定仅适用于 emacs 模式。这份备忘单应该会有所帮助。
- 大多数默认快捷方式不再起作用(CMD-N、CMD-C、...),并且终端中的菜单没有反映这一点。对于某些冲突(新窗口、关闭窗口),我从 Gnome 中获取了冲突。