Skip to content

Commit

Permalink
normalize directory structure: bin, lib, doc, etc #87
Browse files Browse the repository at this point in the history
  • Loading branch information
oldratlee committed Dec 11, 2019
1 parent 62ac01f commit b03c065
Show file tree
Hide file tree
Showing 30 changed files with 73 additions and 79 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ PS:
----------------------

```bash
source <(curl -fsSL https://raw.githubusercontent.com/oldratlee/useful-scripts/master/test-cases/self-installer.sh)
source <(curl -fsSL https://raw.githubusercontent.com/oldratlee/useful-scripts/release-2.x/test-cases/self-installer.sh)
```

更多下载&使用方式,参见[下载使用](docs/install.md)
Expand Down
2 changes: 1 addition & 1 deletion a2l → bin/a2l
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# $ ./a2l arg1 arg2
# $ ./a2l *.txt
#
# @online-doc https://github.com/oldratlee/useful-scripts/blob/master/docs/shell.md#-a2l
# @online-doc https://github.com/oldratlee/useful-scripts/blob/dev-2.x/docs/shell.md#-a2l
# @author Jerry Lee (oldratlee at gmail dot com)


Expand Down
2 changes: 1 addition & 1 deletion ap → bin/ap
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# # print Absolute Path of arguments.
# $ ./ap a.txt ../dir1/b.txt
#
# @online-doc https://github.com/oldratlee/useful-scripts/blob/master/docs/shell.md#-ap-and-rp
# @online-doc https://github.com/oldratlee/useful-scripts/blob/dev-2.x/docs/shell.md#-ap-and-rp
# @author Jerry Lee (oldratlee at gmail dot com)

