MacOS Terminal 常用快捷键大全

您所在的位置:网站首页 window常用快捷键操作 MacOS Terminal 常用快捷键大全

MacOS Terminal 常用快捷键大全

2024-02-12 22:42| 来源: 网络整理| 查看: 265

文章目录 常用功能键控制窗体和页 | Work with Terminal windows and tabs编辑命令行 | Edit a command line选择操作 | Select and find text in a Terminal window快捷键组合 | Key Combinations操作 | Operations 标记和书签 | Work with marks and bookmarks其他 | Other shortcuts操作 | Operations 常用命令核心命令命令链命令管道管道命令命令历史文件管理目录管理搜索帮助引用

常用功能键

在macOS中有一些“特殊”的按键,被称之为 “modifier keys”,中文一般称为 “功能键”,部分常用的功能键如下表所示。

Modifier keySymbolCommand (or Cmd)⌘Shift⇧Option (or Alt)⌥Control (or Ctrl)⌃Caps Lock⇪FnFnLeft Arrow→Right Arrow←Up Arrow↑Down Arrow↓ 控制窗体和页 | Work with Terminal windows and tabs Shortcut 快捷键Action 动作⌘ + NNew window⌘ + TNew tab⇧ + ⌘ + Backslash (\)Show all tabs or exit tab overview⇧ + ⌘ + NNew command⇧ + ⌘ + KNew remote connection⌘ + IShow or hide Inspector⇧ + ⌘ + IEdit title⌥ + ⌘ + IEdit background color⌘ + Plus (+)Make fonts bigger⌘ + Minus (–)Make fonts smaller⌘ + Grave Accent (`)Circle through witndows⌘ + ⇧ + Tilde (~)Previous window⌃ + TabNext Tab⌃ + ⇧ + TabPrevious Tab⌘ + 1Select the first tab (also available for ⌘+2, ⌘ + 3, …, if corresponding tabs existed).⌘ + DSplit window into two panes⇧ + ⌘ + DClose split pane⌘+ + WClose tab⇧ + ⌘ + WClose window⌥ + ⌘ + WClose other tabs⌥ + ⇧ + ⌘ + WClose all⌘ + HomeScroll to top⌘ + EndScroll to bottom⌘ + Page UpPage up⌘ + Page DownPage down⌘ + ⌥ + Page UpLine up⌘ + ⌥ + Page DownLine down 编辑命令行 | Edit a command line ShortcutAction⌃ + AMove the insertion point to the beginning of the line⌃ + EMove the insertion point to the end of the line→Move the insertion point forward one character←Move the insertion point backward one character⌥ + →Move the insertion point forward one word⌥ + ←Move the insertion point backward one word⌃ + UDelete to the beginning of the line⌃ + KDelete to the end of the line⌥ + DDelete forward to the end of the word⌃ + WDelete backward to the beginning of the wordDeleteDelete one characterFn + DeleteForward+ delete one character⌃ + TTranspose two characters 选择操作 | Select and find text in a Terminal window 快捷键组合 | Key Combinations ShortcutAction⌘ + XCut⌘ + CCopy⌃ + ⇧ + ⌘ + CCopy without background color⌥ + ⇧ + ⌘ + CCopy plain text⌘ + VPaste⇧ + ⌘ + VPaste the selection⌃ + ⌘ + VPaste escaped text⌃ + ⇧ + ⌘ + VPaste escaped selection⌘ + FFind⌘ + GFind next⌘ + ⇧ + GFind previous⌘ + EFind using the selected text⌘ + JJump to the selected text⌘ + ASelect all⌃ + ⌘ + SpaceOpen the character viewer 操作 | Operations Press and hold the ⇧ and ⌘ keys and double+ click the path/URL Select a complete file path/URLTriple+ click the line Select a complete line of textDouble+ click the word Select a wordPress and hold the ⌥ key and drag to select text Select a rectangular block 标记和书签 | Work with marks and bookmarks ShortcutAction⌘ + UMark⌥ + ⌘ + UMark as bookmark⇧ + ⌘ + UUnmark⌘ + ReturnMark line and send return⇧ + ⌘ + ReturnSend return without marking⇧ + ⌘ + MInsert bookmark⌥ + ⇧ + ⌘ + MInsert bookmark with name⌘ + ↑Jump to previous mark⌘ + ↓Jump to next mark⌥ + ⌘ + ↑Jump to previous bookmark⌥ + ⌘ + ↓Jump to next bookmark⌘ + LClear to previous mark⌥ + ⌘ + LClear to previous bookmark⌘ + KClear to start⇧ + ⌘ + ASelect between marks 其他 | Other shortcuts ShortcutAction⌃ + ⌘ + FEnter or exit full screen⇧ + ⌘ + CShow or hide colors⌘ + Comma (,)Open Terminal preferences⌥ + ⌘ + RSoft reset terminal emulator state⌃ + ⌥ + ⌘ + RHard reset terminal emulator state⌘ + SExport text as⌘ + PPrint⇧ + ⌘ + SExport selected text as⌃ + RReverse search ⌘ history⌘ + RToggle “Allow Mouse Reporting” ⌥⌘ + ⌥ + OToggle “Use ⌥ as Meta Key” ⌥⌥ + ⌘ + Page DownShow alternate screen⌥ + ⌘ + Page UpHide alternate screen⌃ + ⇧ + ⌘ + Question Mark (?)Open man page for selection⌃ + ⌥ + ⌘ + Slash (/)Search man page index for selection 操作 | Operations Typing ⌘ + Period (.) is equivalent to entering ⌃ + C on the ⌘ line BreakHold down the ⌘ key and double + click the URL Open a URLDrag the file from the Finder into the Terminal window Add the complete path to a fileOn a ⌘ line, type one or more characters, then press Tab Complete directory or file nameOn a ⌘ line, type one or more characters, then press Tab twice Display a list of possible directory or file name completions 常用命令 按键/命令描述Ctrl + A移动光标至行首,也适用于大多数文本编辑器Ctrl + E移动光标至行尾,也适用于大多数文本编辑器Ctrl + Q清除当前行中的所有内容Ctrl + L清屏⌘ + K清屏Ctrl + U剪切光标前的所有字符Ctrl + K剪切光标后的所有字符Ctrl + W剪切光标前的内容,直到遇到为止Ctrl + Y粘贴上一次剪切的字符Ctrl + H与退格键相同Ctrl + C终止当前执行的进程Ctrl + D当没有进程在执行时退出当前终端,如果当前有进程就发送 EOF 命令给当前进程Ctrl + Z将执行中的任何东西放入后台进程。fg 可以将其恢复。Ctrl + _撤销最后一条命令(因为是下划线,所以实际上是 Ctrl + ⇧ + _)Ctrl + T将光标前的两个文字进行互换Ctrl + F将将光标向前移动一个字符Ctrl + B将将光标向后移动一个字符⌥ + →光标向前移动一个单词⌥ + ←光标向后移动一个单词Esc + T将光标前的两个单词进行互换Tab自动补全文件或文件夹的名称 核心命令 按键/命令描述cd [folder]切换目录,例如 cd DocumentscdHome目录cd ~Home目录cd /根目录cd +上一个目录ls文件列表ls + l文件详细列表ls + a列出隐藏文件ls + lh详细文件列表中文件大小以更友好的形式列出ls + R递归显示文件夹中的内容sudo [⌘ ]以超级用户身份执行命令open [file]打开文件 ( 相当于双击一个文件 )top显示运行中的进程,按q终止nano [file]使用 nano 打开编辑vim[file]clear清屏reset重置终端显示 命令链 Key/CommandDescription[⌘ + a]; [⌘ + b]不管命令 a 是否执行成功,执行完命令 a 后再执行命令 b[⌘ + a] && [⌘ + b]如果命令 a 执行成功就执行命令 b[⌘ + a][⌘ + a] &在后台执行命令 a 命令管道 Key/CommandDescription[⌘ + a] / [⌘ + b]运行命令 a,然后将结果给命令 b,例如 ps auxwww 管道命令 按键/命令描述history n列出最近执行过的 n 条命令ctrl+ r检索之前执行过的命令![value]执行最近以 value 开始的命令![value]:p显示最近以 value 开始的命令!!执行最后一次执行的命令!!:p显示最后一次执行的命令 命令历史 按键/命令描述history n列出最近执行过的n条命令ctrl+ r交互式检索之前执行过的命令![value]执行最近以’value’开始的命令![value]:p将最近以’value’开始的命令打印到终端!!执行上一条命令!!:p将上一条命令打印到终端 文件管理 按键/命令描述touch [file]创建一个新文件pwd显示当前工作目录.当前目录, 例如 ls .…上级目录, 例如 ls …ls + l …上级目录的文件详细列表cd …/…/向上移动两个层级cat连接或打印文件到屏幕上rm [file]移除文件, 例如 rm data.tmprm + i [file]移除时出现确认提示rm + r [dir]移除文件及内容rm + f [file]强制移除cp [file] [newfile]复制文件cp [file] [dir]复制文件到指定目录mv [file] [new filename]移动/重命名, 例如 mv file1.ad /tmppbcopy < [file]把内容复制到剪切板中pbpaste粘贴剪切板中的内容pbpaste > [file]把剪切板中的内容复制到文件里 pbpaste > paste+ test.txt 目录管理 按键/命令描述mkdir [dir]创建新目录mkdir + p [dir]/[dir]创建子目录rmdir [dir]移除目录 ( 仅限目录下没有内容时 )rm + R [dir]移除目录及内容less [file]根据当前终端窗口大小来输出文件内容[⌘ ] > [file]将命令输出的内容覆盖�到文件里[⌘ ] >> [file]将命令输出的内容附加到文件里[⌘ ] < [file]告诉命令从文件中读取内容 搜索

Key/⌘ | Description |:+ + ?:+ + | find [dir] + name [search_pattern] | 搜索文件, 例如 find /Users + name “file.txt” grep [search_pattern] [file] | 搜索文件中含有关键字的所有行, e.g. grep “Tom” file.txt grep + r [search_pattern] [dir] | 递归搜索目录的所有文件中包含该关键字的所有行 grep + v [search_pattern] [file] | 搜索文件中不含有关键字的所有行 grep + i [search_pattern] [file] | 搜索文件中含有关键字(不区分大小写)的所有行 mdfind [search_pattern] | 用 Spotlight 搜搜文件 (搜索范围包涵名字、内容、其他文件数据), 例如 mdfind skateboard mdfind + onlyin [dir] + name [pattern] | 用 Spotlight 搜索制定目录中名字包涵关键字的文件

帮助 按键/命令描述⌘ + h显示帮助信息⌘ + help显示帮助信息info [⌘ ]提供帮助man [⌘ ]显示指定命令的帮助信息whatis [⌘ ]显示指定命令的简述apropos [search+ pattern]使用关键字搜索描述内容 引用

[1] 0nn0, terminal-mac-cheatsheet, https://github.com/0nn0/terminal-mac-cheatsheet/tree/master/中文 [2] Apple Official Support, Keyboard shortcuts for Terminal on Mac, https://support.apple.com/guide/terminal/keyboard-shortcuts-trmlshtcts/mac [3] Apple Official Support, Mac keyboard shortcuts, https://support.apple.com/en-us/HT201236



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3