List of default Mac OS X command-line editing bash keyboard shortcuts
来源:互联网 发布:ppt mac版下载 编辑:程序博客网 时间:2024/06/05 12:01
本文转载至:https://maymay.net/blog/2007/07/18/list-of-default-mac-os-x-command-line-editing-bash-keyboard-shortcuts/
More and more often I find myself doing my work on the command line because it’s faster and more efficient. However, most users find that they end up spending a lot of time typing and re-typing commands, editting them, and then having to fix them. This is especially true if you’re new to the command line.
In addition, many times you want to run multiple commands with only slight variations. Perhaps you are benchmarking your Web server with ApacheBench and want to change some of its settings. Whatever you are trying to do, many shells actually offer a full suite of command-line editting shortcuts.
Some of them are built into the shell itself and others are configured elsewhere. Unfortunately, different distributions and different operating systems sometimes don’t have the same shortcut configuration. There are lots of lists out there for Bash keyboard shortcuts for Linux, and many of these work on Mac OS X, but they don’t all work.
So here’s a list as complete as I can make it of the default keyboard editting shortcuts configured on a Mac OS X machine running bash. An extra goodie is that some of these movement shortcuts work in any Coacoa text field, which means you don’t have to keep switching between bash’s command line movement shortcuts and the +arrow keys shortcuts anymore.
- CTRL+a
- Move cursor to beginning of the line. (I think of this as anchoring my cursor to the start.)
- CTRL+e
- Move cursor to the end of the line.
- CTRL+k
- Delete everything from under the cursor to the end of the line. (I think of this as killing the rest of my line.)
- CTRL+f
- Move forward one character. Identical to →.
- CTRL+b
- Move backward one character. Identical to ←.
- ESC+f
- Move forward one word.
- ESC+b
- Move backward one word.
- CTRL+u
- Delete everything from under the cursor the beginning of the line.
- CTRL+w
- Delete from under the cursor to the beginning of the word.
- CTRL+r
- Recall previous commands by searching for them.
- CTRL+t
- Transpose (swap) the two characters before the cursor with one another.
- ESC+t
- Transpose (swap) the two words before the cursor with one another.
- CTRL+y
- Paste the most previously-deleted string. Basically a sort of command-line editting “undo.”
- CTRL+z
- Stop the current process and send it to the background.
- CTRL+c
- Send an SIG_HUP to the current process. The net effect of doing this on the command line is that you cancel your current command and are presented with a blank new line.
- CTRL+d
- Send an end-of-file special character to the current process. Doing this at the command line is identical to closing your terminal window.
- CTRL+p
- Recall previous command executed. Identical to ↑.
- CTRL+d
- Forward delete.
- CTRL+h
- Backspace.
- CTRL+j
- Carriage return. Identical to hitting the return key.
- CTRL+m
- Newline. Identical to return.
- CTRL+l
- Repaint screen. This is useful if a program’s output is overwriting some text on your terminal. The effect of doing this on a command line is that you clear the screen. Note than in Apple’s Terminal.app, you can also press +K to clear the screen.
- CTRL-x + CTRL-x
- Mark current location in line and jump to beginning of line or second mark if defined. Repeat to jump to between both marks.
- CTRL+v
- Insert next character verbatim. This is how you escape control sequences. For instance, to literally send a
- CTRL+[
- Identical to ESC.
- ESC+c
- Capitolize word under cursor and move to next word.
- ESC+u
- Uppercase word under cursor and move to next word.
- ESC+l
- Lowercase word under cursor and move to next word.
- ESC+.
- Insert last word from previous command after cursor.
- TAB
- Auto-completes file, folder, and program names.
- ESC-?
- List the possible completions
- CTRL-x /
- List the possible filename completions
- ESC-/
- Attempt filename completion
- CTRL-x ~
- List the possible variable completions
- ESC- ~
- Attempt username completion
- CTRL-x $
- List the possible variable completions
- ESC-$
- Attempt variable completion
- CTRL-x @
- List the possible hostname completion
- ESC-@
- Attempt hostname completion
- CTRL-x !
- List the possible command completions
- ESC-!
- Attempt command completion
- ESC-TAB
- Attempt completion from previous commands in the history list
Note that this list assumes you’ve not reconfigured any of these shortcuts. Again, they’re the default keyboard assignments. Furthermore, they’re the default keyboard assignments for the default command-line editting mode, which is emacs mode. If you’re familiar with the vi
editor, you can change this to use all the cursor movement and deletion keys you’re familiar with by saying set -o vi
to your shell.
External references
Here’s some other people’s lists. They’re basically the same, but what the hey.
- BASH Command-Line Editing at lxpages – Also has a listing of vi-mode key shortcuts.
- The BASH Reference Manual for Command Line Editing
- Bash Features – Command Line Editing – discusses even more commands that
Readline
can do for you when using bash.
- List of default Mac OS X command-line editing bash keyboard shortcuts
- bash command line editing
- Xcode Command Line Tools for Mac OS X 10.9 Mavericks
- Mac Keyboard Shortcuts (Updating)
- Command Line -- List of command line commands
- Qt Creator Default Keyboard Shortcuts
- MAC OS X command
- Xcode3.2.X 中找不到Mac OS X - Command Line Utility - Foundation Tool
- MAC OS X uname command
- MAC OS X airport command
- Create & delete user accounts from the command line on Mac OS X
- 创建一个Mac OS X 下的Command Line Tool程序
- mac os x 10.9 安装 Command Line Tools ( xCode6 居然不能直接下载这工具 -_-!! )
- Minimal BASH-like line editing
- Getting List of All Processes on Mac OS X
- An A-Z Index of the Apple OS X command line
- List of chrome's command line switch
- How to Use Homebrew Zsh Instead of Mac OS X Default
- 如何激活Navicat?如何注册Navicat
- Android 开源框架ActionBarSherlock 和 ViewPager 仿网易新闻客户端
- 蓝鸥iOS从零基础到精通就业-OC语言入门 对象内存管理4
- 高级Java程序员要具备哪些知识
- github 入门
- List of default Mac OS X command-line editing bash keyboard shortcuts
- S5PV210 LCD屏
- Java 异常Exception e中e的getMessage()和toString()方法的区别
- ubuntu du/eog 命令
- android-bottomSheetBehavior详解
- docker运行mysql主从备份,读写分离
- spring mvc中的@RequestMapping的用法
- (0018)iOS 开发之Github 使用技巧
- 虚拟地址到物理地址的转换