.profile是login用户登录后读取的文件,会读取.bashrc文件,可不管.
.bashrc是非login用户读取的文件,例如在命令行输入bash也会读取该文件,主要的个人设置可放在这里
本人的.bashrc目前只增加了PS1设置和相应增加的环境变量设置:
# Set PS1
export PS1="\[\e[33;1m\]\u@\h \[\e[35;1m\]\t \[\e[36;1m\]\w\[\e[0m\]\n\[\e[32;1m\]$ \[\e[0m\]"
# User specific environment and startup programs
export LD_LIBRARY_PATH=/usr/local/lib:/usr/lib:$LD_LIBRARY_PATH
export PATH=/usr/local/bin:/usr/bin:$PATH
export JAVA_HOME=/usr/lib/jvm/java
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
export MANPATH=/usr/local/texlive/2014/texmf-dist/doc/man:$MANPATH
export INFOPATH=/usr/local/texlive/2014/texmf-dist/doc/info:$INFOPATH
export PATH=/usr/local/texlive/2014/bin/x86_64-linux:$PATH
一些软件的命令等的简写全放在.bash_aliases中:
# config
alias reload='source ~/.bashrc'
alias bashrc='vim ~/.bashrc && source ~/.bashrc'
alias bashpr='vim ~/.bash_profile && source ~/.profile'
alias bashal='vim ~/.bash_aliases && source ~/.bash_aliases'
# login
alias 184='cds && ssh $USER@192.168.8.184'
alias 242='cds && ssh $USER@192.168.8.242'
alias 241='cds && ssh $USER@192.168.8.241'
alias gg='exit'
# workspace
alias ws='cd ~/workspace'
alias bws='cd ~/backup/workspace'
alias wstest='cd ~/workspace/test'
# chdir
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias cd..='cd ..'
alias -- -='cd -'
alias cds='echo "`pwd`" > ~/.cdsave'
alias cdb='cd "`cat ~/.cdsave`"'
mcd() { mkdir -pv $@ && cd $@; }
cd2() { tmp=$(dirname $1); [ -d $1 ] && tmp=$1; cd $tmp && ls -l; }
# task
alias q1='qsub -cwd -q st.q -P st_ms -l vf=1G'
alias q4='qsub -cwd -q st.q -P st_ms -l vf=4G'
alias q8='qsub -cwd -q st.q -P st_ms -l vf=8G'
alias q16='qsub -cwd -q st.q -P st_ms -l vf=16G'
alias qsm='qsub -cwd -q st_supermem.q -P st_supermem -l vf=64G'
alias qs='qstat -u $USER'
alias qh='qhost -u $USER'
alias qt='top -u $USER'
alias task='perl ~/bin/task/task.pl'
alias qdelall='qdel -u $USER'
alias qsuball='perl ~/bin/task/qsub_all.pl'
alias qgc='qstat -g c'
alias psg='ps aux|grep'
alias pgrep='pgrep -u $USER'
# su
alias sin='sudo aptitude install'
alias srm='sudo rm -rf'
# disk
alias df='df -h'
alias du='du -h'
alias dus='du -sh'
alias dul='du -Lh'
alias du0='du --max-depth=0'
alias du1='du --max-depth=1'
# file
alias dir='ls -l'
alias vdir='vdir --color=auto'
alias fn='ls -l |grep "^-"|wc -l'
alias dn='ls -l |grep "^d"|wc -l'
alias fnt='ls -lR|grep "^-"|wc -l'
alias wc='wc -l'
alias row='wc -l'
alias col='awk -F "\t" "{print NF}"'
alias le='less -SN'
alias ls='ls --color=auto'
alias l='ls -CF'
alias la='ls -A'
alias ll='ls -alF'
alias lx='ls -lhBX'
alias lz='ls -lhrS'
alias lt='ls -lhrt'
alias vd='vimdiff'
alias vi='vim'
alias cp='cp -vr'
alias mv='mv -v'
alias rm='rm -rf'
alias chmod='chmod -v --preserve-root'
alias chown='chown -v --preserve-root'
alias grep='grep -rn --color=auto'
alias egrep='egrep -rn --color=auto'
alias fgrep='fgrep -rn --color=auto'
alias mkdir='mkdir -pv'
alias ln='ln -s'
alias delcol1='awk "{\$1=\"\";print \$0}"'
alias delrow1='sed "1d"' # add -i can replace the file
alias row1='sed -n "1,1p"'
alias row2='sed -n "2,1p"'
alias g2u='iconv -f gbk -t utf-8'
alias u2g='iconv -f utf-8 -t gbk'
alias fd='find -type d -name'
alias ff='find -type f -name'
alias chx='chmod +x'
alias tf='tail -f'
alias sv='sudo vim'
alias number='ls | wc -l'
mvtmp() { mv $1 /tmp/; }
cptmp() { cp -r $@ /tmp/; }
switch() { mv $1 ${1}.tmp && mv $2 $1 && mv ${1}.tmp $2; }
del() { mv $@ ~/.local/share/Trash/files; }
vimmul() { vim -o$# $*; }
targz() { tar czvf ${1%%/}.tar.gz ${1%%/}/; }
bd() { find . -type f -size +500000000c| awk '{print "ls -latF --time-style=long-iso "$0}' | sh; }
bd3() { find . -type f -ctime -3 -size +500000000c| awk '{print "ls -latF --time-style=long-iso "$0}' | sh; }
alias decompress='sh ~/bin/file/decompress.sh'
alias fix='sh ~/bin/file/fix.sh'
# others
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
alias which='alias | which --tty-only --read-alias --show-dot --show-tilde'
alias sys='lsb_release -a'
calc() { echo $* | bc; }
# web
alias lftp='lftp user:pwd@ftpip'
alias ping='ping -c 5'
# R
alias R='R --no-save --quiet'
alias Rs='Rscript'
# sql
alias mysql='mysql -u root'
# eclipse
alias eclipse='/opt/eclipse/eclipse'
其中一些稍微复杂的命令放在~/bin下:
task目录下task.pl文件查看当前任务状态:
#!/usr/bin/perl -w
use strict;
my $name=`whoami`;
if($ARGV[0]){$name=$ARGV[0]}
chomp $name;
my %hash=();
#print "$name";
my @task=`qstat -u $name`;
chomp @task;
my ($taskid,$taskname,$taskstate);
#my $msg=();
#my $open="no";
print "ID\tName \tstate\tapply\tuse\tmax\n--------------------------------------------------------\n";
foreach my $task(@task){
if($task=~/ja-task-ID/){next;}
if($task=~/----------/){next;}
$task=~s/^\s+//;
($taskid,$taskname,$taskstate)=(split /\s+/,$task)[0,2,4];
my @mem=`qstat -j $taskid`;
my $needmem=0;
my $usemem=0;
my $maxmem=0;
foreach my $mem(@mem){
if($mem=~/virtual_free=(\w+.?\w*)$/){$needmem=$1}
if($mem=~/vmem=(\w+.\w+)/){$usemem=$1}
if($mem=~/maxvmem=(\w+.\w+)/){$maxmem=$1}
}
print "$taskid\t$taskname \t$taskstate\t$needmem\t$usemem\t$maxmem\n";
}
task目录下qsub_all.pl文件详见:
http://my.oschina.net/u/1791586/blog/287156
file目录下fix.sh:
# function: fix files or dirs permissions
if [ -d $1 ]; then
find $1 -type d -exec chmod 755 {} \;
find $1 -type f -exec chmod 644 {} \;
else
echo "$1 is not a directory."
fi
file目录下decompress.sh:
# function: decompress file
if [ -f $1 ]; then
case $1 in
*.rar) unrar x $1 ;; # rar a filename.rar dirname
*.zip) unzip $1 ;; # zip -r filename.zip dirname
*.7z) 7z x $1 ;; # 7z -t7z dirname
*.tar) tar xvf $1 ;; # tar cvf filename.tar dirname
*.tar.bz2) tar xjvf $1 ;; # tar cjvf filename.tar.bz2 dirname
*.tbz2) tar xjvf $1 ;; # tar cjvf filename.tbz2 dirname
*.bz2) bunzip2 $1 ;; # bzip2 -z filename
*.tgz) tar xzvf $1 ;; # tar czvf filename.tgz dirname
*.tar.gz) tar xzvf $1 ;; # tar czvf filename.tar.gz dirname
*.gz) gunzip $1 ;; # gzip filename
*.tar.Z) tar xZvf $1 ;; # tar cZvf filename.tar.Z dirname
*.Z) uncompress $1 ;; # compress filename
*.tar.xz) tar xJvf $1 ;; # tar cJvf filename.tar.xz dirname
*.xz) xz -d $1 ;; # xz filename
*) echo "'$1' cannot be extracted via decompress()" ;;
esac
else
echo "'$1' is not a valid file"
fi