X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=bashrc;h=1a947db7768d411499b0d38417e84a59bd030f6d;hb=0112da1a38def39a00d6c3d9fbc07a4efb4fb812;hp=0b09ca9d6274aedb5293d3af08921551572ad699;hpb=5d1aa1fd3b6c8a003dd3789791a349f34a0b0c14;p=scripts.git diff --git a/bashrc b/bashrc index 0b09ca9..1a947db 100644 --- a/bashrc +++ b/bashrc @@ -106,7 +106,7 @@ alias mv='mv -i' alias chmod='chmod -c' alias cp='cp -i -v' alias rd=rmdir -alias md='mkdir -v' +alias md='mkdir -pv' alias ps='ps uxaf' alias df='df -hT --sync' alias grep='grep -i -E --color=auto' @@ -140,18 +140,18 @@ alias impressive="impressive -s -D 1000 -t Crossfade -T 100" if [ -e "${HOME}/.dircolors" ]; then eval $(dircolors "${HOME}/.dircolors") - alias ls='ls --group-directories-first --color' - alias lt='ls --color -gohtr --time-style="+%Y %b %d %H:%M"' - alias ll='ls --color -goh --time-style="+%Y %b %d %H:%M"' - alias lll='ls --color -lth' - alias l='ls --color -I "*~" -I "*.o"' + alias ls='ls -p --group-directories-first --color' + alias lt='ls -p --color -gohtr --time-style="+%Y %b %d %H:%M"' + alias ll='ls -p --color -goh --time-style="+%Y %b %d %H:%M"' + alias lll='ls -p --color -lth' + alias l='ls -p --color -I "*~" -I "*.o"' alias less='less -R' else - alias ls='ls --group-directories-first' - alias lt='ls -gohtr --time-style="+%Y %b %d %H:%M"' - alias ll='ls -goh --time-style="+%Y %b %d %H:%M"' - alias lll='ls -lth' - alias l='ls -I "*~" -I "*.o"' + alias ls='ls -p --group-directories-first' + alias lt='ls -p -gohtr --time-style="+%Y %b %d %H:%M"' + alias ll='ls -p -goh --time-style="+%Y %b %d %H:%M"' + alias lll='ls -p -lth' + alias l='ls -p -I "*~" -I "*.o"' fi export EDITOR=emacsclient @@ -185,15 +185,24 @@ function rl () { if [[ ${RECENT_LOG} ]]; then FILEBASE="${RECENT_LOG/.log/}" - pdflatex "${FILEBASE}" - bibtex "${FILEBASE}" - pdflatex "${FILEBASE}" - pdflatex "${FILEBASE}" + if [[ -f "${FILEBASE}.tex" ]]; then + + pdflatex "${FILEBASE}" + bibtex "${FILEBASE}" + pdflatex "${FILEBASE}" + pdflatex "${FILEBASE}" + + if [[ "$1" == "--view" ]]; then + xpdf "${FILEBASE}.pdf" + elif [[ "$1" == "--print" ]]; then + lpr "${FILEBASE}.pdf" + fi + + else + + echo "Can not find a tex file corresponding to the most recent log (${RECENT_LOG/.log/})." >&2 + return 1 - if [[ "$1" == "--view" ]]; then - xpdf "${FILEBASE}.pdf" - elif [[ "$1" == "--print" ]]; then - lpr "${FILEBASE}.pdf" fi else @@ -285,7 +294,15 @@ function cdt () { return 1 fi else - cd $(mktemp -d /tmp/tmp.XXXXXX) + dir=$(mktemp -d /tmp/tmp.XXXXXX) + link=/tmp/tmp + if [[ -h ${link} ]]; then + \rm ${link} + fi + if [[ ! -a ${link} ]]; then + ln -s ${dir} ${link} + fi + cd ${dir} fi } @@ -293,13 +310,12 @@ alias t='cd /tmp' function trash () { TRASH=$(date +/tmp/trash-%Y-%b-%d-%Hh) + LINK=/tmp/trash - if [[ -d ${TRASH} ]]; then - echo "Re-use ${TRASH}" - else - mkdir ${TRASH} - echo "Created ${TRASH}" - fi + mkdir -p ${TRASH} + + [[ -h ${LINK} ]] && \rm ${LINK} + [[ ! -f ${LINK} ]] && ln -s ${TRASH} ${LINK} mv "$@" ${TRASH} echo "Trashed $@" @@ -922,17 +938,22 @@ function selector-printer () { # the current directory function lsn () { - LSN_MEMORY=".lsn-mem" - if [[ $1 == "--mem" ]]; then - \ls > ${LSN_MEMORY} + LSN_MEMORY=".lsn-state" + if [[ $1 == "--mem" ]] || [[ "$1" == "-m" ]]; then + \ls -pa | sort > ${LSN_MEMORY} + echo "State updated." >&2 + elif [[ -n "$1" ]]; then + echo "lsn [--mem|-m]" >&2 + return 1 else if [[ -f ${LSN_MEMORY} ]]; then - comm -1 -3 ${LSN_MEMORY} <(\ls) - comm -2 -3 ${LSN_MEMORY} <(\ls) | while read line; do + comm -1 -3 ${LSN_MEMORY} <(\ls -pa | sort) + comm -2 -3 ${LSN_MEMORY} <(\ls -pa | sort) | while read line; do echo "${VT_RED_FG}${VT_BOLD}${line}${VT_RESET} (missing)" done else - echo "No lsn memory here." >&2 + echo "No lsn state here." >&2 + return 1 fi fi }