3 # PS4='+ $(date "+%s.%N")\011 '
6 #########################################################################
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the version 3 of the GNU General Public License #
9 # as published by the Free Software Foundation. #
11 # This program is distributed in the hope that it will be useful, but #
12 # WITHOUT ANY WARRANTY; without even the implied warranty of #
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU #
14 # General Public License for more details. #
16 # You should have received a copy of the GNU General Public License #
17 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
19 # Written by and Copyright (C) Francois Fleuret #
20 # Contact <francois@fleuret.org> for comments & bug reports #
21 #########################################################################
23 # The site-specific and confidential settings are in another file
25 PRIVATE_BASHRC="${HOME}/private/bashrc.perso"
27 # If the MANPATH is not set, set it
29 [[ "${MANPATH}" ]] || MANPATH=$(manpath)
31 # If the private bashrc exists, execute it
33 [[ -f "${PRIVATE_BASHRC}" ]] && source "${PRIVATE_BASHRC}"
35 # !!! THIS HAS TO BE HERE EVEN IN THE NON-INTERACTIVE PART OR YOU WILL
36 # LOSE YOU PREVIOUS HISTORY !!!
38 export HISTFILESIZE=20000
39 export HISTSIZE=${HISTFILESIZE}
41 export HISTIGNORE="${HISTIGNORE}:&:[ ]*"
43 # I want to save the command time, but I do not want to see it in
46 export HISTTIMEFORMAT=""
50 # I realized that most of my settings are meaningful only in
51 # interactive mode. This should maybe be done more properly through
52 # using different .bash_profile and .bash_login
54 [ ${TERM} == "dumb" ] || [[ ! -t 0 ]] && return
56 # Remove the annoying beeps in console
60 # || setterm --blength 0 # Seriously?
62 ######################################################################
63 ## The interactive part
65 export VT_RESET=$'\e[0m'
66 export VT_BOLD=$'\e[1m'
67 export VT_UNDERLINE=$'\e[4m'
68 export VT_BLINK=$'\e[5m'
70 export VT_SET_TITLE=$'\e]0;'
71 export VT_END_TITLE=$'\007'
73 export VT_BLACK_FG=$'\e[30m'
74 export VT_RED_FG=$'\e[31m'
75 export VT_GREEN_FG=$'\e[32m'
76 export VT_YELLOW_FG=$'\e[33m'
77 export VT_BLUE_FG=$'\e[34m'
78 export VT_MAGENTA_FG=$'\e[35m'
79 export VT_CYAN_FG=$'\e[36m'
80 export VT_WHITE_FG=$'\e[37m'
82 export VT_BLACK_BG=$'\e[40m'
83 export VT_RED_BG=$'\e[41m'
84 export VT_GREEN_BG=$'\e[42m'
85 export VT_YELLOW_BG=$'\e[43m'
86 export VT_BLUE_BG=$'\e[44m'
87 export VT_MAGENTA_BG=$'\e[45m'
88 export VT_CYAN_BG=$'\e[46m'
89 export VT_WHITE_BG=$'\e[47m'
93 export LESS_TERMCAP_us=${VT_GREEN_FG}
94 export LESS_TERMCAP_ue=${VT_RESET}
95 export LESS_TERMCAP_md=${VT_BLUE_FG}${VT_BOLD}
96 export LESS_TERMCAP_me=${VT_RESET}
98 # I do not like to clutter my home with history files
100 export LESSHISTFILE=/dev/null
102 # export LESS_TERMCAP_md=$'\e[1;34;40m'
104 # This prevents ^S from freezing the shell
114 alias chmod='chmod -c'
120 # alias df='df -hT --sync'
121 alias grep='grep -i -E --color=auto'
122 alias find='ionice -c3 find'
124 alias val='valgrind --leak-check=full --show-reachable=yes --db-attach=yes '
126 alias s='screen -d -R default -U && clear'
127 alias p='feh --force-aliasing -d --full-screen --auto-zoom'
131 export HISTFILE=/dev/null
135 function select-tz () {
136 # Select a value for TZ
137 TMP=$(mktemp /tmp/select-tz.XXXXXX)
138 selector -o "${TMP}" <(grep -v ^# /usr/share/zoneinfo/zone.tab | awk '{print $3}' | sort -u)
144 if [[ $1 ]] && which winshepherd.sh
146 play -q ~/local/sounds/deskbell.wav &
148 winshepherd.sh message green "$1"
150 play -q ~/local/sounds/deskbell.wav
154 alias impressive="impressive -s -D 1000 -t Crossfade -T 100"
156 if [[ -e "${HOME}/.dircolors" ]]
158 eval $(dircolors "${HOME}/.dircolors")
159 alias ls='ls -p --group-directories-first --color'
160 alias lt='ls -p --color -gohtr --time-style="+%Y %b %d %H:%M"'
161 alias ll='ls -p --color -goh --time-style="+%Y %b %d %H:%M"'
162 alias lll='ls -p --color -lth'
163 alias l='ls -p --color -I "*~" -I "*.o"'
166 alias ls='ls -p --group-directories-first'
167 alias lt='ls -p -gohtr --time-style="+%Y %b %d %H:%M"'
168 alias ll='ls -p -goh --time-style="+%Y %b %d %H:%M"'
169 alias lll='ls -p -lth'
170 alias l='ls -p -I "*~" -I "*.o"'
173 export EDITOR=emacsclient
174 export GIT_EDITOR=${EDITOR}
176 ######################################################################
177 # Ignored extensions when completing
179 # export FIGNORE="CVS"
181 function latexdiff () {
183 -w $'\033[30;41m' -x $'\033[0m' \
184 -y $'\033[30;42m' -z $'\033[0m' \
188 # Looks for the most recent .log and pdflatex + bibtex the
189 # corresponding tex file
192 # RECENT_LOG=$(ls -t $(find -maxdepth 1 -name "*.log" -type f) | head -1)
194 RECENT_LOG=$(ls -t *.log | head -1)
196 if [[ ${RECENT_LOG} ]]
198 FILEBASE="${RECENT_LOG/.log/}"
200 if [[ -f "${FILEBASE}.tex" ]]
203 pdflatex --shell-escape "${FILEBASE}"
205 pdflatex --shell-escape "${FILEBASE}"
206 pdflatex --shell-escape "${FILEBASE}"
210 if [[ "$1" == "-v" ]] || [[ "$1" == "--view" ]]
212 # xpdf "${FILEBASE}.pdf"
213 zathura "${FILEBASE}.pdf"
214 elif [[ "$1" == "-p" ]] || [[ "$1" == "--print" ]]
216 lpr "${FILEBASE}.pdf"
218 echo "Usage: rl [-v|--view] [-p|--print]" >&2
219 echo "Unknown option $1" >&2
226 echo "Can not find a tex file corresponding to the most recent log (${RECENT_LOG/.log/})." >&2
232 echo "Can not find a recent log." >&2
238 ######################################################################
241 # http://www.reddit.com/r/linux/comments/2cgu5k/a_handy_little_script_for_interacting_with_your/
243 if [[ -t 0 ]] && [[ -z "$1" ]]
245 # output contents of clipboard
246 xclip -out -selection clipboard || exit 1
249 # copy file contents to clipboard
250 xclip -in -selection clipboard < "$1" || exit 1
252 # copy stdin to clipboard
253 xclip -in -selection clipboard <&0 || exit 1
257 # Find a file whose name contains a substring
262 find "$@" -name "*${name}*";
276 while [[ -f "${HOME}/scan-${n}.jpg" ]]
283 if [[ "$1" == "color" ]]
285 OPTS+=" --mode Color"
286 elif [[ "$1" == "gray" ]]
289 elif [[ "$1" == "a4crop" ]]
291 OPTS+=" -l 5 -t 0 -x 200 -y 300"
292 elif [[ "$1" == "help" ]] || [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]
294 echo "$0 [color|gray] [a4crop]" && return 0
296 echo "Unknown argument \`$1'"
302 echo "** Scanning to ${HOME}/scan-${n}.jpg"
305 SCANNER=$(scanimage -L | grep "Canon LiDE 60" | sed -e "s/^.*\`\(.*\)'.*$/\1/")
307 scanimage -d ${SCANNER} \
314 convert -rotate 180 - "${HOME}/scan-${n}.jpg"
319 # A password generator
322 PW=$(tr -dc A-Za-z0-9 < /dev/urandom | head -c16)
323 if [[ ! "$1" == "-s" ]]
325 echo "$(date) ${PW}" >> ${HOME}/private/genpw.log
328 # tr -dc [:graph:] < /dev/urandom | head -c16
334 [[ "$1" ]] || ( echo "Universal unarchive: ua <file> [<file> ...]" >&2 && return 1)
340 *.tgz|*.tar.gz|*.tbz|*.tar.bz2)
353 echo "Unknown file extension $1"
362 # Create a dir and cd there
369 # Capture the screen in a dated png
376 name="capture-$(date +%s).png"
381 echo "Waiting $1 s and saving to ${name}."
384 echo "Saving to ${name}."
387 echo "Please click on the window to capture."
388 xwd | convert xwd:- ${name}
392 # Create and CD in a /tmp/tmp.XXXXXX directory. With the '-'
393 # arguments, do not create one and CD in the most recent instead
400 cd $(\ls -td /tmp/tmp.?????? | head -1)
402 echo "USAGE: cdt [-]" >&2
406 dir=$(mktemp -d /tmp/tmp.XXXXXX)
412 if [[ ! -a ${link} ]]
424 TRASH=$(date +/tmp/trash-${USER}-%Y-%b-%d-%Hh)
429 [[ -h ${LINK} ]] && \rm ${LINK}
431 [[ ! -f ${LINK} ]] && ln -s ${TRASH} ${LINK}
437 function trashlatex () {
438 TRASH=$(date +/tmp/trash-latex-${USER}-%Y-%b-%d-%Hh)
443 [[ -h ${LINK} ]] && \rm ${LINK}
445 [[ ! -f ${LINK} ]] && ln -s ${TRASH} ${LINK}
448 *.log *.pdf *.aux *.nav *.pdfpc *.snm *.toc *.out \
450 *.*.table *.*.gnuplot \
454 ######################################################################
455 ## A version of pho which stores the image numbers in environment
459 TEMP=$(mktemp /tmp/pho.XXXXXXX)
460 $(which pho) "$@" | tee ${TEMP}
461 PHO_NOTE_1=$(grep ^"Note 1: " ${TEMP} | sed -e "s/^[^:]*: //")
462 PHO_NOTE_2=$(grep ^"Note 2: " ${TEMP} | sed -e "s/^[^:]*: //")
463 PHO_NOTE_3=$(grep ^"Note 3: " ${TEMP} | sed -e "s/^[^:]*: //")
464 PHO_NOTE_R90=$(grep ^"Rotate 90 \(CW\): " ${TEMP} | sed -e "s/^[^:]*: //")
465 PHO_NOTE_R180=$(grep ^"Rotate 180: " ${TEMP} | sed -e "s/^[^:]*: //")
466 PHO_NOTE_R270=$(grep ^"Rotate -90 \(CCW\): " ${TEMP} | sed -e "s/^[^:]*: //")
467 [[ "${PHO_NOTE_1}" ]] || unset PHO_NOTE_1
468 [[ "${PHO_NOTE_2}" ]] || unset PHO_NOTE_2
469 [[ "${PHO_NOTE_3}" ]] || unset PHO_NOTE_3
470 [[ "${PHO_NOTE_R90}" ]] || unset PHO_NOTE_R90
471 [[ "${PHO_NOTE_R180}" ]] || unset PHO_NOTE_R180
472 [[ "${PHO_NOTE_R270}" ]] || unset PHO_NOTE_R270
476 ######################################################################
477 ## A version of date that shows the time at home if TZ is set
480 echo "Local - $(date)"
482 echo "Home - $(date)"
485 ######################################################################
486 ## ifup / ifdown with sudo
488 [ ${NETUP_HISTORY} ] || NETUP_HISTORY="${HOME}/.netup_history"
493 [[ "${WIFI_INTERFACE}" ]] || WIFI_INTERFACE=wlan0
495 if [[ "$1" == "--scan" ]]
497 if ifconfig -s | grep -v -q ${WIFI_INTERFACE}
499 sudo ifconfig ${WIFI_INTERFACE} up
503 sudo iwlist ${WIFI_INTERFACE} scan | \grep -E 'ESS|Quali|Encry' | sed -e 's/^[ \t]*//'
505 if [[ ${upped_wifi} ]]
507 sudo ifconfig ${WIFI_INTERFACE} down
514 if \ifconfig -s | grep -q -v ^'(Iface|lo) '
516 echo "There is/are already interface(s) up." >&2
520 if \ps h -C dhclient | grep -q .
522 echo "There is already a dhcp client running." >&2
526 if \ps h -C wpa_supplicant | grep -q .
528 echo "There is already a wpa_supplicant running." >&2
532 if [[ ! "$@" ]] && [[ -s ${NETUP_HISTORY} ]]
534 echo "netup <interface>" >&2
536 # # If we have no argument and there is a .netup_history, use it
537 # ARGS=$(cat ${NETUP_HISTORY})
539 # Otherwise uses the given arguments, and store them
541 echo ${ARGS} > ${NETUP_HISTORY}
544 if [[ "${PRIVATE_INTERFACE_DEFINITION}" ]]
546 ARGS="-i ${PRIVATE_INTERFACE_DEFINITION} ${ARGS}"
549 echo "Executing ${VT_GREEN_FG}[sudo ifup ${ARGS}]${VT_RESET}"
552 # Ugly hack to remove the dsl modem dns server when we add
553 # explicitely a dns in the /etc/network/interfaces
555 REMOVE_LOCAL_DNS=/usr/local/bin/remove-local-dns.sh
556 # REMOVE_LOCAL_DNS=${HOME}/sources/scripts/remove-local-dns.sh
558 if [[ -x ${REMOVE_LOCAL_DNS} ]]
560 echo "Executing ${VT_GREEN_FG}[sudo ${REMOVE_LOCAL_DNS} 192.168]${VT_RESET}"
561 sudo ${REMOVE_LOCAL_DNS} 192.168
565 function netdown () {
566 if [[ ! "$@" ]] && [[ -s ${NETUP_HISTORY} ]]
568 # If there are no arguments and there is a .netup_history, get the
570 ARGS=$(tail -1 ${NETUP_HISTORY} | sed -e "s/=.*$//")
572 # Otherwise, use the standard ifdown
576 [[ "${PRIVATE_INTERFACE_DEFINITION}" ]] && ARGS="-i ${PRIVATE_INTERFACE_DEFINITION} ${ARGS}"
578 echo "Executing sudo ${VT_GREEN_FG}[ifdown ${ARGS}]${VT_RESET}"
581 # if [[ $(\ps -C dhclient | tail -n +2) ]]
583 # echo "There is still a dhcp client running." >&2
587 # if [[ $(\ps -C wpa_supplicant | tail -n +2) ]]
589 # echo "There is still a wpa_supplicant running." >&2
594 function checkgw () {
595 GW=$(route -n | grep ^0.0.0.0 | awk '{print $2}')
600 echo "Can not find a getaway." >&2
605 ######################################################################
606 # Show the most recent files, no scroll
609 TERM_SIZE=($(stty size))
610 INVIS="${VT_GREEN_FG}${VT_RESET}"
611 \ls -goth --time-style="+${VT_GREEN_FG}%Y %b %d %H:%M${VT_RESET}" "$@" | \
612 head -$((TERM_SIZE[0]-2)) | cut -b1-$((TERM_SIZE[1]+${#INVIS}))
615 ######################################################################
619 # /screen selects low-resolution output
620 # /ebook selects medium-resolution output
621 # /printer selects "Print Optimized" setting.
622 # /prepress selects "Prepress Optimized" setting.
628 if [[ "$1" == "--help" ]] || [[ "$1" == "-h" ]]
630 echo "$0 [<file.pdf>|--quality <screen|ebook|printer|prepress>] ..."
633 elif [[ "$1" == "--quality" ]]
640 result="$(basename "$1" .pdf)-${quality}.pdf"
641 echo -n "Generating ${result} with quality ${quality} ... "
642 gs -sDEVICE=pdfwrite \
643 -dCompatibilityLevel=1.4 \
644 -dPDFSETTINGS=/${quality} \
645 -dColorConversionStrategy=/LeaveColorUnchanged \
646 -dNOPAUSE -dQUIET -dBATCH \
647 -sOutputFile="${result}" "$1"
649 ls -hl "$1" "${result}"
652 echo "Cannot fine $1"
659 ######################################################################
660 # You can change the xterm background color on the fly!
662 function setxtermbg () {
663 echo -n $'\e]11;'$1$'\007'
666 ######################################################################
667 # Shuffle the lines from the stdin
669 function shuffle () {
671 [[ $SEED ]] || SEED=0
672 awk 'BEGIN{srand('${SEED}')} { print rand()" "$0 }' | sort -g | sed -e "s/^[0-9\.e\-]* //"
675 ######################################################################
676 # Stores the last entered command into a file
678 KEPT_COMMANDS=${HOME}/.kept_bash_commands
681 if [[ ${KEPT_COMMANDS} ]]
683 TOKEEP=$(mktemp /tmp/keep.XXXXXX)
686 echo "$@" > ${TOKEEP}
688 selector -b -i -d -l ${HISTSIZE} -o "${TOKEEP}" <(history)
691 if [[ -s "${TOKEEP}" ]]
693 echo $(date)": "$(cat ${TOKEEP}) >> ${KEPT_COMMANDS}
696 echo "No command stored!"
701 echo "You have to set \$KEPT_COMMANDS"
705 ######################################################################
706 # I sometime burn CDs and DVDs
709 [[ "${DEV_BURNER}" ]] || DEV_BURNER="/dev/sr0"
712 echo "burn <iso name | dirname>" >&2
715 if [[ $(file "$1" | \grep -E 'ISO 9660|UDF filesystem data') ]]
717 wodim -eject -v dev=${DEV_BURNER} "$1"
719 echo "Do not know what to do with $1" >&2
723 [[ "${TMP_ROOT}" ]] || TMP_ROOT=/tmp/
724 echo "Using ${TMP_ROOT} as temporary directory."
725 TMP=$(mktemp ${TMP_ROOT}/cdimage.XXXXXX) && \
726 genisoimage -input-charset iso8859-1 -r -o ${TMP} "$1" && \
727 wodim -eject -v dev=${DEV_BURNER} ${TMP}
730 echo "Can not find $1" >&2
734 ######################################################################
735 # And watch DVDs too!
740 echo " ! @ Seek to the beginning of the previous/next chapter"
741 echo " j Cycle through the available subtitles"
742 echo " o Show/hide the timing"
743 echo " x z Subtitle delay"
752 dvd_device="/dev/dvd"
763 # -vc ffmpeg12 -vf yadif
765 mplayer > /dev/null \
768 -alang en -slang en \
769 -softvol -softvol-max 1000 \
770 -dvd-device ${dvd_device} ${MPLAYER_OPTIONS} dvd://${title}
774 if [[ -e "/dev/dvd" ]]
776 DVD_DEVICE="/dev/dvd"
777 elif [[ -e "/dev/dvd3" ]]
779 DVD_DEVICE="/dev/dvd3"
781 echo "Can not find the dvd device." >&2
785 echo "Attemptin to rip from ${DVD_DEVICE}."
787 mkdir -p ${HOME}/dvds
790 time dvdbackup -i ${DVD_DEVICE} -v -M "$@" && eject
795 ######################################################################
796 # Create small images from images
798 function mksmall () {
800 if [[ "$1" == "--params" ]]
807 [[ "${PARAMS}" ]] || PARAMS="-geometry 1280x1024"
809 # Auto-orient does not seem to work at all, hence the ugly hack
812 # PARAMS="-auto-orient -geometry 800x600"
814 echo "Using ${PARAMS}"
818 [[ ${DEST_DIR} ]] || DEST_DIR=./small
822 if [[ ! -d ${DEST_DIR} ]]
824 echo "Can not create ${DEST_DIR}" >&2
828 NB_TOTAL=$(find -maxdepth 1 -type f | wc -l)
831 for i in $(find -maxdepth 1 -type f)
833 if [[ $(file $i | grep image) ]]
835 if [[ -e ${DEST_DIR}/$i ]]
837 echo "The file ${DEST_DIR}/$i already exists."
839 if [[ $(file ${i/%.*/}.* | grep -E movie) ]]
841 CAPTION_PARAMS="-font FreeSans-Bold -pointsize 32 -fill green -annotate +10+32 Video"
846 convert ${rotation_cmd} $i ${PARAMS} ${CAPTION_PARAMS} ${DEST_DIR}/$i
849 \ls -lt ${DEST_DIR}/$i
854 echo "$((NB*100/NB_TOTAL))% (${NB}/${NB_TOTAL})"
858 ######################################################################
859 # Move a file to the ~/sources/config directory and replace it where
860 # it was by a symbolic link
862 function mvtoconfig () {
863 CONFIGDIR=${HOME}/sources/config
864 if [[ -d ${CONFIGDIR} ]]
866 NEWNAME=${CONFIGDIR}/$(basename "$1" | sed -e "s/^\.//")
870 echo "Can not find ${CONFIGDIR}"
874 ######################################################################
875 # The complex prompt policy
879 if [[ "${CONSOLE}" == "yes" ]]
886 # If the login is a standard one (as specified in
887 # IGNORED_PROMPT_LOGIN, which is set in the private bash file), do not
888 # show it. I have IGNORED_PROMPT_LOGIN="^fleuret$".
890 if [[ ! ${IGNORED_PROMPT_LOGIN} ]] || [[ ! ${USER} =~ ${IGNORED_PROMPT_LOGIN} ]]
895 # If the display is not the main one, make the assumption that the
896 # shell is not running on the localhost, and show the hostname
898 [[ "${DISPLAY}" != ":0.0" ]] && IDENT="${IDENT}@\h"
900 # If there is the login or the hostname, add a ":" to the prompt
902 [[ "${IDENT}" ]] && IDENT="${IDENT}:"
904 if [[ ${USER} == "root" ]]
906 # If we are root, show that in red
907 PS1="\[${VT_RED_BG}${VT_WHITE_FG}\]${IDENT}\w\[${VT_RESET}\] "
909 if [[ $(\grep QEMU /proc/cpuinfo) ]]
911 # If we are in a qemu virtual machine, in yellow
912 PS1="\[${VT_YELLOW_BG}${VT_BLACK_FG}\]${IDENT}\w\[${VT_RESET}\] "
915 PS1="\[${VT_WHITE_BG}${VT_BLACK_FG}\]${IDENT}\w\[${VT_RESET}\] "
923 ######################################################################
924 # This implements a local history. If we are in a directory containing
925 # a writable local history file, we add the last line of the global
928 LOCAL_HISTORY_FILE=".local_bash_history"
930 function keep_local_history () {
931 if [[ -w "${LOCAL_HISTORY_FILE}" ]]
933 history 1 | sed -e 's/^ *[0-9]* *//' >> ${LOCAL_HISTORY_FILE}
934 TMP=$(mktemp /tmp/lh.XXXXXX)
936 uniq < ${LOCAL_HISTORY_FILE} | tail -${HISTSIZE} > ${TMP}
937 # mv would replace a symbolic link, while cp keeps it
938 \cp ${TMP} ${LOCAL_HISTORY_FILE}
940 LOCAL_HISTORY_HINT="* "
942 LOCAL_HISTORY_HINT=""
946 PS1="\[${VT_WHITE_BG}\]\${LOCAL_HISTORY_HINT}\[${VT_RESET}\]${PS1}"
948 ######################################################################
949 # Show the history path if it is unusual
951 function histfile_cue () {
952 if [[ ! "${HISTFILE}" == "${HOME}/.bash_history" ]]
954 HISTORY_CUE="[${HISTFILE}]"
960 PS1="\[${VT_YELLOW_BG}\]\${HISTORY_CUE}\[${VT_RESET}\]${PS1}"
962 ######################################################################
963 # The dus command is available on my web site
965 # git clone http://fleuret.org/git/dus/
967 alias dus='dus -f -i'
969 ######################################################################
970 # The finddup command is available on my web site
972 # git clone http://fleuret.org/git/finddup/
974 alias finddup='finddup -p'
976 ######################################################################
977 # The selector command is available on my web site
979 # git clone http://fleuret.org/git/selector/
981 export SELECTOR_CD_HISTORY_SIZE=10000
983 source bash-selector.sh --hist --cd
985 ######################################################################
986 # And we avoid to put in the history the use of the selector, which we
989 HISTIGNORE="${HISTIGNORE}:selector-history"
991 ######################################################################
993 function selector-printer () {
994 TMP=$(mktemp /tmp/selector-printer.XXXXXX)
995 selector -o ${TMP} <(lpstat -a | awk '{print $1}')
996 export PRINTER=$(cat ${TMP})
997 echo "PRINTER=${PRINTER}"
1002 ######################################################################
1003 # A ls with memory to notice what files have been added/removed from
1004 # the current directory
1007 [[ "${LSN_STATE_FILE}" ]] || LSN_STATE_FILE=".lsn-state"
1009 if [[ $1 == "--mem" ]] || [[ "$1" == "-m" ]]
1012 \ls -pa | sort > "${LSN_STATE_FILE}"
1013 echo "State updated." >&2
1015 elif [[ $1 == "+" ]]
1020 TMP=$(mktemp /tmp/lsn.XXXXXX)
1021 \ls -d "$@" > ${TMP}
1022 cat "${LSN_STATE_FILE}" >> ${TMP}
1023 sort ${TMP} | uniq -u > "${LSN_STATE_FILE}"
1029 lsn [--help|-h] [--mem|-m] [+ <file> ...]
1037 stores the current state of the directory
1039 + <file> [<file> ...]
1040 switches the presence/absence of the indicated files in the
1044 if [[ ! "$1" == "-h" ]] && [[ ! "$1" == "--help" ]]
1046 echo >&2 "Unknown option \`\`$1''."
1052 if [[ -f "${LSN_STATE_FILE}" ]]
1054 TMP=$(mktemp /tmp/lsn.XXXXXX)
1055 \ls -pa | sort > ${TMP}
1056 if diff > /dev/null ${TMP} "${LSN_STATE_FILE}"
1058 echo "${VT_GREEN_FG}${VT_BOLD}No change (since $(date +"%b %d, %Y" -r "${LSN_STATE_FILE}"))${VT_RESET}"
1060 \comm -1 -3 "${LSN_STATE_FILE}" ${TMP}
1061 \comm -2 -3 "${LSN_STATE_FILE}" ${TMP} | while read line
1063 echo "${VT_RED_FG}${VT_BOLD}${line}${VT_RESET} (missing)"
1068 echo "${VT_RED_FG}${VT_BOLD}No lsn state here.${VT_RESET}" >&2
1075 ######################################################################
1077 function prompt_command () {
1078 [[ "${CORE_CHECK_PWD}" == ${PWD} ]] || find . -maxdepth 1 -name "core__*" | awk '{print "'${VT_RED_FG}'"$0"'${VT_RESET}'"}'
1079 CORE_CHECK_PWD=${PWD}
1081 # if [[ $(umask) != 0022 ]]
1083 # echo "Umask changed to $(umask)"
1085 # save the history after every command to avoid loosing some when
1086 # multiple shells are open
1088 # load the saved history
1090 # and the local histories system defined above
1092 # and the history cue
1096 PROMPT_COMMAND="prompt_command"
1098 ######################################################################
1100 # Displaying the timezone if it is set
1102 [[ ${TZ} ]] && echo "${VT_BLUE_FG}Time zone is ${TZ}.${VT_RESET}"
1104 ######################################################################
1106 source /usr/share/bash-completion/bash_completion
1108 ######################################################################
1110 # added by Miniconda3 installer
1111 export PATH="/home/fleuret/conda/bin:$PATH"