Skip to content

Commit f583cdf

Browse files
committed
clean code and add online doc link info
1 parent 71676e5 commit f583cdf

File tree

3 files changed

+14
-18
lines changed

3 files changed

+14
-18
lines changed

c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ copy() {
1313
case "`uname`" in
1414
Darwin*)
1515
pbcopy ;;
16-
CYGWIN*)
17-
clip ;;
18-
MINGW*)
16+
CYGWIN*|MINGW*)
1917
clip ;;
2018
*)
2119
xsel -b ;;

console-text-color-themes.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#!/bin/bash
22
# @Function
33
# show all console text color themes.
4+
#
5+
# @online-doc https://github.com/oldratlee/useful-scripts/blob/master/docs/shell.md#beer-console-text-color-themessh
6+
# @author Jerry Lee (oldratlee at gmail dot com)
47

58
readonly _ctct_PROG="$(basename "$(readlink -f "$0")")"
69
[ "$_ctct_PROG" == 'console-text-color-themes.sh' ] && readonly _ctct_is_direct_run=true

echo-args.sh

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,22 @@
11
#!/bin/bash
2+
# @Function
3+
# print arguments in human and debug friendly style.
4+
#
5+
# @online-doc https://github.com/oldratlee/useful-scripts/blob/master/docs/shell.md#beer-echo-argssh
6+
# @author Jerry Lee (oldratlee at gmail dot com)
27

3-
readonly ec=$'\033' # escape char
8+
readonly ebegin=$'\033[1;31m' # escape begin, red color
49
readonly eend=$'\033[0m' # escape end
510

6-
redEcho() {
7-
if [ -c /dev/stdout ] ; then
8-
# if stdout is console, turn on color output.
9-
echo -n "$ec[1;31m$@$eend"
10-
else
11-
echo -n "$@"
12-
fi
13-
}
14-
1511
echoArg() {
1612
local index=$1
1713
local count=$2
1814
local value=$3
1915

20-
echo -n "$index/$count: "
21-
redEcho "["
22-
echo -n "$value"
23-
redEcho "]"
24-
echo
16+
# if stdout is console, turn on color output.
17+
[ -c /dev/stdout ] &&
18+
echo "$index/$count: $ebegin[$eend$value$ebegin]$eend" ||
19+
echo "$index/$count: [$value]"
2520
}
2621

2722

0 commit comments

Comments
 (0)