Skip to content

Commit de16ef9

Browse files
committed
clean code
1 parent 2d37450 commit de16ef9

File tree

5 files changed

+9
-25
lines changed

5 files changed

+9
-25
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
[![GitHub forks](https://img.shields.io/github/forks/oldratlee/useful-scripts.svg?style=social&label=Fork&)](https://github.com/oldratlee/useful-scripts/fork)
1111

1212

13-
把平时有用的手动操作做成脚本,这样可以便捷的使用。 :sparkles:
13+
:point_right: 把平时有用的手动操作做成脚本,这样可以便捷的使用。 :sparkles:
1414

1515
有自己用的好的脚本 或是 平时常用但没有写成脚本的功能,欢迎提供([提交Issue](https://github.com/oldratlee/useful-scripts/issues))和分享([Fork后提交代码](https://github.com/oldratlee/useful-scripts/fork))! :sparkling_heart:
1616

console-text-color-themes.sh

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,14 @@ colorEcho() {
1515
local combination="$1"
1616
shift 1
1717

18-
[ -t 1 ] &&
19-
echo "$_ctct_ec[${combination}m$@$_ctct_eend" ||
20-
echo "$@"
18+
[ -t 1 ] && echo "$_ctct_ec[${combination}m$@$_ctct_eend" || echo "$@"
2119
}
2220

2321
colorEchoWithoutNewLine() {
2422
local combination="$1"
2523
shift 1
2624

27-
[ -t 1 ] &&
28-
echo -n "$_ctct_ec[${combination}m$@$_ctct_eend" ||
29-
echo -n "$@"
25+
[ -t 1 ] && echo -n "$_ctct_ec[${combination}m$@$_ctct_eend" || echo -n "$@"
3026
}
3127

3228
# if not directly run this script(use as lib), just export 2 helper functions,

parseOpts.sh

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,8 @@ readonly _opts_eend=$'\033[0m' # escape end
2929
_opts_colorEcho() {
3030
local color=$1
3131
shift
32-
if [ -t 1 ] ; then
33-
# if stdout is console, turn on color output.
34-
echo "$_opts_ec[1;${color}m$@$_opts_eend"
35-
else
36-
echo "$@"
37-
fi
32+
# if stdout is console, turn on color output.
33+
[ -t 1 ] && echo "$_opts_ec[1;${color}m$@$_opts_eend" || echo "$@"
3834
}
3935

4036
_opts_redEcho() {

swtrunk.sh

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,8 @@ readonly eend=$'\033[0m' # escape end
1515
colorEcho() {
1616
local color=$1
1717
shift
18-
if [ -t 1 ] ; then
19-
# if stdout is console, turn on color output.
20-
echo "$ec[1;${color}m$@$eend"
21-
else
22-
echo "$@"
23-
fi
18+
# if stdout is console, turn on color output.
19+
[ -t 1 ] && echo "$ec[1;${color}m$@$eend" || echo "$@"
2420
}
2521

2622
redEcho() {

test-cases/parseOpts-test.sh

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,8 @@ readonly eend=$'\033[0m' # escape end
1616
colorEcho() {
1717
local color=$1
1818
shift
19-
if [ -t 1 ] ; then
20-
# if stdout is console, turn on color output.
21-
echo "$ec[1;${color}m$@$eend"
22-
else
23-
echo "$@"
24-
fi
19+
# if stdout is console, turn on color output.
20+
[ -t 1 ] && echo "$ec[1;${color}m$@$eend" || echo "$@"
2521
}
2622

2723
redEcho() {

0 commit comments

Comments
 (0)