From 19025faefbe84a532d3fc27017e6966601b9b0a8 Mon Sep 17 00:00:00 2001 From: LAN-TW Date: Sun, 1 Dec 2013 01:37:54 +0800 Subject: =?UTF-8?q?bash=5Finclude:=20chr=20/=20ord=20/=20hex=20=E5=87=BD?= =?UTF-8?q?=E5=BC=8F=E3=80=81=E5=BF=AB=E9=80=9F=E6=AA=A2=E8=A6=96=20C=20ma?= =?UTF-8?q?cro=20=E8=88=87=20git=20=E6=AD=B7=E5=8F=B2=E7=B4=80=E9=8C=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bash_include | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) (limited to 'bash_include') diff --git a/bash_include b/bash_include index 21fd293..50a7c9d 100644 --- a/bash_include +++ b/bash_include @@ -106,6 +106,7 @@ export EDITOR=vim export FCEDIT=vim export VISUAL=vim export PAGER=less +export GCC_COLORS=1 # Aliases @@ -136,6 +137,8 @@ alias ndate='date +%H:%M:%S---%A---%x' alias npasswd="getent passwd | awk 'BEGIN {FS=\":\"} {printf \"%24s%3s%6s%6s %-28s%-18s>> %s\\n\",\$1,\$2,\$3,\$4,\$6,\$7,\$5}' | $PAGER" alias ngroup="getent group | awk 'BEGIN {FS=\":\"} {printf \"%24s%3s%6s >> %s\\n\",\$1,\$2,\$3,\$4}' | $PAGER" +alias git_history='git log --pretty=format:"%h %ad | %s%d [%an]" --graph --date=iso' + # Functions @@ -1324,6 +1327,56 @@ function argv0 () ( exec -a "$argv0" "$execname" "$@" ) } +function chr () +{ + printf $(printf '\\%03o\\n' "$1") +} + +function hex () +{ + printf "0x%02x\n" "$1" +} + +function ord () +{ + printf "%d 0x%02x 0%03o\n" "'$1" "'$1" "'$1" +} + +function cc_define () +{ + local -i i + local mycpp="${CPP}" + if [ -z "${mycpp}" ]; then + if [ -z "${CC}" ]; then + mycpp="cpp" + else + mycpp="${CC} -E" + fi + fi + + split_arguments "$@" + + { + (( i = 0 )) + while [ "${prefixlist[$i]}" ]; do + echo "#include <${prefixlist[$i]}>" + (( i++ )) + done + (( i = 0 )) + while [ "${arglist[$i]}" ]; do + echo "${arglist[$i]}" + (( i++ )) + done + } | ${mycpp} - | tail -n "${#arglist[@]}" + unset arglist + unset prefixlist +} + +function cxx_define () +{ + CPP="${CXXCPP}" CC="${CXX:-c++ -x c++}" cc_define "$@" +} + function repeat () { local repeat_times="$1" @@ -1689,12 +1742,18 @@ function help_function () mvfile [-n] filenames ... [-- sudo_prefix ...] varset variables ... <<< Tools: Non-interactive >>> - argv0 executable arguments ... (include argv[0]) backup_file filename ... [-- sudo_prefix ...] convert_to_html filename ... mkscreenacl usernames ... repeat times arguments ... wait_success arguments ... + <<< Tools: Programming >>> + argv0 executable arguments ... (include argv[0]) + cc_define macro [-- included_headers ...] + cxx_define macro [-- included_headers ...] + chr number + hex number + ord character <<< Miscellaneous: Background Jobs >>> check_dmesg seconds -- cgit v1.2.3