Skip to content

Commit

Permalink
add doc for command c and a2l
Browse files Browse the repository at this point in the history
  • Loading branch information
oldratlee committed Jun 30, 2015
1 parent 96cfc49 commit 89c9707
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 26 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,16 @@ source <(curl -fsSL https://raw.githubusercontent.com/oldratlee/useful-scripts/m

包含`Shell`使用或命令加强的脚本。

1. [console-text-color-themes.sh](docs/shell.md#beer-console-text-color-themessh)
显示`Terminator`的全部文字彩色组合的效果及其打印方式
1. [c](docs/shell.md#beer-c)
原样命令行输出,并拷贝标准输出到系统剪贴板,省去`CTRL+C``CTRL+V`操作
1. [colines](docs/shell.md#beer-colines)
彩色`cat`出文件行,方便人眼区分不同的行。
1. [a2l](docs/shell.md#beer-a2l)
按行彩色输出参数,方便人眼查看。
1. [echo-args.sh](docs/shell.md#beer-echo-argssh)
输出脚本收到的参数,在控制台运行时,把参数值括起的括号显示成 **红色**,方便人眼查看。用于调试脚本参数输入。
1. [console-text-color-themes.sh](docs/shell.md#beer-console-text-color-themessh)
显示`Terminator`的全部文字彩色组合的效果及其打印方式。
1. [tcp-connection-state-counter.sh](docs/shell.md#beer-tcp-connection-state-countersh)
统计各个`TCP`连接状态的个数。用于方便排查系统连接负荷问题。
1. [parseOpts.sh](docs/shell.md#beer-parseoptssh)
Expand Down
4 changes: 2 additions & 2 deletions 2line → a2l
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# echo each arguments on one line colorfully.
#
# @Usage
# $ ./2line arg1 arg2
# $ ./2line *.txt
# $ ./a2l arg1 arg2
# $ ./a2l *.txt
#
# @author Jerry Lee

Expand Down
2 changes: 1 addition & 1 deletion c
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ if [ $# -eq 0 ]; then
teeAndCopy
else
"$@" | teeAndCopy
fi
fi
2 changes: 1 addition & 1 deletion colines
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Function
# cat lines colorfully. colines means COL(orfule L)INES.
# cat lines colorfully. colines means COLorful LINES.
#
# @Usage
# $ echo -n 'Hello\nWorld' | colines
Expand Down
98 changes: 79 additions & 19 deletions docs/shell.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,44 @@

包含`Shell`使用或命令加强的脚本。

:beer: [console-text-color-themes.sh](../console-text-color-themes.sh)
:beer: [c](../c)
----------------------

显示`Terminator`的全部文字彩色组合的效果及其打印方式
原样命令行输出,并拷贝标准输出到系统剪贴板,省去`CTRL+C``CTRL+V`操作。支持`Linux``Mac``Windows``cygwin``MSSYS`

脚本中,也给出了`colorEcho``colorEchoWithoutNewLine`函数更方便输出彩色文本,用法:
命令名`c`意思是`Copy`,因为这个命令我平时非常常用,所以使用一个字符的命令名,方便键入。

```bash
colorEcho <颜色样式> <要输出的文本>...
colorEchoWithoutNewLine <颜色样式> <要输出的文本>...
```
更多说明参见[拷贝复制命令行输出放在系统剪贴板上](http://oldratlee.com/post/2012-12-23/command-output-to-clip)

### 示例

```bash
# 输出红色文本
colorEcho "0;31;40" "Hello world!"
# 输出黄色带下划线的文本
colorEchoWithoutNewLine "4;33;40" "Hello world!" "Hello Hell!"
# 前缀方式,后面跟上要运行的命令
$ c pwd
/Users/jerry
$ c echo -e 'a\nb'
a
b
# 从标准输入读取内容
$ c < id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAz+ETZEgoLeIiC0rjWewdDs0sbo8c...== [email protected]
# 后缀方式,管道
$ echo -e 'a\nb' | nl | c
1 a
2 b
```

`console-text-color-themes.sh`的运行效果图如下:
![console-text-color-themes.sh的运行效果图](console-colorful-text.png)

### 贡献者

[姜太公](https://github.com/jiangjizhong)提供循环输出彩色组合的脚本。

### 参考资料

- [utensil](https://github.com/utensil)[在Bash下输出彩色的文本](http://utensil.github.io/tech/2007/09/10/colorful-bash.html),这是篇很有信息量很钻研的文章!
[拷贝复制命令行输出放在系统剪贴板上](http://oldratlee.com/post/2012-12-23/command-output-to-clip),给出了不同系统可用命令。

:beer: [colines](../colines)
----------------------

彩色`cat`出文件行,方便人眼区分不同的行。

命令名`colines`意思是`COLorful LINES`

### 示例

```bash
Expand All @@ -64,6 +67,33 @@ file2 line2

注:上面显示中,没有彩色,在控制台上运行可以看出彩色效果。

:beer: [a2l](../a2l)
----------------------

按行彩色输出参数,方便人眼查看。

命令名`a2l`意思是`Arguments to(2) Lines`

### 示例

```bash
$ a2l *.java
A.java
B.java
...

# zsh支持 **/* 跨目录glob,可以方便搜索,但是输出内容是空格分隔的不方便查看。
# 把参数按行输出方便查看 或是 grep
$ a2l **/*.sh
swtrunk.sh
tcp-connection-state-counter.sh
test-cases/parseOpts-test.sh
test-cases/self-installer.sh
...
```

注:上面显示中,没有彩色,在控制台上运行可以看出彩色效果。

:beer: [echo-args.sh](../echo-args.sh)
----------------------

Expand All @@ -90,6 +120,36 @@ $ ./echo-args.sh 1 " 2 foo " "3 3"

这样可以不改其它的程序,查看到输入参数的信息。

:beer: [console-text-color-themes.sh](../console-text-color-themes.sh)
----------------------

显示`Terminator`的全部文字彩色组合的效果及其打印方式。

脚本中,也给出了`colorEcho``colorEchoWithoutNewLine`函数更方便输出彩色文本,用法:

```bash
colorEcho <颜色样式> <要输出的文本>...
colorEchoWithoutNewLine <颜色样式> <要输出的文本>...
```

```bash
# 输出红色文本
colorEcho "0;31;40" "Hello world!"
# 输出黄色带下划线的文本
colorEchoWithoutNewLine "4;33;40" "Hello world!" "Hello Hell!"
```

`console-text-color-themes.sh`的运行效果图如下:
![console-text-color-themes.sh的运行效果图](console-colorful-text.png)

### 贡献者

[姜太公](https://github.com/jiangjizhong)提供循环输出彩色组合的脚本。

### 参考资料

- [utensil](https://github.com/utensil)[在Bash下输出彩色的文本](http://utensil.github.io/tech/2007/09/10/colorful-bash.html),这是篇很有信息量很钻研的文章!

:beer: [tcp-connection-state-counter.sh](../tcp-connection-state-counter.sh)
----------------------

Expand Down
2 changes: 1 addition & 1 deletion tcp-connection-state-counter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# @author Jerry Lee

netstat -tna | awk 'NR > 2 {
s[$NF]++
s[$NF]++
}
END {
Expand Down

0 comments on commit 89c9707

Please sign in to comment.