diff options
author | LAN-TW <lantw44@gmail.com> | 2011-11-25 22:01:25 +0800 |
---|---|---|
committer | LAN-TW <lantw44@gmail.com> | 2011-11-25 22:01:25 +0800 |
commit | d11761e89ee58119649fba4ff4c44cd1a62e25ea (patch) | |
tree | 4d301fbf051ebe414e3f4a3569def327343845e2 /bash_include | |
parent | fb4dfec3d32623de841dba97e890d127e7b4adc6 (diff) | |
download | configfile-d11761e89ee58119649fba4ff4c44cd1a62e25ea.tar configfile-d11761e89ee58119649fba4ff4c44cd1a62e25ea.tar.gz configfile-d11761e89ee58119649fba4ff4c44cd1a62e25ea.tar.bz2 configfile-d11761e89ee58119649fba4ff4c44cd1a62e25ea.tar.lz configfile-d11761e89ee58119649fba4ff4c44cd1a62e25ea.tar.xz configfile-d11761e89ee58119649fba4ff4c44cd1a62e25ea.tar.zst configfile-d11761e89ee58119649fba4ff4c44cd1a62e25ea.zip |
bash_include: 加入更多背景執行功能、將 == 替換成 =bash_include-20111126
Diffstat (limited to 'bash_include')
-rw-r--r-- | bash_include | 53 |
1 files changed, 38 insertions, 15 deletions
diff --git a/bash_include b/bash_include index 2df4855..2a4d476 100644 --- a/bash_include +++ b/bash_include @@ -1,6 +1,8 @@ colorprompting='\[\e[1;31m\]\!\[\e[m\] [\[\e[1;33m\]\u\[\e[m\]@\[\e[1;32m\]\h\[\e[m\] \[\e[1;36m\]\w\[\e[m\]]\$ ' nocolorprompting='\! [\u@\h \w]\$ ' +bgrunfiledir="$HOME/tmp/bgrun" + HISTSIZE=100000 HISTFILESIZE=100000 @@ -31,9 +33,9 @@ alias sg='sudo -g' function compile_all () { noask=0 - [ "$1" == '' ] && echo "Which file(s) do you want to compile? " && return 1 - [ "$1" == "-n" ] && noask=1 - if [ "$noask" == "0" ]; then + [ "$1" = '' ] && echo "Which file(s) do you want to compile? " && return 1 + [ "$1" = "-n" ] && noask=1 + if [ "$noask" = "0" ]; then read -p "CFLAGS [$CFLAGS] ? " NEWCFLAGS read -p "LDFLAGS [$LDFLAGS] ? " NEWLDFLAGS [ "$NEWCFLAGS" '!=' '' ] && CFLAGS=$NEWCFLAGS @@ -52,11 +54,11 @@ function compile_all () '\e[1;33mWarning\e[0m: Non-existent file or not a regular file\n' shift ; continue fi - [ "$TARGETFILE" == "$1" ] && shift && continue - if [ "$SUFFIX" == "c" ]; then + [ "$TARGETFILE" = "$1" ] && shift && continue + if [ "$SUFFIX" = "c" ]; then echo "[CC] $1 -> $TARGETFILE" gcc $CFLAGS "$1" $LDFLAGS -o "$TARGETFILE" - elif [ "$SUFFIX" == "cpp" ]; then + elif [ "$SUFFIX" = "cpp" ]; then echo "[CXX] $1 -> $TARGETFILE" g++ $CFLAGS "$1" $LDFLAGS -o "$TARGETFILE" else @@ -103,33 +105,54 @@ function mkscreenacl () function bgrun () { - [ "$#" == "0" ] && return 1 + [ "$#" = "0" ] && return 1 + [ '!' -d "$bgrunfiledir" ] && mkdir -p "$bgrunfiledir" current_time=`date "+%Y%m%d-%H%M%S"` - filename="$HOME/tmp/$1-$current_time" + filename="$bgrunfiledir/$1-$current_time" echo "Writing to $filename" "$@" &> "$filename" & } -function bgout() +function bgview () { - if [ "$1" == "" ] + if [ "$1" = "" ] then yourchoice=1 fi - rootfilename=`find ~/tmp/ -maxdepth 1 -mindepth 1 | cut -d - -f 2,3 | sort -r | sed -n ${yourchoice}p` - realfilename=`find ~/tmp/ -maxdepth 1 -mindepth 1 | grep "$rootfilename"` - if [ "$PAGER" == "" ] + rootfilename=`find "$bgrunfiledir" -maxdepth 1 -mindepth 1 | cut -d - -f 2,3 | sort -r | sed -n ${yourchoice}p` + realfilename=`find "$bgrunfiledir" -maxdepth 1 -mindepth 1 | grep "$rootfilename"` + if [ "$PAGER" = "" ] then PAGER=less fi read -p "View '$realfilename' ? " confirm - if [ "$confirm" == "n" ] || [ "$confirm" == "N" ] + if [ "$confirm" = "n" ] || [ "$confirm" = "N" ] then return 1 fi "$PAGER" "$realfilename" } +function bgcount () +{ + find "$bgrunfiledir" -maxdepth 1 -mindepth 1 | cut -d - -f 2,3 | wc | awk '{print $2}' +} + +function check_dmesg () +{ + [ "$#" = "0" ] && return 1 + + while true + do + PREVIOS_DMESG_BUF="$DMESG_BUF" + DMESG_BUF="`dmesg`" + [ "$PREVIOS_DMESG_BUF" '!=' "$DMESG_BUF" ] && [ "$FIRST_RUN" = "0" ] && echo '===> system message buffer was modified <===' + sleep $1 + [ "$?" '!=' "0" ] && return 1 + FIRST_RUN=0 + done +} + # Starting doing something startcolor @@ -137,7 +160,7 @@ startcolor umask 0022 tty -s -if [ "$?" == "0" ] +if [ "$?" = "0" ] then bind '"\e[A":history-search-backward' bind '"\e[B":history-search-forward' |