X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=bashrc;h=f23078a37992cc3795c97622ba7ebb28138750ad;hb=4533cd84b6c05d62f049fba6f47530cb972f2194;hp=20cb77dd7ddf77bd78b38e1b8717a5c637bdb729;hpb=715b46d9325d15fc04870c057ce67bf88138b545;p=scripts.git diff --git a/bashrc b/bashrc index 20cb77d..f23078a 100644 --- a/bashrc +++ b/bashrc @@ -1,5 +1,8 @@ # -*-Shell-script-*- +# PS4='+ $(date "+%s.%N")\011 ' +# set -x + ######################################################################### # This program is free software: you can redistribute it and/or modify # # it under the terms of the version 3 of the GNU General Public License # @@ -120,8 +123,9 @@ alias find='ionice -c3 find' alias pd=pushd alias val='valgrind --leak-check=full --show-reachable=yes --db-attach=yes ' -alias s='screen -d -R -U && clear' +alias s='screen -d -R default -U && clear' alias p='feh --force-aliasing -d --full-screen --auto-zoom' +alias gp=gnuplot function nh () { export HISTFILE=/dev/null @@ -205,7 +209,8 @@ function rl () { then if [[ "$1" == "-v" ]] || [[ "$1" == "--view" ]] then - xpdf "${FILEBASE}.pdf" + # xpdf "${FILEBASE}.pdf" + zathura "${FILEBASE}.pdf" elif [[ "$1" == "-p" ]] || [[ "$1" == "--print" ]] then lpr "${FILEBASE}.pdf" @@ -314,7 +319,12 @@ function scan () { # A password generator function genpw () { - tr -dc A-Za-z0-9 < /dev/urandom | head -c16 + PW=$(tr -dc A-Za-z0-9 < /dev/urandom | head -c16) + if [[ ! "$1" == "-s" ]] + then + echo "$(date) ${PW}" >> ${HOME}/private/genpw.log + fi + echo ${PW} # tr -dc [:graph:] < /dev/urandom | head -c16 echo } @@ -375,7 +385,7 @@ function cap () { fi echo "Please click on the window to capture." - xwd | convert - ${name} + xwd | convert xwd:- ${name} \ls -l ${name} } @@ -424,6 +434,23 @@ function trash () { echo "Trashed $@" } +function trashlatex () { + TRASH=$(date +/tmp/trash-latex-${USER}-%Y-%b-%d-%Hh) + LINK=/tmp/trash + + mkdir -p ${TRASH} + + [[ -h ${LINK} ]] && \rm ${LINK} + + [[ ! -f ${LINK} ]] && ln -s ${TRASH} ${LINK} + + mv -v \ + *.log *.pdf *.aux *.nav *.pdfpc *.snm *.toc *.out \ + *.bbl *.blg \ + *.*.table *.*.gnuplot \ + ${TRASH} +} + ###################################################################### ## A version of pho which stores the image numbers in environment ## variables @@ -456,13 +483,7 @@ function dt () { } ###################################################################### -## ifup / ifdown with sudo and memorization of the network - -## When invoked without an argument netup uses the same argument as -## the previous time - -## When invoked without an argument netdown removes the last interface -## which was netuped +## ifup / ifdown with sudo [ ${NETUP_HISTORY} ] || NETUP_HISTORY="${HOME}/.netup_history" @@ -585,11 +606,54 @@ function checkgw () { # Show the most recent files, no scroll function lr () { - HEIGHT=$(stty size | awk '{print $1}') - WIDTH=$(stty size | awk '{print $2}') - \ls -goth --time-style="+%Y %b %d %H:%M" "$@" | \ - head -$((HEIGHT-2)) | \ - cut -b1-${WIDTH} + TERM_SIZE=($(stty size)) + INVIS="${VT_GREEN_FG}${VT_RESET}" + \ls -goth --time-style="+${VT_GREEN_FG}%Y %b %d %H:%M${VT_RESET}" "$@" | \ + head -$((TERM_SIZE[0]-2)) | cut -b1-$((TERM_SIZE[1]+${#INVIS})) +} + +###################################################################### + +reduce-pdf () { + + # /screen selects low-resolution output + # /ebook selects medium-resolution output + # /printer selects "Print Optimized" setting. + # /prepress selects "Prepress Optimized" setting. + + quality="printer" + + while [[ "$1" ]] + do + if [[ "$1" == "--help" ]] || [[ "$1" == "-h" ]] + then + echo "$0 [|--quality ] ..." + return 0 + + elif [[ "$1" == "--quality" ]] + then + shift + quality="$1" + + elif [[ -f "$1" ]] + then + result="$(basename "$1" .pdf)-${quality}.pdf" + echo -n "Generating ${result} with quality ${quality} ... " + gs -sDEVICE=pdfwrite \ + -dCompatibilityLevel=1.4 \ + -dPDFSETTINGS=/${quality} \ + -dColorConversionStrategy=/LeaveColorUnchanged \ + -dNOPAUSE -dQUIET -dBATCH \ + -sOutputFile="${result}" "$1" + echo "done." + ls -hl "$1" "${result}" + + else + echo "Cannot fine $1" + + fi + shift + done } ###################################################################### @@ -1022,7 +1086,7 @@ function prompt_command () { # multiple shells are open history -a # load the saved history - history -n + # history -n # and the local histories system defined above keep_local_history # and the history cue @@ -1038,3 +1102,10 @@ PROMPT_COMMAND="prompt_command" [[ ${TZ} ]] && echo "${VT_BLUE_FG}Time zone is ${TZ}.${VT_RESET}" ###################################################################### + +source /usr/share/bash-completion/bash_completion + +###################################################################### + +# added by Miniconda3 installer +export PATH="/home/fleuret/conda/bin:$PATH"