[ $# -eq 0 ] && files=(.) || files=("$@")
Expand Down
2 changes: 1 addition & 1 deletion c → bin/c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# $ c echo "hello world!"
# $ echo "hello world!" | c
#
# @online-doc https://github.com/oldratlee/useful-scripts/blob/master/docs/shell.md#-c
# @online-doc https://github.com/oldratlee/useful-scripts/blob/dev-2.x/docs/shell.md#-c
# @author Jerry Lee (oldratlee at gmail dot com)

set -e
Expand Down
2 changes: 1 addition & 1 deletion coat → bin/coat
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# $ coat /path/to/file1
# $ coat /path/to/file1 /path/to/file2
#
# @online-doc https://github.com/oldratlee/useful-scripts/blob/master/docs/shell.md#-coat
# @online-doc https://github.com/oldratlee/useful-scripts/blob/dev-2.x/docs/shell.md#-coat
# @author Jerry Lee (oldratlee at gmail dot com)

set -e
Expand Down
1 change: 1 addition & 0 deletions bin/console-text-color-themes
2 changes: 1 addition & 1 deletion echo-args → bin/echo-args
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# @Function
# print arguments in human and debugging friendly style.
#
# @online-doc https://github.com/oldratlee/useful-scripts/blob/master/docs/shell.md#-echo-args
# @online-doc https://github.com/oldratlee/useful-scripts/blob/dev-2.x/docs/shell.md#-echo-args
# @author Jerry Lee (oldratlee at gmail dot com)

readonly ec=$'\033' # escape char
Expand Down
2 changes: 1 addition & 1 deletion find-in-jars → bin/find-in-jars
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# $ find-in-jars 'Service\.class$' -e jar -e zip
# $ find-in-jars 'Mon[^$/]*Service\.class$' -s ' <-> '
#
# @online-doc https://github.com/oldratlee/useful-scripts/blob/master/docs/java.md#-find-in-jars
# @online-doc https://github.com/oldratlee/useful-scripts/blob/dev-2.x/docs/java.md#-find-in-jars
# @author Jerry Lee (oldratlee at gmail dot com)

readonly PROG="`basename "$0"`"
Expand Down
4 changes: 2 additions & 2 deletions rp → bin/rp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# # if more than 1 argument, print relative path to last argument.
# $ ./rp a.txt ../b.txt /etc/passwd /etc/apache2
#
# @online-doc https://github.com/oldratlee/useful-scripts/blob/master/docs/shell.md#-ap-and-rp
# @online-doc https://github.com/oldratlee/useful-scripts/blob/dev-2.x/docs/shell.md#-ap-and-rp
# @author Jerry Lee (oldratlee at gmail dot com)

[ $# -eq 0 ] && {
Expand All @@ -35,5 +35,5 @@ for f in "${files[@]}" ; do
echo "$f does not exists!"
continue
}
realpath "$f" --relative-to="$relativeTo"
realpath "$f" --relative-to="$relativeTo"
done
2 changes: 1 addition & 1 deletion show-busy-java-threads → bin/show-busy-java-threads
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# @Usage
# $ ./show-busy-java-threads
#
# @online-doc https://github.com/oldratlee/useful-scripts/blob/master/docs/java.md#-show-busy-java-threads
# @online-doc https://github.com/oldratlee/useful-scripts/blob/dev-2.x/docs/java.md#-show-busy-java-threads
# @author Jerry Lee (oldratlee at gmail dot com)
# @author superhj1987 (superhj1987 at 126 dot com)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# $ show-duplicate-java-classes path/to/lib_dir1 /path/to/lib_dir2
# $ show-duplicate-java-classes -c path/to/class_dir1 -c /path/to/class_dir2
#
# @online-doc https://github.com/oldratlee/useful-scripts/blob/master/docs/java.md#-show-duplicate-java-classes
# @online-doc https://github.com/oldratlee/useful-scripts/blob/dev-2.x/docs/java.md#-show-duplicate-java-classes
# @author tg123 (farmer1992 at gmail dot com)
# @author Jerry Lee (oldratlee at gmail dot com)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# @Usage
# $ ./tcp-connection-state-counter
#
# @online-doc https://github.com/oldratlee/useful-scripts/blob/master/docs/shell.md#-tcp-connection-state-counter
# @online-doc https://github.com/oldratlee/useful-scripts/blob/dev-2.x/docs/shell.md#-tcp-connection-state-counter
# @author Jerry Lee (oldratlee at gmail dot com)
# @author @sunuslee (sunuslee at gmail dot com)

Expand Down
2 changes: 1 addition & 1 deletion xpf → bin/xpf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# @Usage
# $ ./xpf file
#
# @online-doc https://github.com/oldratlee/useful-scripts/blob/master/docs/shell.md#-xpl-and-xpf
# @online-doc https://github.com/oldratlee/useful-scripts/blob/dev-2.x/docs/shell.md#-xpl-and-xpf
# @author Jerry Lee (oldratlee at gmail dot com)

BASE="$(dirname "$0")"
Expand Down
2 changes: 1 addition & 1 deletion xpl → bin/xpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# @Usage
# $ ./xpf [file [file ...] ]
#
# @online-doc https://github.com/oldratlee/useful-scripts/blob/master/docs/shell.md#-xpl-and-xpf
# @online-doc https://github.com/oldratlee/useful-scripts/blob/dev-2.x/docs/shell.md#-xpl-and-xpf
# @author Jerry Lee (oldratlee at gmail dot com)

PROG=`basename $0`
Expand Down
1 change: 0 additions & 1 deletion colines

This file was deleted.

24 changes: 12 additions & 12 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ git clone git://github.com/oldratlee/useful-scripts.git
cd useful-scripts

# 使用Release分支的内容
git checkout release
git checkout release-2.x

# 更新脚本
git pull
```

包含2个分支:

- `master`:开发分支
- `release`:发布分支,功能稳定的脚本
- `dev-2.x`:开发分支
- `release-2.x`:发布分支,功能稳定的脚本

当然如果你不想安装`git`,`github`是支持`svn`的:
当然如果你不想安装`git``github`是支持`svn`的:

```bash
svn co https://github.com/oldratlee/useful-scripts/branches/release
svn co https://github.com/oldratlee/useful-scripts/branches/release-2.x

cd useful-scripts

Expand All @@ -37,33 +37,33 @@ svn up
```

PS:
我的做法是把`useful-scripts` checkout到`$HOME/bin/useful-scripts`目录下,再把`$HOME/bin/useful-scripts`配置到`PATH`变量上,这样方便我本地使用所有的脚本。
我的做法是把`useful-scripts` checkout到`$HOME/bin`目录下,再把`$HOME/bin/useful-scripts/bin`配置到`PATH`变量上,这样方便我本地使用所有的脚本。

### 打包下载

下载文件[release.zip](https://github.com/oldratlee/useful-scripts/archive/release.zip)
下载文件[release-2.x.zip](https://github.com/oldratlee/useful-scripts/archive/release-2.x.zip)

```bash
wget --no-check-certificate https://github.com/oldratlee/useful-scripts/archive/release.zip
wget --no-check-certificate https://github.com/oldratlee/useful-scripts/archive/release-2.x.zip

unzip release.zip
unzip release-2.x.zip
```

下载和运行单个文件
-------------------

[`show-busy-java-threads`](https://raw.github.com/oldratlee/useful-scripts/release/show-busy-java-threads)为例。
[`show-busy-java-threads`](https://raw.github.com/oldratlee/useful-scripts/release-2.x/bin/show-busy-java-threads)为例。

### `curl`文件直接用`bash`运行

```bash
curl -sLk 'https://raw.github.com/oldratlee/useful-scripts/release/show-busy-java-threads' | bash
curl -sLk 'https://raw.github.com/oldratlee/useful-scripts/release-2.x/bin/show-busy-java-threads' | bash
```

### 下载单个文件

```bash
wget --no-check-certificate https://raw.github.com/oldratlee/useful-scripts/release/show-busy-java-threads
wget --no-check-certificate https://raw.github.com/oldratlee/useful-scripts/release-2.x/bin/show-busy-java-threads
chmod +x show-busy-java-threads

./show-busy-java-threads
Expand Down
6 changes: 3 additions & 3 deletions docs/java.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<a id="beer-show-busy-java-threadssh"></a>
<a id="beer-show-busy-java-threads"></a>

🍺 [show-busy-java-threads](../show-busy-java-threads)
🍺 [show-busy-java-threads](../bin/show-busy-java-threads)
----------------------

用于快速排查`Java``CPU`性能问题(`top us`值过高),自动查出运行的`Java`进程中消耗`CPU`多的线程,并打印出其线程栈,从而确定导致性能问题的方法调用。
Expand Down Expand Up @@ -222,7 +222,7 @@ $ show-busy-java-threads
- 发现并提交Issue:在`top v3.2`下提取不正确的Bug [#71](https://github.com/oldratlee/useful-scripts/issues/71)
- 发现并提交Issue:support command name jsvc to find java process [#72](https://github.com/oldratlee/useful-scripts/issues/72)
🍺 [show-duplicate-java-classes](../show-duplicate-java-classes)
🍺 [show-duplicate-java-classes](../bin/show-duplicate-java-classes)
----------------------
找出`Java Lib``Java`库,即`Jar`文件)或`Class`目录(类目录)中的重复类。
Expand Down Expand Up @@ -385,7 +385,7 @@ class paths to find:
<a id="beer-find-in-jarssh"></a>
<a id="beer-find-in-jars"></a>
🍺 [find-in-jars](../find-in-jars)
🍺 [find-in-jars](../bin/find-in-jars)
----------------------
在当前目录下所有`jar`文件里,查找类或资源文件。
Expand Down
24 changes: 11 additions & 13 deletions docs/shell.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
`Shell`使用加强
====================================

🍺 [c](../c)
🍺 [c](../bin/c)
----------------------

原样命令行输出,并拷贝标准输出到系统剪贴板,省去`CTRL+C`操作,优化命令行与其它应用之间的操作流。
Expand Down Expand Up @@ -113,16 +113,15 @@ Options:
- [拷贝复制命令行输出放在系统剪贴板上](http://oldratlee.com/post/2012-12-23/command-output-to-clip),给出了不同系统可用命令。
- 关于文本文件最后的换行,参见[Why should text files end with a newline?](https://stackoverflow.com/questions/729692)
🍺 [coat](../coat)
🍺 [coat](../bin/coat)
----------------------
彩色`cat`出文件行,方便人眼区分不同的行。
支持`Linux``Mac``Windows``cygwin``MSSYS`)。
命令支持选项、功能和使用方式与[`cat`命令](https://linux.die.net/man/1/cat)完全一样(实际上读流操作在实现上全部代理给`cat`命令)。
命令名`coat`意思是`COlorful cAT`;当然单词`coat`的意思是外套,彩色输入行就像件漂亮的外套~ 😆
注:之前命名是`colines`(意思是`COLorful LINES`)。
命令名`coat`意思是`COlorful cAT`;当然单词`coat`的意思是外套,彩色输入行就像件漂亮的外套~ 😆
### 示例
Expand Down Expand Up @@ -176,7 +175,7 @@ or available locally via: info '(coreutils) cat invocation'
注:上面示例中,没有彩色;在控制台上运行可以看出彩色效果,如下:
![coat screenshot](../docs/coat.png)
🍺 [a2l](../a2l)
🍺 [a2l](../bin/a2l)
----------------------
按行彩色输出参数,方便人眼查看。
Expand All @@ -195,16 +194,15 @@ B.java
# zsh支持 **/* 跨目录glob,可以方便搜索,但是输出内容是空格分隔的不方便查看。
# 把参数按行输出方便查看 或是 grep
$ a2l **/*.sh
console-text-color-themes.sh
swtrunk.sh
lib/console-text-color-themes.sh
test-cases/parseOpts-test.sh
test-cases/self-installer.sh
...
```
注:上面示例中,没有彩色;在控制台上运行可以看出彩色效果,和上面的`coat`命令一样。
🍺 [ap](../ap) and [rp](../rp)
🍺 [ap](../bin/ap) and [rp](../bin/rp)
----------------------
批量转换文件路径为绝对路径/相对路径,会自动跟踪链接并规范化路径。
Expand Down Expand Up @@ -239,7 +237,7 @@ $ rp /home /etc/../etc /home/admin
<a id="beer-tcp-connection-state-countersh"></a>
<a id="beer-tcp-connection-state-counter"></a>
🍺 [tcp-connection-state-counter](../tcp-connection-state-counter)
🍺 [tcp-connection-state-counter](../bin/tcp-connection-state-counter)
----------------------
统计各个`TCP`连接状态的个数。
Expand Down Expand Up @@ -270,7 +268,7 @@ SYN_SENT 17
[sunuslee](https://github.com/sunuslee)改进此脚本,增加对`MacOS`的支持。 [#56](https://github.com/oldratlee/useful-scripts/pull/56)
🍺 [xpl](../xpl) and [xpf](../xpf)
🍺 [xpl](../bin/xpl) and [xpf](../bin/xpf)
----------------------
在命令行中快速完成 在文件浏览器中 打开/选中 指定的文件或文件夹的操作,优化命令行与其它应用之间的操作流。
Expand Down Expand Up @@ -315,7 +313,7 @@ xpf /path/to/dir1 /path/to/foo1.txt
<a id="beer-echo-argssh"></a>
<a id="beer-echo-args"></a>
🍺 [echo-args](../echo-args)
🍺 [echo-args](../bin/echo-args)
----------------------
在编写脚本时,常常要确认输入参数是否是期望的:参数个数,参数值(可能包含有人眼不容易发现的空格问题)。
Expand All @@ -342,7 +340,7 @@ $ ./echo-args 1 " 2 foo " "3 3"
这样可以不改其它的程序,查看到输入参数的信息。
🍺 [console-text-color-themes.sh](../console-text-color-themes.sh)
🍺 [console-text-color-themes.sh](../lib/console-text-color-themes.sh)
----------------------
显示`Terminator`的全部文字彩色组合的效果及其打印方式。
Expand Down Expand Up @@ -380,7 +378,7 @@ colorEchoWithoutNewLine "4;33;40" "Hello world!" "Hello Hell!"
- [utensil](https://github.com/utensil)的[在Bash下输出彩色的文本](http://utensil.github.io/tech/2007/09/10/colorful-bash.html),这是篇很有信息量很钻研的文章!
🍺 [parseOpts.sh](../parseOpts.sh)
🍺 [parseOpts.sh](../lib/parseOpts.sh)
----------------------
命令行选项解析库,加强支持选项有多个值(即数组)。
Expand Down
Loading

0 comments on commit b03c065

Please sign in to comment.