1
0
Fork 0
mirror of https://github.com/hcartiaux/dotfiles.git synced 2024-10-18 09:15:24 +02:00
dotfiles/bash/bash_oar
2018-02-25 13:02:51 +01:00

40 lines
1.2 KiB
Bash

#
# ~/.bash_oar
#
# ----------------------------------------------------------------------
# OAR Batch scheduler
# ----------------------------------------------------------------------
# Resources:
# - http://wiki-oar.imag.fr/index.php/Customization_tips
# - http://wiki-oar.imag.fr/index.php/Oarsh_and_bash_completion
if [[ $SHELL == "/bin/bash" ]]; then
# oarsh completion
function _oarsh_complete_() {
local word=${COMP_WORDS[COMP_CWORD]}
local list
list=$(uniq "$OAR_NODEFILE" | tr '\n' ' ')
COMPREPLY=($(compgen -W "$list" -- "${word}"))
}
complete -F _oarsh_complete_ oarsh
fi
# Job + Remaining time
__oar_ps1_remaining_time() {
if [ -n "$OAR_JOB_WALLTIME_SECONDS" -a -n "$OAR_NODE_FILE" -a -r "$OAR_NODE_FILE" ]; then
DATE_NOW=$(date +%s)
DATE_JOB_START=$(stat -c %Y "$OAR_NODE_FILE")
DATE_TMP=$OAR_JOB_WALLTIME_SECONDS
((DATE_TMP = (DATE_TMP - DATE_NOW + DATE_JOB_START) / 60))
echo -n "[OAR$OAR_JOB_ID->$DATE_TMP]"
fi
}
# OAR motd
test -n "$INTERACTIVE" && test -n "$OAR_NODE_FILE" && (
echo "[OAR] OAR_JOB_ID=$OAR_JOB_ID"
echo "[OAR] Your nodes are:"
sort "$OAR_NODE_FILE" | uniq -c | awk '{printf(" %s*%d\n",$2,$1)}END{printf("\n")}' | sed -e 's/,$//'
) || true