From: Francois Fleuret Date: Thu, 10 Mar 2011 10:41:06 +0000 (+0100) Subject: Multiple changes! (that's a useful comment) X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=commitdiff_plain;h=d2dc8b041185a0e4d5247d2d877dd9c17b44a446;p=scripts.git Multiple changes! (that's a useful comment) --- diff --git a/bashrc b/bashrc index 66dc586..dbe21a4 100644 --- a/bashrc +++ b/bashrc @@ -103,10 +103,9 @@ alias rd=rmdir alias md='mkdir -v' alias ps='ps uxaf' alias df='df -hT --sync' -alias grep='grep -E --mmap' +alias grep='grep -E --mmap --color=auto' alias s='screen -d -R -U && clear' -alias mc='echo Try mv ' # I'm fed up with midnight commander # alias kj="keyjnote -s -D 1000 -t Crossfade -T 100" alias impressive="impressive -s -D 1000 -t Crossfade -T 100" @@ -137,12 +136,12 @@ export GIT_EDITOR=${EDITOR} ###################################################################### # Ignored extensions when completing -export FIGNORE="CVS" +# export FIGNORE="CVS" ###################################################################### # Functions -# Find a file containing a name +# Find a file whose name contains a substring function fn () { name=$1 @@ -150,6 +149,13 @@ function fn () { find "$@" -name "*${name}*"; } +function bak () { + while [[ "$1" ]]; do + cp "$1" "$1".bak + shift + done +} + # Create a dir and cd there function mcd () { @@ -210,6 +216,19 @@ function mmsget () { mplayer "$1" -dumpstream -dumpfile $(basename "$1") } +function quicktex () { + if [[ $1 ]]; then + MAIN=$1 + else + MAIN=$(\ls -t *.tex | head -1 | sed -r -e 's/\.tex//') + fi + pdflatex ${MAIN} + bibtex ${MAIN} + pdflatex ${MAIN} + pdflatex ${MAIN} + xpdf ${MAIN}.pdf +} + ###################################################################### # http://www.reddit.com/r/linux/comments/akt3j/a_functional_programming_style_map_function_for/ @@ -232,6 +251,10 @@ function map () { done } +function d () { + wget -O - $1 +} + ###################################################################### ## A version of pho which stores the image numbers in environment ## variables @@ -275,17 +298,14 @@ function dt () { ###################################################################### ## ifup / ifdown with sudo and memorization of the network -## When invoked without an argument this "ifup" uses the same argument -## as the previous time +## When invoked without an argument netup uses the same argument as +## the previous time -## When invoked without an argument this "ifdown" removes the last -## interface which was ifuped +## When invoked without an argument netdown removes the last interface +## which was netuped [[ ${NETUP_HISTORY} ]] || NETUP_HISTORY="${HOME}/.netup_history" -alias ifup="echo Try netup" -alias ifdown="echo Try netdown" - function netup () { if [[ ! "$@" ]] && [[ -s ${NETUP_HISTORY} ]]; then # If we have no argument and there is a .netup_history, use it @@ -379,13 +399,12 @@ function keep () { # I sometime burn CDs and DVDs function burn () { - set -e DEVICE="/dev/cdrw" if [[ ! "$1" ]]; then echo "burn " >&2 elif [[ -f "$1" ]]; then if [[ $(file "$1" | grep "ISO 9660") ]]; then - wodim -eject -v dev=${DEVICE} $1 + wodim -eject -v dev=${DEVICE} "$1" else echo "Unknown type of $1" >&2 fi @@ -405,9 +424,11 @@ function burn () { function dvd () { echo - echo " ! and @ Seek to the beginning of the previous/next chapter" - echo " j Cycle through the available subtitles" - echo " o Show/hide the timing" + echo " ! @ Seek to the beginning of the previous/next chapter" + echo " j Cycle through the available subtitles" + echo " o Show/hide the timing" + echo " x z Subtitle delay" + echo " / * Volume" echo if [[ "$1" ]]; then @@ -429,6 +450,7 @@ function dvd () { -vc ffmpeg12 -quiet \ -vf yadif \ -alang en \ + -softvol -softvol-max 1000 \ -dvd-device ${dvd_device} dvd://${title} # -slang en @@ -441,6 +463,8 @@ function ripdvd () { time dvdbackup -v -M && eject } +alias ripcd=abcde + ###################################################################### # Upload the sources from the current directory to work @@ -773,64 +797,52 @@ function selector-history () { selector --bash -c 7,4,0,3 -q <(history) } -# Find pathes in the history and make a list of the existing ones +# M-r puts the selected history line in place of the current one + +bind '"\C-[r":"\C-a\C-kselector-history\C-m"' + +# M-t appends the selected history line and the end of the current one + +bind '"\C-[t":"\C-a\C-kselector-history\C-m\C-a\C-y\C-e"' + +###################################################################### +# Maintain a list of visited directories and provide a selector-based +# command to go back to any of them. + +export CD_HISTORY -export CD_HISTORY=${HOME}/.selector-cd-history +[[ "${CD_HISTORY}" ]] || CD_HISTORY=${HOME}/.selector-cd-history + +function selector-cd-search () { + PATH_TEMP=$(mktemp /tmp/selector-cd-path.XXXXXX) + selector -l 10000 -d -i -o ${PATH_TEMP} -q ${CD_HISTORY} + cd "$(cat ${PATH_TEMP} | sed -e 's|~|'${HOME}'|')" + \rm ${PATH_TEMP} +} function selector-cd () { - if [[ "$1" == "+" ]]; then - PATH_TEMP=$(mktemp /tmp/selector-cd-path.XXXXXX) - selector -d -i -o ${PATH_TEMP} ${CD_HISTORY} - cd "$(cat ${PATH_TEMP} | sed -e 's|~|'${HOME}'|')" - \rm ${PATH_TEMP} + if [[ -z "$1" ]]; then + cd else - if [[ -z "$1" ]]; then - cd - else - cd "$1" - fi - echo $PWD | sed -e "s|${HOME}|~|" >> ${CD_HISTORY} + cd "$1" fi + echo $PWD | sed -e "s!${HOME}!~!" >> ${CD_HISTORY} } alias cd=selector-cd -alias cdd="cd $(tail -1 ${CD_HISTORY})" # M-c provides a dynamic list of directories to cd into -bind '"\C-[c":"\C-a\C-kselector-cd +\C-m"' - -# function selector-cd () { -# LIST_TEMP=$(mktemp /tmp/selector-cd-list.XXXXXX) -# PATH_TEMP=$(mktemp /tmp/selector-cd-path.XXXXXX) -# for d in $(history | \ -# grep ^" *[0-9]* *cd" | \ -# awk '{ print $3 }' | \ -# grep -v "\.\." | \ -# uniq); do -# if [[ -d $d ]]; then -# echo "$d" -# fi -# done >> ${LIST_TEMP} -# selector -d -i -o ${PATH_TEMP} ${LIST_TEMP} -# cd $(cat ${PATH_TEMP}) -# \rm ${LIST_TEMP} -# \rm ${PATH_TEMP} -# } - -# M-r puts the selected history line in place of the current one - -bind '"\C-[r":"\C-a\C-kselector-history\C-m"' - -# M-t appends the selected history line and the end of the current one - -bind '"\C-[t":"\C-a\C-kselector-history\C-m\C-a\C-y\C-e"' +bind '"\C-[c":"\C-a\C-kselector-cd-search\C-m"' +###################################################################### # And we avoid to put in the history the use of the selector, which we # do too often HISTIGNORE="${HISTIGNORE}:selector-history" +###################################################################### + function selector-printer () { TMP=$(mktemp /tmp/selector-printer.XXXXXX) selector -o ${TMP} <(lpstat -a | awk '{print $1}')