使 Sublime Text 颜色通用 Bash 命令(cp,mv,...)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29256263/
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
Make Sublime Text color common Bash commands (cp, mv, ...)
提问by becko
By default Sublime Text colors Bash keywords like echo
, for
, time
, and some more. However, I like how gEdit also colors cp
, mv
, and some others that Sublime Text doesn't highlight. How can I make Sublime Text recognize cp
and mv
(and maybe others) as keyboards and highlight them, for Bash script files (.sh)?
默认情况下,Sublime Text 会为 Bash 关键字(如echo
、for
、等)着色time
。但是,我喜欢 gEdit 的颜色cp
,mv
以及 Sublime Text 没有突出显示的其他一些颜色。对于 Bash 脚本文件 (.sh),如何让 Sublime Text 识别cp
和mv
(可能还有其他人)作为键盘并突出显示它们?
回答by AGS
Command Palette -> PackageResourceViewer: Open Resource
-> ShellScript
-> Shell-Unix-Generic.tmLanguage
命令面板 -> PackageResourceViewer: Open Resource
-> ShellScript
->Shell-Unix-Generic.tmLanguage
Scroll down to ~ line 1750 and add/edit support.function.builtin.shell
向下滚动到 ~ 第 1750 行并添加/编辑 support.function.builtin.shell
<dict>
<key>match</key>
<string>(?<![-/])\b(?:alias|bg|bind|break|builtin|caller|cd|command|....)\b</string>
<key>name</key>
<string>support.function.builtin.shell</string>
</dict>
回答by LinuxSecurityFreak
1st:Install the Package Control
第一:安装包控件
Menu Tools -> the very bottom click on Install Package Control and wait a few seconds, it will tell you once successfully installed:
菜单工具 -> 最底部点击安装包控制并等待几秒钟,它会告诉你一旦安装成功:
Package Control was successfully installed
包控制已成功安装
(Restart sublime-text
for that menu item to disappear.)
(重新启动sublime-text
以使该菜单项消失。)
2nd:View the Command Palette
第二:查看命令面板
Menu Tools -> at the very top click on Command Palette.
菜单工具 -> 在最顶部单击命令面板。
3rd:Search for Package Control: Install Package
第三:搜索包控制:安装包
Just type into the search box:
只需在搜索框中输入:
Package Control: Install Package
包控制:安装包
And click on it.
并点击它。
4th:Install the PackageResourceViewer plugin
第四:安装PackageResourceViewer插件
Just type into the search box:
只需在搜索框中输入:
PackageResourceViewer
包资源查看器
And click on it.
并点击它。
It will notify to about successful installation very shortly in the very bottom status bar.
它会在最底部的状态栏中很快通知您安装成功。
5th:Open the resource viewer
5:打开资源查看器
View the Command Palette again.
再次查看命令面板。
Just type into the search box:
只需在搜索框中输入:
PackageResourceViewer: Open Resource
PackageResourceViewer:打开资源
And click on it.
并点击它。
6th:Open ShellScript resource
6:打开ShellScript资源
Just type into the search box:
只需在搜索框中输入:
ShellScript
脚本
And click on it.
并点击它。
7th:Open Bash sublime-syntax configuration file
7:打开 Bash sublime-syntax 配置文件
Just type into the search box:
只需在搜索框中输入:
Bash.sublime-syntax
Bash.sublime 语法
And click on it.
并点击它。
It will open a file.
它将打开一个文件。
8th:Search for support.function.builtin.shell
Search via CTRL+Ffor this code:
support.function.builtin.shell
9th:Edit the match
line content to your liking
Out of the box this contains in the build 3126:
'(?<![-/])\b(?:alias|bg|bind|break|builtin|caller|cd|command|compgen|complete|dirs|disown|echo|enable|eval|exec|exit|false|fc|fg|getopts|hash|help|history|jobs|kill|let|logout|popd|printf|pushd|pwd|read|readonly|set|shift|shopt|source|suspend|test|times|trap|true|type|ulimit|umask|unalias|unset|wait)\b'
第八:搜索support.function.builtin.shell
通过CTRL+搜索F此代码:
support.function.builtin.shell
第九:match
根据自己的喜好编辑行内容
开箱即用,它包含在构建 3126 中:
'(?<![-/])\b(?:alias|bg|bind|break|builtin|caller|cd|command|compgen|complete|dirs|disown|echo|enable|eval|exec|exit|false|fc|fg|getopts|hash|help|history|jobs|kill|let|logout|popd|printf|pushd|pwd|read|readonly|set|shift|shopt|source|suspend|test|times|trap|true|type|ulimit|umask|unalias|unset|wait)\b'
In later versions, I have tested build 3176, the file is structuredheavily and there is no longer a single line to edit.
在以后的版本中,我测试了 build 3176,文件结构很重,不再需要编辑一行。
You will literally have to dig through the file and edit it to your liking.
您实际上必须仔细阅读文件并根据自己的喜好进行编辑。
10th:Save the file and continue working
10th:保存文件并继续工作
CTRL+S
CTRL+S
You don't need to restart sublime-text
in order for the new settings to apply.
您无需重新启动sublime-text
即可应用新设置。