X-Git-Url: https://www.fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=bashrc;h=4ae13cb788fcf8c440a99195559581f9ee8ee447;hb=46103bc8002cd6365de73e8a54481f1115f0f4c1;hp=b7e32623b0486be8937e493793b79c931f936043;hpb=7d0d106afa93fa5dba16c59fad371c94e0f55af3;p=scripts.git diff --git a/bashrc b/bashrc index b7e3262..4ae13cb 100644 --- a/bashrc +++ b/bashrc @@ -23,11 +23,11 @@ PRIVATE_BASHRC="${HOME}/private/bashrc.perso" # If the MANPATH is not set, set it -[ "${MANPATH}" ] || MANPATH=$(manpath) +[[ "${MANPATH}" ]] || MANPATH=$(manpath) # If the private bashrc exists, execute it -[ -f "${PRIVATE_BASHRC}" ] && source "${PRIVATE_BASHRC}" +[[ -f "${PRIVATE_BASHRC}" ]] && source "${PRIVATE_BASHRC}" # !!! THIS HAS TO BE HERE EVEN IN THE NON-INTERACTIVE PART OR YOU WILL # LOSE YOU PREVIOUS HISTORY !!! @@ -168,7 +168,9 @@ function latexdiff () { # corresponding tex file function rl () { - RECENT_LOG=$(ls -t $(find -maxdepth 1 -name "*.log" -type f) | head -1) + # RECENT_LOG=$(ls -t $(find -maxdepth 1 -name "*.log" -type f) | head -1) + + RECENT_LOG=$(ls -t *.log | head -1) if [[ ${RECENT_LOG} ]]; then FILEBASE="${RECENT_LOG/.log/}" @@ -238,6 +240,14 @@ function bak () { done } +# A password generator + +function genpw () { + tr -dc A-Za-z0-9 < /dev/urandom | head -c16 + # tr -dc [:graph:] < /dev/urandom | head -c16 + echo +} + function ua () { [[ "$1" ]] || ( echo "Universal unarchive: ua [ ...]" >&2 && return 1) @@ -533,12 +543,12 @@ function keep () { # I sometime burn CDs and DVDs function burn () { - DEVICE="/dev/cdrw1" + [[ "${DEV_BURNER}" ]] || DEV_BURNER="/dev/sr0" if [[ ! "$1" ]]; then echo "burn " >&2 elif [[ -f "$1" ]]; then if [[ $(file "$1" | \grep -E 'ISO 9660|UDF filesystem data') ]]; then - wodim -eject -v dev=${DEVICE} "$1" + wodim -eject -v dev=${DEV_BURNER} "$1" else echo "Do not know what to do with $1" >&2 fi @@ -547,7 +557,7 @@ function burn () { echo "Using ${TMP_ROOT} as temporary directory." TMP=$(mktemp ${TMP_ROOT}/cdimage.XXXXXX) && \ genisoimage -input-charset iso8859-1 -r -o ${TMP} "$1" && \ - wodim -eject -v dev=${DEVICE} ${TMP} + wodim -eject -v dev=${DEV_BURNER} ${TMP} rm -f ${TMP} else echo "Can not find $1" >&2 @@ -616,7 +626,13 @@ alias ripcd=abcde function mksmall () { - PARAMS="-geometry 800x600" + if [[ "$1" == "--params" ]]; then + shift + PARAMS="$1" + shift + fi + + [[ "${PARAMS}" ]] || PARAMS="-geometry 800x600" # Auto-orient does not seem to work at all, hence the ugly hack # with exif below @@ -703,25 +719,19 @@ else [[ "${IDENT}" ]] && IDENT="${IDENT}:" - # If we are root, show that in red - if [[ ${USER} == "root" ]]; then + # If we are root, show that in red PS1="\[${VT_RED_BG}${VT_WHITE_FG}\]${IDENT}\w\[${VT_RESET}\] " else - PS1="\[${VT_WHITE_BG}${VT_BLACK_FG}\]${IDENT}\w\[${VT_RESET}\] " + if [[ $(\grep QEMU /proc/cpuinfo) ]]; then + # If we are in a qemu virtual machine, in yellow + PS1="\[${VT_YELLOW_BG}${VT_BLACK_FG}\]${IDENT}\w\[${VT_RESET}\] " + else + # Otherwise in white + PS1="\[${VT_WHITE_BG}${VT_BLACK_FG}\]${IDENT}\w\[${VT_RESET}\] " + fi fi - # In an xterm, show the hostname and path in the title bar, highlight - # the prompt - - # [[ "${TERMS_WITH_BAR}" ]] || TERMS_WITH_BAR="^xterm|screen$" - - # if [[ "${TERM}" =~ "${TERMS_WITH_BAR}" ]]; then - # PS1="\[${VT_SET_TITLE}shell@\h (\w)${VT_END_TITLE}${VT_WHITE_BG}\]${IDENT}\w\[${VT_RESET}\] " - # else - # PS1="\[${VT_WHITE_BG}\]${IDENT}\w\[${VT_RESET}\] " - # fi - fi ###################################################################### @@ -780,6 +790,8 @@ alias finddup='finddup -p' # # git clone http://fleuret.org/git/selector/ +export SELECTOR_CD_HISTORY_SIZE=10000 + source bash-selector.sh --hist --cd ###################################################################### @@ -851,6 +863,9 @@ function lsn () { ###################################################################### function prompt_command () { + # if [[ $(umask) != 0022 ]]; then + # echo "Umask changed to $(umask)" + # fi # save the history after every command to avoid loosing some when # multiple shells are open history -a