diff options
author | LAN-TW <lantw44@gmail.com> | 2011-11-25 00:30:53 +0800 |
---|---|---|
committer | LAN-TW <lantw44@gmail.com> | 2011-11-25 00:30:53 +0800 |
commit | fb4dfec3d32623de841dba97e890d127e7b4adc6 (patch) | |
tree | 78adf30cf0e6a5f5aec799904b4f37afc9272646 /bash_include | |
parent | e96d4d03e5225cc9b6895a51cd26c17c4423884e (diff) | |
download | configfile-fb4dfec3d32623de841dba97e890d127e7b4adc6.tar configfile-fb4dfec3d32623de841dba97e890d127e7b4adc6.tar.gz configfile-fb4dfec3d32623de841dba97e890d127e7b4adc6.tar.bz2 configfile-fb4dfec3d32623de841dba97e890d127e7b4adc6.tar.lz configfile-fb4dfec3d32623de841dba97e890d127e7b4adc6.tar.xz configfile-fb4dfec3d32623de841dba97e890d127e7b4adc6.tar.zst configfile-fb4dfec3d32623de841dba97e890d127e7b4adc6.zip |
bash_include: 加入基本的背景執行輔助函式bash_include-20111125
Diffstat (limited to 'bash_include')
-rw-r--r-- | bash_include | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/bash_include b/bash_include index 83e57c7..2df4855 100644 --- a/bash_include +++ b/bash_include @@ -101,6 +101,35 @@ function mkscreenacl () done } +function bgrun () +{ + [ "$#" == "0" ] && return 1 + current_time=`date "+%Y%m%d-%H%M%S"` + filename="$HOME/tmp/$1-$current_time" + echo "Writing to $filename" + "$@" &> "$filename" & +} + +function bgout() +{ + 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" == "" ] + then + PAGER=less + fi + read -p "View '$realfilename' ? " confirm + if [ "$confirm" == "n" ] || [ "$confirm" == "N" ] + then + return 1 + fi + "$PAGER" "$realfilename" +} + # Starting doing something startcolor |