alias 在Linux系统中用来给指令起别名,用来简化很长的指令。 用法很简单:
- alias : 查看当前所有别名
- alias tmstart = "$CATALINA_HOME/bin/start.sh" : 为启动tomcat的指令器别名
- unalias tmstart : 删除 tmstart 别名
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM functionJAVA_HOME=/usr/lib/jvm/java-6-sun
CLASSPATH=$JAVA_HOME/lib
PATH=$JAVA_HOME:$PATHCATALINA_HOME=/home/lvjian/libs/tomcat6
#PATH=$CATALINA_HOME/bin:$PATH# some alias about tomcat
alias tm='cd $CATALINA_HOME';
alias tmout='tail -f $CATALINA_HOME/logs/catalina.out';
alias tmstart='$CATALINA_HOME/bin/startup.sh';
alias tmstop='$CATALINA_HOME/bin/shutdown.sh';
alias tmconf='vim $CATALINA_HOME/conf/server.xml';
alias tmclear='rm -rf $CATALINA_HOME/work/*';alias tail='tail -f';
alias cd..='cd ..';
# alias this for window cls
alias cls='clear'# cd to my eclipse workspace
alias sts='cd ~/sts';
# cd to my netmange3-rest project, it's a Rest-ful webservice
alias nm3='cd ~/sts/netmanage3-rest';
# startup netmanage3-rest webservice.
# The code of Gistnm3start.sh is below:
# #!/bin/bash
# cd ~/sts/netmanage3-rest/
# mvn jetty:run
alias nm3start='~/scripts/nm3start.sh';alias shrc='vim ~/.bash_profile';
alias shs='source ~/.bash_profile'; # alias open folder, it for mac os x - open
alias openf='nautilus ';
这里解释一下:
1. Tomcat相关:
alias tm='cd $CATALINA_HOME';
alias tmout='tail -f $CATALINA_HOME/logs/catalina.out';
alias tmstart='$CATALINA_HOME/bin/startup.sh';
alias tmstop='$CATALINA_HOME/bin/shutdown.sh';
alias tmconf='vim $CATALINA_HOME/conf/server.xml';
alias tmclear='rm -rf $CATALINA_HOME/work/*';
- tm: 进入tomcat目录
- tmout: 监视tomcat日志
- tmstart: 启动tomcat
- tmstop: 关闭tomcat
- tmconf: 使用vim编辑tomcat -> server.xml
- tmclear: 清理tomcat缓存
2. 日常使用
alias tail='tail -f';
alias cd..='cd ..';
# alias this for window cls
alias cls='clear'
# alias open folder, it for mac os x - open
alias openf='nautilus ';
- 将tail指令修改成始终监控,即一旦文件有更新则会在terminal中打印出来
- 由于本人经常错将"cd空格.."打成"cd..", 所以将"cd.."映射成"cd .."
- 清理Terminal, window下用cls, ubuntu下用clear, 这里做个统一。
- ubuntu下文件管理器。 MacOS下使用open . 就能打开当前目录, ubuntu下需要用nautilus, 又长又难记, 统一一下。
alias shrc='vim ~/.bash_profile';
alias shs='source ~/.bash_profile';
- shrc: 快速编辑~/.bash_profile文件.
- shs: 快速重新加载 ~/.bash_profile.
3. 项目相关
# cd to my eclipse workspace
alias sts='cd ~/sts';
# cd to my netmange3-rest project, it's a Rest-ful webservice
alias nm3='cd ~/sts/netmanage3-rest';
alias nm3start='~/scripts/nm3start.sh';
- Giststs : 跳转到eclipse的workspace
- nm3: 跳转到网管服务器项目
- nm3start: 快速启动网管项目。 "~/scripts/nm3start.sh" 之我自己写的启动脚本
#!/bin/bashcd ~/sts/netmanage3-rest/
mvn jetty:run
chmod 755 ~/scripts/nm3start.sh
你可能感兴趣的文章:
- Linux/Mac OS Terminal 个人常用技巧整理
- 分享一个SlideShare:《做卓有成效的程序员》 (由于slideshare被和谐,可以直接下载PPT)