仓库源文站点原文


layout: post title: 我的.bashrc设置 categories:


我用bash也有很多年了, 以前的时候里面的设置波动很大, 但现在慢慢收敛了, 基本不再有大的波动. 所以我就重新整理了一下, 使其更有条理, 修改/添加更方便. 做量化计算或分子模拟的, 可以作为参考.

下面就是我的设置

<table class="highlighttable"><th colspan="2" style="text-align:left">mine.bashrc</th><tr><td><div class="linenodiv" style="background-color: #f0f0f0; padding-right: 10px"><pre style="line-height:125%"> 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134</pre></div></td><td class="code"><div class="highlight"><pre style="line-height:125%"><span></span><span style="color: #008800; font-style: italic">########################################################################</span> <span style="color: #008800; font-style: italic"># 作业系统脚本/程序</span> <span style="color: #008800; font-style: italic">########################################################################</span> <span style="color: #B8860B">jobMode</span><span style="color: #666666">=</span>pbs <span style="color: #666666">[[</span> <span style="color: #BB4444">`</span>hostname<span style="color: #BB4444">`</span> <span style="color: #666666">=</span>~ ^<span style="color: #666666">[</span>pin|c<span style="color: #666666">[</span>0-9<span style="color: #666666">]]</span>* <span style="color: #666666">]]</span> <span style="color: #666666">&&</span> <span style="color: #666666">{</span> <span style="color: #B8860B">jobMode</span><span style="color: #666666">=</span>slurm; <span style="color: #666666">}</span> <span style="color: #666666">[[</span> <span style="color: #BB4444">`</span>hostname<span style="color: #BB4444">`</span> <span style="color: #666666">=</span>~ ^node<span style="color: #666666">[</span>0-9<span style="color: #666666">]]</span>* <span style="color: #666666">]]</span> <span style="color: #666666">&&</span> <span style="color: #666666">{</span> <span style="color: #B8860B">jobMode</span><span style="color: #666666">=</span>node; <span style="color: #666666">}</span> <span style="color: #666666">[[</span> <span style="color: #B8860B">$jobMode</span> <span style="color: #666666">=</span>~ node <span style="color: #666666">]]</span> <span style="color: #666666">&&</span> <span style="color: #666666">{</span> <span style="color: #AA22FF">source</span> <span style="color: #BB6622; font-weight: bold">\!\!</span>_node.bashrc; <span style="color: #666666">}</span> <span style="color: #666666">[[</span> <span style="color: #B8860B">$jobMode</span> <span style="color: #666666">=</span>~ pbs <span style="color: #666666">]]</span> <span style="color: #666666">&&</span> <span style="color: #666666">{</span> <span style="color: #AA22FF">source</span> <span style="color: #BB6622; font-weight: bold">\!\!</span>_pbs.bashrc; <span style="color: #666666">}</span> <span style="color: #666666">[[</span> <span style="color: #B8860B">$jobMode</span> <span style="color: #666666">=</span>~ slurm <span style="color: #666666">]]</span> <span style="color: #666666">&&</span> <span style="color: #666666">{</span> <span style="color: #AA22FF">source</span> <span style="color: #BB6622; font-weight: bold">\!\!</span>_slurm.bashrc; <span style="color: #666666">}</span> <span style="color: #AA22FF; font-weight: bold">if</span> <span style="color: #666666">[[</span> ! <span style="color: #B8860B">$jobMode</span> <span style="color: #666666">=</span>~ node <span style="color: #666666">]]</span>; <span style="color: #AA22FF; font-weight: bold">then</span> <span style="color: #008800; font-style: italic">########################################################################</span> <span style="color: #008800; font-style: italic"># 加载模块</span> <span style="color: #008800; font-style: italic">########################################################################</span> . /etc/profile.d/env-modules.sh <span style="color: #008800; font-style: italic"># 无此文件则注释掉</span> module load intel/18.0.2 mkl/18.0.2 impi/18.0.2 cmake/3.5.2 module list <span style="color: #008800; font-style: italic"># 使用MPI版本 goto/mkl blas设置为1, 使用混合 mpi/openmp则设其他值</span> <span style="color: #AA22FF">export</span> <span style="color: #B8860B">OMP_NUM_THREADS</span><span style="color: #666666">=1</span> <span style="color: #B8860B">MKL_NUM_THREADS</span><span style="color: #666666">=1</span> <span style="color: #B8860B">GOTO_NUM_THREADS</span><span style="color: #666666">=</span>1 <span style="color: #AA22FF; font-weight: bold">fi</span> <span style="color: #008800; font-style: italic">########################################################################</span> <span style="color: #008800; font-style: italic"># 常规设置</span> <span style="color: #008800; font-style: italic">########################################################################</span> <span style="color: #AA22FF">umask</span> 0027 <span style="color: #AA22FF">history</span> -c; <span style="color: #B8860B">HISTSIZE</span><span style="color: #666666">=</span>50 <span style="color: #AA22FF">ulimit</span> -Sv unlimited -nu <span style="color: #666666">65535</span> -c <span style="color: #666666">0</span> 2>/dev/null <span style="color: #AA22FF">export</span> <span style="color: #B8860B">HISTCONTROL</span><span style="color: #666666">=</span>ignoredups <span style="color: #BB6622; font-weight: bold">\</span> <span style="color: #B8860B">HISTCONTROL</span><span style="color: #666666">=</span>erasedups <span style="color: #BB6622; font-weight: bold">\</span> <span style="color: #B8860B">HISTIGNORE</span><span style="color: #666666">=</span><span style="color: #BB4444">"ls:pjob*:pque*:cls:cd*:exit"</span> <span style="color: #BB6622; font-weight: bold">\</span> <span style="color: #B8860B">LS_COLORS</span><span style="color: #666666">=</span><span style="color: #BB4444">'</span><span style="color: #B8860B">no</span><span style="color: #666666">=</span>00:fi<span style="color: #666666">=</span>00:di<span style="color: #666666">=</span>01;34:ln<span style="color: #666666">=</span>01;36:pi<span style="color: #666666">=</span>40;33:so<span style="color: #666666">=</span>01;35:bd<span style="color: #666666">=</span>40;33;01:cd<span style="color: #666666">=</span>40;33;01:or<span style="color: #666666">=</span>40;31;01:ex<span style="color: #666666">=</span>01;31:*.tar<span style="color: #666666">=</span>01;31:*.tgz<span style="color: #666666">=</span>01;31:*.arj<span style="color: #666666">=</span>01;31:*.taz<span style="color: #666666">=</span>01;31:*.lzh<span style="color: #666666">=</span>01;31:*.zip<span style="color: #666666">=</span>01;31:*.z<span style="color: #666666">=</span>01;31:*.Z<span style="color: #666666">=</span>01;31:*.gz<span style="color: #666666">=</span>01;31:*.bz2<span style="color: #666666">=</span>01;31:*.deb<span style="color: #666666">=</span>01;31:*.i386.rpm<span style="color: #666666">=</span>01;31:*.src.rpm<span style="color: #666666">=</span>01;30:*.jpg<span style="color: #666666">=</span>01;35:*.gif<span style="color: #666666">=</span>01;35:*.bmp<span style="color: #666666">=</span>01;35:*.ppm<span style="color: #666666">=</span>01;35:*.tga<span style="color: #666666">=</span>01;35:*.xbm<span style="color: #666666">=</span>01;35:*.xpm<span style="color: #666666">=</span>01;35:*.tif<span style="color: #666666">=</span>01;35:*.png<span style="color: #666666">=</span>01;35:<span style="color: #BB4444">'</span> <span style="color: #008800; font-style: italic">########################################################################</span> <span style="color: #008800; font-style: italic"># 彩色提示符: 当前路径 运行任务/总任务 日期时间 用户名@节点</span> <span style="color: #008800; font-style: italic">########################################################################</span> <span style="color: #B8860B">Coff</span><span style="color: #666666">=</span><span style="color: #BB4444">"\[\e[0m\]"</span>; <span style="color: #B8860B">Cblk</span><span style="color: #666666">=</span><span style="color: #BB4444">"\[\e[30m\]"</span>; <span style="color: #B8860B">Cred</span><span style="color: #666666">=</span><span style="color: #BB4444">"\[\e[31m\]"</span>; <span style="color: #B8860B">Cgrn</span><span style="color: #666666">=</span><span style="color: #BB4444">"\[\e[32m\]"</span> <span style="color: #B8860B">Cylw</span><span style="color: #666666">=</span><span style="color: #BB4444">"\[\e[33m\]"</span>; <span style="color: #B8860B">Cblu</span><span style="color: #666666">=</span><span style="color: #BB4444">"\[\e[34m\]"</span>; <span style="color: #B8860B">Cpup</span><span style="color: #666666">=</span><span style="color: #BB4444">"\[\e[35m\]"</span> <span style="color: #B8860B">Ccyn</span><span style="color: #666666">=</span><span style="color: #BB4444">"\[\e[36m\]"</span>; <span style="color: #B8860B">Cwht</span><span style="color: #666666">=</span><span style="color: #BB4444">"\[\e[37m\]"</span>; <span style="color: #B8860B">Bblk</span><span style="color: #666666">=</span><span style="color: #BB4444">"\[\e[40m\]"</span> <span style="color: #AA22FF">export</span> <span style="color: #B8860B">PS1</span><span style="color: #666666">=</span><span style="color: #BB4444">"</span><span style="color: #B8860B">$Bblk</span><span style="color: #BB4444"> </span><span style="color: #B8860B">$Cwht</span><span style="color: #BB4444"> \w </span><span style="color: #B8860B">$Cred</span><span style="color: #BB4444">\$(</span><span style="color: #B8860B">$runJob</span><span style="color: #BB4444">)/\$(</span><span style="color: #B8860B">$allJob</span><span style="color: #BB4444">) </span><span style="color: #B8860B">$Cgrn</span><span style="color: #BB4444">\$(date "</span>+%Y-%m-%d<span style="color: #BB4444">") \t</span><span style="color: #B8860B">$Cylw</span><span style="color: #BB4444"> <\u@\h>\n</span><span style="color: #B8860B">$Cred</span><span style="color: #BB4444">\$ </span><span style="color: #B8860B">$Coff</span><span style="color: #BB4444">"</span>; <span style="color: #008800; font-style: italic">########################################################################</span> <span style="color: #008800; font-style: italic"># 常用命令别名, 设置</span> <span style="color: #008800; font-style: italic">########################################################################</span> <span style="color: #AA22FF">alias</span> ~<span style="color: #666666">=</span><span style="color: #BB4444">'</span><span style="color: #AA22FF">cd</span> ~;clear<span style="color: #BB4444">'</span> <span style="color: #BB6622; font-weight: bold">\</span> -<span style="color: #666666">=</span><span style="color: #BB4444">'</span><span style="color: #AA22FF">cd</span> -;clear<span style="color: #BB4444">'</span> <span style="color: #BB6622; font-weight: bold">\</span> ..<span style="color: #666666">=</span><span style="color: #BB4444">'</span><span style="color: #AA22FF">cd</span> ..;clear<span style="color: #BB4444">'</span> <span style="color: #BB6622; font-weight: bold">\</span> <span style="color: #B8860B">rm</span><span style="color: #666666">=</span><span style="color: #BB4444">'</span>rm -i<span style="color: #BB4444">'</span> <span style="color: #BB6622; font-weight: bold">\</span> <span style="color: #B8860B">cp</span><span style="color: #666666">=</span><span style="color: #BB4444">'</span>cp -i<span style="color: #BB4444">'</span> <span style="color: #BB6622; font-weight: bold">\</span> <span style="color: #B8860B">mv</span><span style="color: #666666">=</span><span style="color: #BB4444">'</span>mv -i<span style="color: #BB4444">'</span> <span style="color: #BB6622; font-weight: bold">\</span> <span style="color: #B8860B">ll</span><span style="color: #666666">=</span><span style="color: #BB4444">'</span>ls -l<span style="color: #BB4444">'</span> <span style="color: #BB6622; font-weight: bold">\</span> <span style="color: #B8860B">la</span><span style="color: #666666">=</span><span style="color: #BB4444">'</span>ls -aF<span style="color: #BB4444">'</span> <span style="color: #BB6622; font-weight: bold">\</span> <span style="color: #B8860B">cls</span><span style="color: #666666">=</span><span style="color: #BB4444">'</span>clear; ls<span style="color: #BB4444">'</span> <span style="color: #BB6622; font-weight: bold">\</span> <span style="color: #B8860B">grep</span><span style="color: #666666">=</span><span style="color: #BB4444">'</span>grep --color<span style="color: #666666">=</span>auto<span style="color: #BB4444">'</span> <span style="color: #BB6622; font-weight: bold">\</span> <span style="color: #B8860B">ls</span><span style="color: #666666">=</span><span style="color: #BB4444">'</span>ls --color<span style="color: #666666">=</span>auto -NF --show-control-chars<span style="color: #BB4444">'</span> <span style="color: #008800; font-style: italic">########################################################################</span> <span style="color: #008800; font-style: italic"># 设置PATH(命令搜索位置), LD_LIBRARY_PATH(库文件搜索位置)</span> <span style="color: #008800; font-style: italic">########################################################################</span> <span style="color: #AA22FF">export</span> <span style="color: #B8860B">PATH</span><span style="color: #666666">=</span><span style="color: #B8860B">$PATH</span>:<span style="color: #BB6622; font-weight: bold">\</span> /share/apps/bin:<span style="color: #BB6622; font-weight: bold">\</span> ~/bin:<span style="color: #BB6622; font-weight: bold">\</span> ~/GMX4.6.7/bin <span style="color: #AA22FF">export</span> <span style="color: #B8860B">LD_LIBRARY_PATH</span><span style="color: #666666">=</span><span style="color: #B8860B">$LD_LIBRARY_PATH</span>:<span style="color: #BB6622; font-weight: bold">\</span> /usr/lib:<span style="color: #BB6622; font-weight: bold">\</span> /usr/lib64 <span style="color: #008800; font-style: italic">########################################################################</span> <span style="color: #008800; font-style: italic"># 专业程序, export用于在脚本中使用, alias用于在命令行中使用</span> <span style="color: #008800; font-style: italic">########################################################################</span> <span style="color: #008800; font-style: italic"># VMD</span> <span style="color: #AA22FF">export</span> <span style="color: #B8860B">DISPLAY</span><span style="color: #666666">=</span>localhost:0.0 <span style="color: #BB6622; font-weight: bold">\</span> <span style="color: #B8860B">LIBGL_ALWAYS_INDIRECT</span><span style="color: #666666">=</span>yes <span style="color: #BB6622; font-weight: bold">\</span> <span style="color: #B8860B">vmd</span><span style="color: #666666">=</span>~/VMD1.9.1/VMD1.9.1 <span style="color: #AA22FF">alias</span> <span style="color: #B8860B">vmd</span><span style="color: #666666">=</span><span style="color: #B8860B">$vmd</span> <span style="color: #008800; font-style: italic"># GROMACS</span> <span style="color: #AA22FF">export</span> <span style="color: #B8860B">GMXLIB</span><span style="color: #666666">=</span>~/GMX4.6.7/share/gromacs/top:/storage/<span style="color: #B8860B">$USER</span>/scratch/!GMXLIB <span style="color: #BB6622; font-weight: bold">\</span> <span style="color: #B8860B">gmx</span><span style="color: #666666">=</span><span style="color: #BB4444">'</span>bash /home/jicun/!GMX<span style="color: #BB4444">'</span> <span style="color: #BB6622; font-weight: bold">\</span> <span style="color: #B8860B">gmx18</span><span style="color: #666666">=</span>~/GMX4.6.7/2018/bin/gmx_mpi_d <span style="color: #AA22FF">alias</span> <span style="color: #B8860B">gmx</span><span style="color: #666666">=</span><span style="color: #B8860B">$gmx</span> <span style="color: #BB6622; font-weight: bold">\</span> <span style="color: #B8860B">gmx18</span><span style="color: #666666">=</span><span style="color: #B8860B">$gmx18</span> <span style="color: #BB6622; font-weight: bold">\</span> <span style="color: #008800; font-style: italic"># Gaussian</span> <span style="color: #AA22FF">export</span> <span style="color: #B8860B">GAUROOT</span><span style="color: #666666">=</span>~/g16 <span style="color: #008800; font-style: italic"># 使用版本路径</span> <span style="color: #AA22FF">export</span> <span style="color: #B8860B">g16</span><span style="color: #666666">=</span><span style="color: #B8860B">$GAUROOT</span>/g16 <span style="color: #BB6622; font-weight: bold">\</span> <span style="color: #B8860B">GAUSS_EXEDIR</span><span style="color: #666666">=</span><span style="color: #B8860B">$GAUROOT</span> <span style="color: #BB6622; font-weight: bold">\</span> <span style="color: #B8860B">GAUSS_SCRDIR</span><span style="color: #666666">=</span>~/_tmp <span style="color: #BB6622; font-weight: bold">\</span> <span style="color: #B8860B">PATH</span><span style="color: #666666">=</span><span style="color: #B8860B">$PATH</span>:<span style="color: #B8860B">$GAUROOT</span> <span style="color: #BB6622; font-weight: bold">\</span> <span style="color: #B8860B">LD_LIBRARY_PATH</span><span style="color: #666666">=</span><span style="color: #B8860B">$LD_LIBRARY_PATH</span>:<span style="color: #B8860B">$GAUROOT</span> <span style="color: #AA22FF">alias</span> <span style="color: #B8860B">g16</span><span style="color: #666666">=</span><span style="color: #B8860B">$g16</span> <span style="color: #008800; font-style: italic"># MOLPRO</span> <span style="color: #AA22FF">export</span> <span style="color: #B8860B">molpro</span><span style="color: #666666">=</span>~/molpro/bin/molpro <span style="color: #AA22FF">alias</span> <span style="color: #B8860B">molpro</span><span style="color: #666666">=</span><span style="color: #B8860B">$molpro</span> <span style="color: #008800; font-style: italic"># GAMESS</span> <span style="color: #AA22FF">export</span> <span style="color: #B8860B">gms</span><span style="color: #666666">=</span>~/gamess/_bin/rungms <span style="color: #AA22FF">alias</span> <span style="color: #B8860B">gms</span><span style="color: #666666">=</span><span style="color: #B8860B">$gms</span> <span style="color: #008800; font-style: italic"># MOPAC, PQS</span> <span style="color: #AA22FF">export</span> <span style="color: #B8860B">MOPAC_LICENSE</span><span style="color: #666666">=</span>~/bin/mopac <span style="color: #BB6622; font-weight: bold">\</span> <span style="color: #B8860B">PQS_ROOT</span><span style="color: #666666">=</span>~/PQS <span style="color: #BB6622; font-weight: bold">\</span> <span style="color: #B8860B">PQS_BASDIR</span><span style="color: #666666">=</span>~/PQS/BASDIR <span style="color: #BB6622; font-weight: bold">\</span> <span style="color: #B8860B">PQS_SCRDIR</span><span style="color: #666666">=</span>/storage/<span style="color: #B8860B">$USER</span>/scratch/_tmp <span style="color: #008800; font-style: italic">########################################################################</span> <span style="color: #008800; font-style: italic"># 用户脚本/程序</span> <span style="color: #008800; font-style: italic">########################################################################</span> <span style="color: #AA22FF">export</span> <span style="color: #B8860B">pardo</span><span style="color: #666666">=</span>~/bin/parallel <span style="color: #BB6622; font-weight: bold">\</span> <span style="color: #B8860B">capmol</span><span style="color: #666666">=</span><span style="color: #BB4444">'</span>bash /home/jicun/capmol<span style="color: #BB4444">'</span> <span style="color: #BB6622; font-weight: bold">\</span> <span style="color: #B8860B">setqm</span><span style="color: #666666">=</span><span style="color: #BB4444">'</span>bash /home/jicun/setQMMM<span style="color: #BB4444">'</span> <span style="color: #BB6622; font-weight: bold">\</span> <span style="color: #B8860B">gro2qm</span><span style="color: #666666">=</span><span style="color: #BB4444">'</span>bash /home/jicun/gro2QM<span style="color: #BB4444">'</span> <span style="color: #AA22FF">alias</span> <span style="color: #B8860B">pardo</span><span style="color: #666666">=</span><span style="color: #B8860B">$pardo</span> <span style="color: #BB6622; font-weight: bold">\</span> <span style="color: #B8860B">capmol</span><span style="color: #666666">=</span><span style="color: #B8860B">$capmol</span> <span style="color: #BB6622; font-weight: bold">\</span> <span style="color: #B8860B">setqm</span><span style="color: #666666">=</span><span style="color: #B8860B">$setqm</span> <span style="color: #BB6622; font-weight: bold">\</span> <span style="color: #B8860B">gro2qm</span><span style="color: #666666">=</span><span style="color: #B8860B">$gro2qm</span> <span style="color: #BB6622; font-weight: bold">\</span> <span style="color: #B8860B">sapt</span><span style="color: #666666">=</span><span style="color: #BB4444">'</span>~/!SAPT<span style="color: #BB4444">'</span> <span style="color: #BB6622; font-weight: bold">\</span> <span style="color: #B8860B">mrun</span><span style="color: #666666">=</span><span style="color: #BB4444">"matlab -r"</span> <span style="color: #BB6622; font-weight: bold">\</span> <span style="color: #B8860B">trun</span><span style="color: #666666">=</span><span style="color: #BB4444">'</span>~/!Trun<span style="color: #BB4444">'</span> <span style="color: #BB6622; font-weight: bold">\</span> <span style="color: #B8860B">getref</span><span style="color: #666666">=</span><span style="color: #BB4444">'</span>bash /home/jicun/getRef<span style="color: #BB4444">'</span> <span style="color: #BB6622; font-weight: bold">\</span> <span style="color: #B8860B">sx</span><span style="color: #666666">=</span><span style="color: #BB4444">'</span>bash /home/jicun/sx.bsh<span style="color: #BB4444">'</span> <span style="color: #BB6622; font-weight: bold">\</span> <span style="color: #B8860B">scr</span><span style="color: #666666">=</span><span style="color: #BB4444">"cd /storage/</span><span style="color: #B8860B">$USER</span><span style="color: #BB4444">/scratch;clear"</span> <span style="color: #BB6622; font-weight: bold">\</span> <span style="color: #B8860B">lscr</span><span style="color: #666666">=</span><span style="color: #BB4444">"cd /local_scratch/</span><span style="color: #B8860B">$USER</span><span style="color: #BB4444">;clear"</span> <span style="color: #BB6622; font-weight: bold">\</span> <span style="color: #B8860B">icc</span><span style="color: #666666">=</span><span style="color: #BB4444">'</span>~/!IFC c<span style="color: #BB4444">'</span> <span style="color: #BB6622; font-weight: bold">\</span> <span style="color: #B8860B">ifc</span><span style="color: #666666">=</span><span style="color: #BB4444">'</span>~/!IFC f<span style="color: #BB4444">'</span> <span style="color: #BB6622; font-weight: bold">\</span> <span style="color: #B8860B">vsp_ikp</span><span style="color: #666666">=</span><span style="color: #BB4444">'</span>~/!VSP ikp<span style="color: #BB4444">'</span> <span style="color: #BB6622; font-weight: bold">\</span> <span style="color: #B8860B">vsp_run</span><span style="color: #666666">=</span><span style="color: #BB4444">'</span>~/!VSP run<span style="color: #BB4444">'</span> <span style="color: #BB6622; font-weight: bold">\</span> <span style="color: #B8860B">vsp_d3</span><span style="color: #666666">=</span><span style="color: #BB4444">'</span>~/!VSP d3<span style="color: #BB4444">'</span></pre></div> </td></tr></table>

命令行使用了彩色提示符, 显示了

当前路径 运行任务数/总任务数 日期时间 <用户名@节点>

效果如下

网络资源