Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
wiki:old:customization_tips [2013/07/29 16:23] – [PROMPT BASH for Interactive jobs] neyronwiki:old:customization_tips [2014/08/29 16:48] – [oarsh completion] neyron
Line 1201: Line 1201:
 ====== Users tips ====== ====== Users tips ======
 ===== oarsh completion ===== ===== oarsh completion =====
-//This tip is from Jerome Reybert.//+//Tip based on an idea from Jerome Reybert//
  
-"I wanted a simple way to access another nodes from the main node of my OAR reservation (ie. to check if library is present on another nodeor to top a process...). Every time I needed this, I had to +In order to complete nodes names in oarsh command, add these lines in your .bashrc
-<code bash> +
- $ cat $OAR_NODEFILE +
- $ oarsh "one of the nodes" +
-</code> +
- +
-bash_completion is a better solution. bash_completion seems to be widely available on g5k nodes. You just have to add these lines in your .bashrc, and then try oarsh <TAB>+
  
 <code bash> <code bash>
- function _oarsh_complete_() +function _oarsh_complete_() { 
- +  if [ -n "$OAR_NODEFILE" -a "$COMP_CWORD" -eq 1 ]; then 
-   local word=${comp_words[comp_cword]} +    local word=${comp_words[comp_cword]} 
-   local list=`cat $OAR_NODEFILE | uniq | tr '\' ' '` +    local list=$(cat $OAR_NODEFILE | uniq | tr '\n' ' ') 
-   COMPREPLY=($(compgen -W "$list" -- "${word}")) +    COMPREPLY=($(compgen -W "$list" -- "${word}")) 
- } +  fi 
- complete -F _oarsh_complete_ oarsh+
 +complete -o default -F _oarsh_complete_ oarsh
 </code> </code>
  
 +Then try oarsh <TAB>
 ===== PROMPT BASH for Interactive jobs ===== ===== PROMPT BASH for Interactive jobs =====
 If you want to have a bash prompt with your job id and the remaining walltime then you can add in your ~/.bashrc: If you want to have a bash prompt with your job id and the remaining walltime then you can add in your ~/.bashrc:
  
 <code bash> <code bash>
-  if ["$PS1" ]; then +if [ "$PS1" ]; then 
-      __oar_ps1_remaining_time(){ +    __oar_ps1_remaining_time(){ 
-          if [-n "$OAR_JOB_WALLTIME_SECONDS" -a -n "$OAR_NODE_FILE" -a -r "$OAR_NODE_FILE" ]; then +        if [ -n "$OAR_JOB_WALLTIME_SECONDS" -a -n "$OAR_NODE_FILE" -a -r "$OAR_NODE_FILE" ]; then 
-              DATE_NOW=$(date +%s) +            DATE_NOW=$(date +%s) 
-              DATE_JOB_START=$(stat -c %Y $OAR_NODE_FILE) +            DATE_JOB_START=$(stat -c %Y $OAR_NODE_FILE) 
-              DATE_TMP=$OAR_JOB_WALLTIME_SECONDS +            DATE_TMP=$OAR_JOB_WALLTIME_SECONDS 
-              ((DATE_TMP = (DATE_TMP - DATE_NOW + DATE_JOB_START) / 60)) +            ((DATE_TMP = (DATE_TMP - DATE_NOW + DATE_JOB_START) / 60)) 
-              echo -n "$DATE_TMP" +            echo -n "$DATE_TMP" 
-          fi +        fi 
-      +    
-      PS1='[\\u@\\h|\\W]$([-n "$OAR_NODE_FILE" ] && echo -n "(\\[\\e[1;32m\\]$OAR_JOB_ID\\[\\e[0m\\]-->\\[\\e[1;34m\\]$(__oar_ps1_remaining_time)mn\\[\\e[0m\\])")\\$ ' +    PS1='[\u@\h|\W]$([ -n "$OAR_NODE_FILE" ] && echo -n "(\[\e[1;32m\]$OAR_JOB_ID\[\e[0m\]-->\[\e[1;34m\]$(__oar_ps1_remaining_time)mn\[\e[0m\])")\$ ' 
-      if [-n "$OAR_NODE_FILE" ] +    if [ -n "$OAR_NODE_FILE" ]then 
-      then +        echo "[OAR] OAR_JOB_ID=$OAR_JOB_ID" 
-          echo "[OAR] OAR_JOB_ID=$OAR_JOB_ID" +        echo "[OAR] Your nodes are:" 
-          echo "[OAR] Your nodes are:" +        sort $OAR_NODE_FILE | uniq -c | awk '{printf("      %s*%d", $2, $1)}END{printf("\n")}' | sed -e 's/,$//' 
-          sort $OAR_NODE_FILE | uniq -c | awk '{printf("      %s*%d+    fi 
-",$2,$1)}END{printf("\ +fi
-")}' | sed -e 's/,$//' +
-      fi +
-  fi+
 </code> </code>
  
wiki/customization_tips.txt · Last modified: 2020/03/25 15:24 by neyron
Recent changes RSS feed GNU Free Documentation License 1.3 Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki