Skip to content

Commit c25f1fa

Browse files
committed
翻译 externalCommands_en.png
1 parent 9d44553 commit c25f1fa

File tree

3 files changed

+76
-103
lines changed

3 files changed

+76
-103
lines changed
Lines changed: 75 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,45 @@
1-
## 外部命令能干什么呢?
1+
## What can external commands do?
22

3-
外部命令可以让您在HBuilderX中通过菜单、快捷键等方式调用外部程序或命令行
3+
External commands allow you to call external programs or command lines through menus, shortcut keys, etc. in HBuilderX.
44

5-
## 使用场景
5+
## scenes to be used
66

7-
- 压缩文件与解压
8-
- 压缩图片
9-
- 文档转换(比如markdown转pdf
10-
- 调用python、shell脚本
11-
- 打开本地的某个程序
12-
- 传输文件到服务器
13-
- 操作服务器的某些服务(如启动、停止、重启nginx)
14-
- 下载文件
15-
- 安装apk到手机
16-
- 上传应用到应用分发网站(比如蒲公英)
17-
- 批量压缩
18-
- 其它的自动化操作
19-
- 上传文件到七牛云、阿里云等
7+
- Compress and decompress file
8+
- Compress images
9+
- Document conversion(For example, markdown to pdf
10+
- Call python, shell script
11+
- Open a local program
12+
- Transfer files to the server
13+
-O perate certain services of the server (such as start, stop, restart nginx)
14+
- download file
15+
- Install apk to phone
16+
- Upload the application to the application distribution website (such as Dandelion)
17+
- Batch compression
18+
- Other automated operations
19+
- Upload files to Qiniu Cloud, Alibaba Cloud, etc.
2020

21-
## 外部命令在哪里?
21+
## Menu
2222

23-
菜单【工具】-->【外部命令】
23+
Click the menu [Tools] --> [External Commands] --> [Custom External Commands], you can customize the external commands, the format is json.
2424

25-
如下图,您可以看到几个例子
25+
<img src="/static/snapshots/tutorial/menu_tool/externalCommands_en.png" class="hd-img" />
2626

27-
<img src="/static/snapshots/tutorial/externalCommands.png" />
2827

29-
点击菜单【工具】-->【外部命令】-->【自定义外部命令】,就可以自定义外部命令,格式为json。
28+
## Example
3029

31-
## 外部命令示例
30+
### Example 1: Compress and decompress
3231

33-
### 例子1:压缩、解压
34-
35-
windows例子:
36-
37-
> 注意: windows的软件大部分安装在`Program Files`目录,需要注意空格与斜杠。如下例子
32+
**windows:**
3833

3934
```shell
4035
[{
41-
"name": "文件: 压缩7z格式",
36+
"name": "Compressed to 7z",
4237
"command": "\"C:/Program\ Files/7-Zip/7z.exe\" a ${file}.7z ${file}",
4338
"type": "process",
4439
"key": ""
4540
},
4641
{
47-
"name": "文件: 压缩zip格式",
42+
"name": "Compressed to zip",
4843
"command": [
4944
"C:/Program Files/7-Zip/7z.exe",
5045
"a",
@@ -55,7 +50,7 @@ windows例子:
5550
"key": ""
5651
},
5752
{
58-
"name": "文件: 解压",
53+
"name": "Decompress",
5954
"command": "\"C:/Program Files/7-Zip/7z.exe\" x ${file}",
6055
"type": "shell",
6156
"key": ""
@@ -64,195 +59,172 @@ windows例子:
6459

6560
```
6661

67-
Mac例子:
62+
**Mac: **
6863

6964
```shell
7065
[
7166
{
72-
"name": "压缩目录为bz2",
67+
"name": "Compressed to bz2",
7368
"command": "cd ${fileDir} && tar -jcvf ${fileBasename}.tar.bz2 ${fileBasename}",
7469
"type": "terminal",
7570
"key": "alt+shift+e"
7671
},
7772
{
78-
"name": "解压zip包",
73+
"name": "Decompress zip",
7974
"command": "unzip ${file}",
8075
"type": "terminal",
8176
"key": "alt+shift+e"
8277
}
8378
]
8479
```
8580

86-
### 例子2:调用外部python、shell等脚本
81+
### Example 2: Call external python script
8782

8883
```
8984
[{
90-
"name":"调用python脚本",
85+
"name":"run python script",
9186
"command":"python script.py",
9287
"type" : "terminal",
9388
"key":"alt+shift+p"
9489
}]
9590
```
9691

97-
### 例子3: 调用TinyPNG无损压缩图片
98-
99-
大部分情况下, 图片都是需要压缩的,为了 更快的打开网页,节省流量
100-
推荐:[TinyPNGg官网](https://tinypng.com) 无损压缩,良心网站,每月500张免费。
92+
### Example 3: Call TinyPNG to losslessly compress images
10193

102-
如下所示:`YOUR_API_KEY`是你申请的key, --output 可以指定目录文件名,注意如果和当前图片路径一致,会覆盖原先图片
10394
```
10495
[{
105-
"name":"调用TinyPNG无损压缩图片",
96+
"name":"Call TinyPNG",
10697
"command":"curl --user api:YOUR_API_KEY --data-binary @${file} -i https://api.tinify.com/shrink --output ${file}",
10798
"type" : "terminal",
10899
"key":"alt+shift+m"
109100
}]
110101
```
111-
注意:curl是mac自带的命令,windows上如需使用curl,请下载[curl](https://curl.haxx.se/windows/) 安装
112102

113-
### 例子4:下载文件
114-
mac上下载文件的命令有:wget、curl
115-
windows上下载文件的命令是:bitsadmin.exe
103+
### Example 4: Download File
104+
105+
The commands for downloading files on mac are: `wget`, `curl`
106+
107+
The command to download files on windows is: `bitsadmin.exe`
108+
116109
```
117110
[{
118-
"name":"下载文件",
119-
"command":"wget -c ${userInput:输入要下载的地址url}",
111+
"name":"Download File",
112+
"command":"wget -c ${userInput: url}",
120113
"type" : "terminal",
121114
"key":"alt+shift+m"
122115
}]
123116
```
124-
注意: `${userInput:弹框说明}` 会在当前屏幕弹框,可以输入内容
125117

126-
### 例子5: Mac: 复制项目到远程linux服务器
118+
Note: `$(userInput:Box description)` will pop up on the current screen, you can input content
119+
120+
### Example 5: Mac: scp file to linux
127121

128-
scp是linux和mac上才能用的命令,windows上不可以使用哦
122+
`scp` is a command that can only be used on linux and mac, not on windows.
129123

130124
```
131125
[{
132-
"name":"scp传输项目到服务器",
133-
"command":"scp -r ${projectDir} 用户名@ip:服务器目录路径",
126+
"name":"scp file to linux",
127+
"command":"scp -r ${projectDir} user@ip:server_path",
134128
"type" : "terminal",
135129
"key":"alt+shift+m"
136130
}]
137131
```
138132

139-
### 例子6: 远程linux服务器 重启/启动nginx服务
133+
### Example 6: linux nginx start
140134

141135
```
142136
[{
143-
"name":"远程服务器重启nginx",
144-
"command":"ssh 用户@ip '/opt/nginx/sbin/nginx -s reload'",
137+
"name":"linux: reload nginx",
138+
"command":"ssh user@ip '/opt/nginx/sbin/nginx -s reload'",
145139
"type" : "terminal",
146140
"key":""
147141
},
148142
{
149-
"name":"远程服务器重启nginx",
150-
"command":"ssh 用户@ip '/opt/nginx/sbin/nginx'",
143+
"name":"linux: start nginx",
144+
"command":"ssh user@ip '/opt/nginx/sbin/nginx'",
151145
"type" : "terminal",
152146
"key":""
153147
}]
154148
```
155149

156-
### 例子7: 使用pandoc转markdown为pdf、doc、html
150+
### Example 7: Use pandoc to convert markdown to pdf, doc, html
151+
152+
What is pandoc? Pandoc is a software, an artifact that can convert all kinds of document formats to each other, and a Swiss army knife of document conversion.
157153

158-
pandoc是什么?
159-
pandoc是一个软件,是一个能把千奇百怪的文档格式互相转换的神器,是一把文档转换的瑞士军刀。
160-
安装后,可以通过命令调用。[pandoc官网](http://www.pandoc.org)
154+
After installation, it can be invoked through commands. [pandoc official website](http://www.pandoc.org)
161155

162-
**pandoc结合外部命令的例子**
156+
**pandoc Example**
163157

164158
```
165159
[{
166-
"name": "Pandoc转md为pdf",
160+
"name": "Pandoc: md to pdf",
167161
"command": "pandoc ${file} -o ${fileBasename}.pdf",
168162
"type": "terminal",
169163
"key": ""
170164
},
171165
{
172-
"name": "Pandoc转md为doc",
166+
"name": "Pandoc: md to doc",
173167
"command": "pandoc ${file} -o ${fileBasename}.docx",
174168
"type": "terminal",
175169
"key": ""
176170
},
177171
{
178-
"name": "Pandoc转md为html",
172+
"name": "Pandoc: md to html",
179173
"command": "pandoc ${file} -o ${fileBasename}.html",
180174
"type": "terminal",
181175
"key": ""
182176
}
183177
]
184178
```
185179

186-
### 例子8: 安装apk到Android手机
180+
### Example 8: Install apk to Android phone
187181

188182
```
189183
[
190184
{
191-
"name": "安装apk到android手机",
185+
"name": "install apk",
192186
"command": "adb install ${file}",
193187
"type": "terminal",
194188
"key": ""
195189
}
196190
]
197191
```
198192

199-
### 例子9: 【蒲公英】内测应用上传
200-
201-
```
202-
[
203-
{
204-
"name": "【蒲公英】内测应用上传",
205-
"command": "curl -F 'file=@${file}' -F 'uKey=xxxxxxx' -F '_api_key=xxxxxx' https://upload.pgyer.com/apiv1/app/upload",
206-
"type": "terminal",
207-
"key": "alt+shift+m"
208-
}
209-
]
210-
```
211-
说明:`uKey``_api_key`需要自己申请。 网址:https://www.pgyer.com/doc/api
212-
213-
### 例子10:使用ftp
214-
参考网友贡献[http://ask.dcloud.net.cn/article/35459](http://ask.dcloud.net.cn/article/35459)
215-
216-
### 例子11:使用颜色选择器
217-
该插件目前无需外部命令配置,具体见其文档:[http://ext.dcloud.net.cn/plugin?id=146](http://ext.dcloud.net.cn/plugin?id=146)
218-
219-
### 例子12: 批量压缩js文件
193+
### Example 9: Batch compress js files
220194

221195
find是mac上的命令。windows请自行编写批处理
222196
```
223197
[{
224-
"name": "js批量压缩",
198+
"name": "Batch compress js files",
225199
"command": "for i in `find ${projectDir} -path ${projectDir}'/unpackage' -prune -o -name '*.js' -and ! -iname '*.min.js'`;do `/Applications/HBuilderX-Alpha.app/Contents/HBuilderX/plugins/compress-babel-minify/node_modules/.bin/minify ${i} --out-file ${i%.js*}.min.js 2>/dev/null`;[ $? -ne 0 ] && echo && echo '压缩错误的文件:'${i}; done",
226200
"type": "shell",
227201
"key": "alt+shift+e"
228202
}]
229203
```
230204

231-
## 外部命令配置快捷键
205+
## configuration shortcut keys
232206

233-
如上的例子,key,可以配置快捷键哦
207+
The following example: configure shortcut keys by key
234208

235209
```
236210
{
237-
"name":"scp传输项目到服务器",
238-
"command":"scp -r ${projectDir} 用户名@ip:服务器目录路径",
211+
"name":"scp",
212+
"command":"scp -r ${projectDir} user@ip:server_path",
239213
"type" : "terminal",
240214
"key":"alt+shift+m"
241215
}
242216
```
243217

244218

245-
## 外部命令变量说明
219+
## External command variable description
246220

247-
因为变量和快捷键,所以外部命令强大。
248221

249222
```
250-
//------------外部命令 变量说明------------//
251-
"command"、"workingDir"中可使用预定义的变量来获取当前文件的路径信息
252-
${file} 当前文件的完整路径,比如 D:\files\test.txt
253-
${fileName} 当前文件的文件名,比如 test.txt
254-
${fileExtension} 当前文件的扩展名,比如 txt
255-
${fileBasename} 当前文件仅包含文件名的部分,比如 test
256-
${fileDir} 当前文件所在目录的完整路径,比如 D:\files
257-
${projectDir} 当前文件所在项目的完整路径,只有当前文件是项目管理器中某个项目下的文件时才起作用
223+
"command"、"workingDir": Use predefined variables to get the path information of the current file
224+
${file} The full path of the current file,Example: D:\files\test.txt
225+
${fileName} The file name of the current file,Example: test.txt
226+
${fileExtension} The extension of the current file,Example: txt
227+
${fileBasename} The current file only contains part of the file name,Example: test
228+
${fileDir} The full path of the directory where the current file is located,Example: D:\files
229+
${projectDir} The full path of the project where the current file is located
258230
```

en/_sidebar.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
* [Compase Selected Files](/Tutorial/UserGuide/LocalFileDiff.md)
2727
* [Local History](/Tutorial/UserGuide/LocalHistory.md)
2828
* [editorconfig](/Tutorial/UserGuide/editorconfig.md)
29+
* [External Commands](/Tutorial/UserGuide/externalCommands.md)
2930
* Languages
3031
* [Overview](/Tutorial/Language/Overview.md)
3132
* [CodeAssistant](/Tutorial/Language/CodeAssistant.md)
93.1 KB
Loading

0 commit comments

Comments
 (0)