aoeu.sh 让你 type less, do more

Github: https://github.com/shenjia/aoeu.sh

这是一个为 Linux / MacOS 用户设计的alias集合。

 作为开发人员,我们每天都要在终端敲很多重复性的命令。一些大段重复的命令(比如部署,安装,备份等)我们会写shell脚本来避免重复性的键入,却忽视了还有很多使用频率极高的命令。

有的命令很短,比如 vim 和 cd .. ,但是我们每天都要敲无数次。而有的并不短,比如 apt-cache search 或 ps aux | grep 。

也许你认为这些命令已经很短了,但是时间紧急的时候(比如在生产服务器上解bug),少敲几个字符真的很顶事。

为这些最常用的命令设置1~2个字符的alias别名,能节省我们很多时间,也能降低我们手指的疲劳度。

Dealing with directories
alias i=’cd’ # go in
alias o=’cd ..’ # go out
alias oo=’cd /’ # go root
alias a=’ls -G’ # list
alias aa=’ls -G -l -h’ # list with details
alias aaa=’du -h -d 1′ # list disk usage
alias u=’pwd’ # show current location
alias m=’mkdir’ # make directory

Dealing with files
alias e=’vim’ # edit a file
alias ee=’sudo vim’ # edit a file wih sudo
alias f=’find . -name’ # find file by name
alias t=’tail -f’ # keep watching at a file
alias z=’tar zcvf’ # compress file
alias x=’tar zxvf’ # extract compress file
alias xx=’chmod +x’ # add execute permission
alias ww=’chmod a+w’ # add write permission
alias g=’wget’ # get file from internet

Dealing with packages
alias sh=”apt-cache search” // search a package
alias in=’apt-get install’ // install a package
alias un=’apt-get remove’ // uninstall a package
For MacOS, use “port search | port install | port uninstall” instead.
For Centos, use “yum search | yum install | yum remove” instead.

Dealing with system
alias q=’exit’ # exit shell
alias c=’clear’ # clear monitor
alias p=’ps aux | grep’ # look for process
alias h=’sudo vim /etc/hosts’ # edit host config
alias k=’sudo killall’ # kill process
alias ip=”ifconfig | sed -n ‘/inet /p'” # list ips
alias pt=’sudo lsof -i -P -sTCP:LISTEN’ # listening port
alias su=’su -‘ # switch to root user

Dealing with asdf.sh
alias eee=”e /usr/local/bin/asdf.sh” // edit the asdf.sh
alias xxx=”. /usr/local/bin/asdf.sh” // execute the asdf.sh

你可以为自己最常用的命令建立alias别名,进一步提升你的工作效率,别忘了先在shell里试试有没有被占用。
比如我设置了这些alias,以方便我的开发工作:
alias nr=’service nginx restart’
alias phpr=’service php5-fpm restart’
alias phpi=’e /etc/php5/fpm/php.ini’
alias sn=’svn st | grep ? | awk ‘\”{print $2}’\’
alias sa=’svn add `svn st | grep ? | awk ‘\”{print $2}’\”`’
alias sr=’svn rm –force’
…..

This entry was posted in IT技术, Linux, 效率 and tagged , , . Bookmark the permalink.