set -e
set -o pipefail
-ARXIV_BIBFILE="${HOME}/tex/teaching/dlc/dlc.bib"
+[[ "${ARXIV_BIBFILE}" ]] || (echo >&2 "Define \$ARXIV_BIBFILE"; exit 2)
+[[ "${ARXIV_BIBDIR}" ]] || (echo >&2 "Define \$ARXIV_BIBDIR"; exit 2)
tmp=$(mktemp /tmp/arxiv-bib.sh.XXXXXX)
id="$(basename ${filename} .pdf)"
fi
+ while [[ -f "$1.part" ]] # dealing with firefox's download
+ do
+ echo "Waiting for $1.part to vanish"
+ sleep 1
+ done
+
echo -n "Fetching info from arxiv.org ... "
curl -s > "${tmp}" "https://arxiv.org/abs/${id}"
TITLE="$(echo "${AUTHORS} - ${TITLE} ${YEAR} ${id}.pdf" | sed -e 's/ /_/g')"
- mv -v "${filename}" "${TITLE}"
+ mv -v "${filename}" "${ARXIV_BIBDIR}/${TITLE}"
######################################################################
[[ "${MANPATH}" ]] || MANPATH=$(manpath)
+export EDITOR='emacs -nw'
+export GIT_EDITOR=${EDITOR}
+
# If the private bashrc exists, execute it
[[ -f "${PRIVATE_BASHRC}" ]] && source "${PRIVATE_BASHRC}"
export HISTTIMEFORMAT=""
shopt -s histappend
+shopt -s autocd
# I realized that most of my settings are meaningful only in
# interactive mode. This should maybe be done more properly through
# using different .bash_profile and .bash_login
+######################################################################
+
+# added by Miniconda3 installer
+export PATH="/home/fleuret/conda/bin:$PATH"
+
[ ${TERM} == "dumb" ] || [[ ! -t 0 ]] && return
# Remove the annoying beeps in console
alias p='feh --force-aliasing -d --full-screen --auto-zoom'
alias gp=gnuplot
+function ext () {
+ find . -maxdepth 1 -type f | \grep \. | sed -e 's/^.*\.\([^/.]*\)$/\1/'
+}
+
+function obs () {
+ dir=${HOME}/misc/use-by-$(date --date='+3 months' +%Y-%b-%d)
+ mkdir -p "${dir}"
+ pushd "${dir}"
+}
+
function nh () {
export HISTFILE=/dev/null
unalias cd
alias l='ls -p -I "*~" -I "*.o"'
fi
-export EDITOR=emacsclient
-export GIT_EDITOR=${EDITOR}
-
######################################################################
# Ignored extensions when completing
# A password generator
function genpw () {
- PW=$(tr -dc A-Za-z0-9 < /dev/urandom | head -c16)
+ if [[ "$1" == "-e" ]]
+ then
+ PW=$(tr -dc A-Z0-9 < /dev/urandom | head -c6)
+ shift
+ else
+ PW=$(tr -dc A-Za-z0-9 < /dev/urandom | head -c16)
+ fi
if [[ ! "$1" == "-s" ]]
then
echo "$(date) ${PW}" >> ${HOME}/private/genpw.log
then
name=$2
else
- name="capture-$(date +%s).png"
+ name="capture-$(date +%Y%m%d-%H%M%S).png"
fi
if [[ "$1" ]]
alias a='cd /tmp/at'
function trash () {
- TRASH=$(date +/tmp/trash-${USER}-%Y-%b-%d-%Hh)
- LINK=/tmp/trash
-
- mkdir -p ${TRASH}
- [[ -h ${LINK} ]] && \rm ${LINK}
+ [[ "${TRASH_ROOT}" ]] || TRASH_ROOT="${HOME}/.trash"
- [[ ! -f ${LINK} ]] && ln -s ${TRASH} ${LINK}
+ if [[ "$1" == "--" ]]
+ then
+ shift
+ elif [[ "$1" == "-t" ]]
+ then
+ shift
+ TRASH_DIR="${TRASH_ROOT}"
+ mkdir -p "${TRASH_DIR}"
+ else
+ TRASH_DIR=$(date +/tmp/trash-${USER}-%Y-%b-%d-%Hh)
+ LINK=/tmp/trash
+ mkdir -p ${TRASH_DIR}
+ [[ -h ${LINK} ]] && \rm ${LINK}
+ [[ ! -f ${LINK} ]] && ln -s ${TRASH_DIR} ${LINK}
+ fi
- mv "$@" ${TRASH}
+ mv "$@" "${TRASH_DIR}"
echo "Trashed $@"
}
######################################################################
source /usr/share/bash-completion/bash_completion
-
-######################################################################
-
-# added by Miniconda3 installer
-export PATH="/home/fleuret/conda/bin:$PATH"
clean
1. umounts all the volumes using a /dev/dm-* device
- 2. LUKS-close all the volumes appearing in /dev/mapper
+ 2. luks-close all the volumes appearing in /dev/mapper
3. Delete all the loop devices
sync
- Mounts both files as LUKS volumes, runs a dry-run rsync, and asks for
- interactive confirmation before synchronizing.
+ Mounts both files as luks volumes, runs a dry-run rsync, and asks for
+ interactive confirmation, then rsync.
fsck
- LUKS-open the provided file and run fsck on it.
+ luks-open the provided file and run fsck on it.
mount|umount
Automagically figures out from /etc/fstab what is the /dev/mapper/
- device associated to the dir, and both LUKS-opens/mounts or
- umounts/LUKS-closes it.
+ device associated to the dir, and both luks-opens/mounts or
+ umounts/luks-closes it.
EOF
}
clean)
- # mount | grep ^'/dev/dm-[0-9]*' | sed -e 's/^.* on \([^ ]*\) .*$/\1/' | \
-
- mount | grep ^'/dev/mapper' | sed -e 's/^.* on \([^ ]*\) .*$/\1/' | \
- while read line
- do
- echo "umount ${line}"
- umount ${line}
- done
-
- ls /dev/mapper | grep -v ^control$ | \
- while read line
- do
- echo "cryptsetup luksClose ${line[0]}"
- cryptsetup luksClose "${line[0]}"
- done
-
- losetup -a | sed -e "s/:.*$//" | \
- while read line
- do
- echo "losetup -d ${line}"
- losetup -d ${line}
- done
+ mount | grep ^'/dev/mapper' | sed -e 's/^.* on \([^ ]*\) .*$/\1/' | while read line
+ do
+ echo "umount ${line}"
+ umount "${line}"
+ done
+
+ find /dev/mapper -type l | while read line
+ do
+ echo "cryptsetup luksClose ${line}"
+ cryptsetup luksClose "${line}"
+ done
+
+ losetup -a | sed -e "s/:.*$//" | while read line
+ do
+ echo "losetup -d ${line}"
+ losetup -d "${line}"
+ done
exit 0
else
- echo "\`${device}' does not look like a LUKS one"
+ echo "\`${device}' does not look like a luks one"
fi