Skip to content

Commit bab294c

Browse files
committed
some update...
1 parent 3f63356 commit bab294c

File tree

6 files changed

+70
-5
lines changed

6 files changed

+70
-5
lines changed

examples/demo/color.php

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,26 @@
66
// $text = sprintf("\033[%sm%s\033[%sm\n", implode(';', $setCodes), $text, implode(';', $unsetCodes));
77
// var_dump(chr(27));
88
// echo $text;
9-
system("echo -e '\033[32;40;1;4mfoo\033[39;49;22;24m'");
10-
system("printf '\033[32;40;1;4mfoo\033[39;49;22;24m'");
9+
10+
11+
passthru("echo \033[32;40;1;4mfoo\033[39;49;22;24m");
12+
passthru('echo -e \033[32;40;1;4mfoo\033[39;49;22;24m');
13+
passthru("printf '\033[32;40;1;4mfoo\033[39;49;22;24m'");
14+
echo "\n";
15+
16+
// $cmdFile = dirname(__DIR__, 2) . '/src/BuiltIn/Resources/cmd/SetEscChar.cmd';
17+
// echo $cmdFile . "\n";
18+
19+
// exec("call $cmdFile");
20+
system('echo %ESC%[1;33;40m Yellow on black %ESC%[0m');
21+
22+
// system('set TEST=val1 && echo %TEST%');
23+
// passthru('set TEST=val2');
24+
// passthru('echo %TEST%');
25+
1126
fwrite(STDOUT, "\033[32;40;1;4mfoo\033[39;49;22;24m");
12-
fflush(STDOUT);
27+
fwrite(STDOUT, "\x1b[32;40;1;4mfoo\x1b[39;49;22;24m");
28+
// fflush(STDOUT);
1329

1430

1531

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# 说明
2+
3+
一些辅助命令及脚本文件。
4+
5+
来自于:
6+
7+
- ConEmu https://github.com/Maximus5/ConEmu
8+
9+
## 使用
10+
11+
### 在cmd里输出颜色:
12+
13+
需要设置一个环境变量 `set ESC=`, 对应的 ASCII `\x1B`
14+
15+
先运行:
16+
17+
```bash
18+
call SetEscChar.cmd
19+
```
20+
21+
然后执行:
22+
23+
```bash
24+
echo %ESC%[1;33;40m Yellow on black %ESC%[0m
25+
```
26+
27+
成功的话,就会看见黄色的文字 <span style="color: yellow;">Yellow on black</span>
28+
29+
### 设置cmd中的字符集为 `utf-8`
30+
31+
```bash
32+
chcp 65001 & cmd
33+
```
34+
35+
36+
37+
## 参考
38+
39+
- https://conemu.github.io/en/AnsiEscapeCodes.html
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@rem This file helps you using ANSI in your cmd scripts
2+
@rem Just call this file and you can type in your prompt smth like
3+
@rem
4+
@rem call SetEscChar
5+
@rem echo %ESC%[1;33;40m Yellow on black %ESC%[0m
6+
@rem
7+
8+
@set ESC=

src/Components/PharCompiler.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,8 @@ public function pack(string $pharFile, $refresh = true): string
386386
*/
387387
public function findChangedByGit()
388388
{
389-
list(, $output, ) = ProcessUtil::run('git status -s', $this->basePath);
389+
// -u expand dir's files
390+
list(, $output, ) = ProcessUtil::run('git status -s -u', $this->basePath);
390391

391392
// 'D some.file' deleted
392393
// ' M some.file' modified

src/Components/Terminal.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
* 2K 清除本行
1818
* \x0D = \r = 13 回车,回到行首
19-
* ESC = \x1B = 27
19+
* ESC = \x1B = \033 = 27
2020
*/
2121
final class Terminal
2222
{

src/Utils/ProcessUtil.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class ProcessUtil
2121
SIGINT => 'SIGINT(Ctrl+C)',
2222
SIGTERM => 'SIGTERM',
2323
SIGKILL => 'SIGKILL',
24+
SIGSTOP => 'SIGSTOP',
2425
];
2526

2627
/**

0 commit comments

Comments
 (0)