useful alias

来源:互联网 发布:剪歌软件 编辑:程序博客网 时间:2024/04/27 15:30


alias ..="cd .."  
alias cdd="cd .."  
alias cd..="cd .."  
alias cde="cd ../.."  
alias ....="cd ../../.."  
alias .....="cd ../../../.."  
alias cd-='cd -'  
alias cdu='cd /mnt/hgfs/ushare'  
alias cds='echo "`pwd`" > ~/.cdsave'  #cd save previous dir
alias cdb='cd "`cat ~/.cdsave`"'  # cd back to previous dir 


alias ls='ls --color=auto'  
alias l.='ls -d .* --color=auto' # Show hidden files 
alias ll='ls -al --color=tty'   #ls,--color  
alias lx='ls -lhBX --color=auto'        #sort by extension  
alias lz='ls -lhrS --color=auto'        #sort by size  
alias lt='ls -lhrt --color=auto'        #sort by date      
alias lsd='find . -maxdepth 1 -type d | sort'   #list all dir  




alias grep="grep -rnE --color"    #r recursive; n: num; E:extern patern  --color highlight
alias mkdir="mkdir -pv"  
alias cp='cp -v'  
alias cpr='cp -r'  
alias mv='mv -v'  
alias chmod='chmod -v --preserve-root'  
alias chown='chown -v --preserve-root'  # not permit do it on root dir
alias last="last -a"  
alias free='free -m'  # mem usage
alias lftp="lftp user:pwd@ftpip"  
alias dfind='find -type d -name'  #  
alias ffind='find -type f -name'  # 


alias dus="du -s"   #  
alias du0="du --max-depth=0"  
alias du1="du -ah --max-depth=1"  
alias df="df -h"  
 

alias ushare='sudo mount -t vboxsf ushare ~/ushare'

alias vimi='sudo vim +PluginInstall +qall'


### gvim
#function gvim () { (/usr/bin/gvim -f "$@" &) }  
alias g='gvim -f'  
alias sv="sudo vim"  
alias gd='gvim -d'  # diff tow file
alias gp='gvim -p'  # tab files
alias vimi='sudo vim +PluginInstall +qall'

alias sc='source ~/.bashrc'  
alias gc='gvim ~/.bashrc'  
alias gba='gvim ~/.bash_aliases'  


############
alias gu='iconv -f gbk -t utf-8'  #format gbk to utf-8  
alias ug='iconv -f utf-8 -t gbk'  




alias af="awk -F '\t' '{print NF}'"   #num of collums \t delema,  
alias wl='wc -l'    #how many lines  
alias hpwd='echo -n "`hostname`:";eval pwd'  #hostname + pwd  
  
  
alias path='echo -e ${PATH//:/\\n}'  


alias pong='ping -c 5 '   ## Stop after sending count ECHO_REQUEST packets #


alias chux='chmod u+x'    #  
alias psg='ps aux|grep'   #  


alias agi='sudo apt-get install'  
alias agr='sudo apt-get remove'  
alias agu='sudo apt-get update'  
alias acs='apt-cache search'  


###
function hello() { echo " test :Hello world! $1" ; }


extract(){  
if [ -z "$1" ]; then  
    # display usage if no parameters given
    echo "Usage: extract <path/file_name>.<zip|rar|bz2|gz|tar|tbz2|tgz|Z|7z|xz|ex|tar.bz2|tar.gz|tar.xz>"  
    echo "       extract <path/file_name_1.ext> [path/file_name_2.ext] [path/file_name_3.ext]"  
    return 1  
fi  


if [ -f $1 ]; then  
    case $1 in  
        *.tar.bz2)   tar xjf $1        ;;  
        *.tar.gz)    tar xzf $1     ;;  
        *.bz2)       bunzip2 $1       ;;  
        *.rar)       unrar e $1     ;;  
        *.gz)        gunzip $1     ;;  
        *.tar)       tar xf $1        ;;  
        *.tbz2)      tar xjvf $1      ;;  
        *.tgz)       tar xzvf $1       ;;  
        *.zip)       unzip $1     ;;  
        *.Z)         uncompress $1  ;;  
        *.7z)        7z x $1    ;;  
        *)           echo "'$1' cannot be extracted via extract()" ;;  
    esac  
else  
    echo "'$1' is not a valid file"  
fi  
}  




mktar(){ tar cvf  "${1%%/}.tar"     "${1%%/}/"; }  
mktgz(){ tar cvzf "${1%%/}.tar.gz"  "${1%%/}/"; }  
mktbz(){ tar cvjf "${1%%/}.tar.bz2" "${1%%/}/"; }  


# make dir & cd to
mkcd(){ 
    echo "mcd call"   
    mkdir -pv "$@"  
    cd "$@"  
}  




# save a file to ~/tmp  
saveit() {  
    cp $1 ${HOME}/tmp/${1}.saved  
}  
# switch two files 
switchfile() {  
  mv $1 ${1}.tmp && mv $2 $1 && mv ${1}.tmp $2  
}
原创粉丝点击