Update of the 'keep' command so that it now uses selector when available.
authorFrancois Fleuret <francois@fleuret.org>
Mon, 30 Jun 2014 08:50:17 +0000 (10:50 +0200)
committerFrancois Fleuret <francois@fleuret.org>
Mon, 30 Jun 2014 08:50:17 +0000 (10:50 +0200)
bashrc

diff --git a/bashrc b/bashrc
index b4da27d..0ce1e40 100644 (file)
--- a/bashrc
+++ b/bashrc
@@ -108,7 +108,8 @@ alias cp='cp -i -v'
 alias rd=rmdir
 alias md='mkdir -pv'
 alias ps='ps uxaf'
-alias df='df -hT --sync'
+alias df='df -hT'
+# alias df='df -hT --sync'
 alias grep='grep -i -E --color=auto'
 alias find='ionice -c3 find'
 alias pd=pushd
@@ -537,20 +538,42 @@ KEPT_COMMANDS=${HOME}/.kept_bash_commands
 
 function keep () {
     if [[ ${KEPT_COMMANDS} ]]; then
-        LINE="$*"
-        [[ "${LINE}" ]] || LINE=$(history | tail -2 | head -1 | sed -e "s/^[0-9 ]*//")
-        echo $LINE
-        echo $(date)": "${LINE} >> ${KEPT_COMMANDS}
+        TOKEEP=$(mktemp /tmp/keep.XXXXXX)
+        if [[ "$*" ]]; then
+            echo "$*" > ${TOKEEP}
+        else
+            selector -b -i -d -l ${HISTSIZE} -o "${TOKEEP}" <(history)
+        fi
+
+        if [[ -s "${TOKEEP}" ]]; then
+            echo $(date)": "$(cat ${TOKEEP}) >> ${KEPT_COMMANDS}
+            cat "${TOKEEP}"
+        else
+            echo "No command stored!"
+        fi
+
+        \rm ${TOKEEP}
     else
         echo "You have to set \$KEPT_COMMANDS"
     fi
 }
 
+# function keep () {
+    # if [[ ${KEPT_COMMANDS} ]]; then
+        # LINE="$*"
+        # [[ "${LINE}" ]] || LINE=$(history | tail -2 | head -1 | sed -e "s/^[0-9 ]*//")
+        # echo $LINE
+        # echo $(date)": "${LINE} >> ${KEPT_COMMANDS}
+    # else
+        # echo "You have to set \$KEPT_COMMANDS"
+    # fi
+# }
+
 ######################################################################
 # I sometime burn CDs and DVDs
 
 function burn () {
-    DEVICE="/dev/cdrw"
+    DEVICE="/dev/cdrw1"
     if [[ ! "$1" ]]; then
         echo "burn <iso name | dirname>" >&2
     elif [[ -f "$1" ]]; then
@@ -605,7 +628,7 @@ function dvd () {
         -quiet \
         -alang en -slang en \
         -softvol -softvol-max 1000 \
-        -dvd-device ${dvd_device} $* dvd://${title}
+        -dvd-device ${dvd_device} ${MPLAYER_OPTIONS} dvd://${title}
 }
 
 function ripdvd () {
@@ -983,7 +1006,7 @@ function lsn () {
             TMP=$(mktemp /tmp/lsn.XXXXXX)
             \ls -pa | sort > ${TMP}
             if diff > /dev/null ${TMP} ${LSN_MEMORY}; then
-                echo "${VT_GREEN_FG}${VT_BOLD}No change${VT_RESET}"
+                echo "${VT_GREEN_FG}${VT_BOLD}No change (since $(date +"%b %d, %Y" -r ${LSN_MEMORY}))${VT_RESET}"
             else
                 \comm -1 -3 ${LSN_MEMORY} ${TMP}
                 \comm -2 -3 ${LSN_MEMORY} ${TMP} | while read line; do