From: Francois Fleuret Date: Mon, 30 Jun 2014 08:50:17 +0000 (+0200) Subject: Update of the 'keep' command so that it now uses selector when available. X-Git-Url: https://www.fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=commitdiff_plain;ds=sidebyside;h=d26b38afff52ff3b13303962bda478884696e0f0;hp=ae7f4b84ee0a0d6302f98d48d1720b255cf3ec40;p=scripts.git Update of the 'keep' command so that it now uses selector when available. --- diff --git a/bashrc b/bashrc index b4da27d..0ce1e40 100644 --- 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 " >&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