Created
August 19, 2012 14:04
-
-
Save saltnlight5/3395024 to your computer and use it in GitHub Desktop.
Bash examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Bash Profile script | |
# Zemian Deng 07/03/2012 | |
# | |
export EASYANT_HOME=$HOME/apps/easyant | |
export JAVA_HOME=$HOME/apps/jdk | |
export PATH=$JAVA_HOME/bin:\ | |
$HOME/apps/maven/bin:\ | |
$HOME/apps/gradle/bin:\ | |
$HOME/apps/groovy/bin:\ | |
/usr/local/mysql/bin:\ | |
/usr/local/Cellar/ruby/1.9.3-p194/bin:\ | |
$HOME/apps/jruby/bin:\ | |
/usr/local/bin:\ | |
$PATH | |
# Shell and tools shortcuts | |
alias tstamp='date "+%Y%m%d-%H%M%S"' | |
# Groovy scripting shortcuts | |
alias g=groovy | |
alias gs='groovysh' | |
alias gc='groovyConsole' | |
# Fast edit | |
function jedit(){ | |
FILES='' | |
for F in "$@"; do | |
FULL_DIR=$(cd $(dirname $F) && pwd) | |
FILES="$FILES $FULL_DIR/$(basename $F)" | |
done | |
#echo /Applications/jEdit.app/Contents/MacOS/jedit -reuseview -- $FILES | |
/Applications/jEdit.app/Contents/MacOS/jedit -reuseview -- $FILES &> /dev/null | |
} | |
alias e=jedit | |
alias n=notes | |
alias eb='e $HOME/.bash_profile' | |
alias rb='source $HOME/.bash_profile' | |
alias nweb='java -jar $HOME/notes/webnotepad.war' | |
# notes | |
function notes() { F="$HOME/notes/$(tstamp).markdown"; touch $F; e $F; } | |
# Maven shortcuts | |
alias mvnc='mvn test-compile' | |
alias mvni='mvn install -DskipTests' | |
alias mvnp='mvn package -DskipTests' | |
alias mvnt='mvn test' | |
function mvnt1() { mvn test -Dtest="$1"; } | |
function mvncat() { cat target/surefire-reports/*$1*.txt ; } | |
alias mvndt='mvn dependency:tree' | |
alias mvndc='mvn dependency:copy-dependencies' | |
# TimeMachine shortcuts | |
alias cdtm='cd $HOME/projects/scheduler' | |
alias tmweb='mvn tomcat7:run' | |
function tms() { mvn exec:java -Dexec.classpathScope=test -Dexec.mainClass=timemachine.scheduler.tool.SchedulerServer -Dexec.args="$1" ; } | |
# JBossAS shortcuts | |
export JB=$HOME/apps/jboss | |
export JBD=$HOME/apps/jboss/standalone/deployments | |
export JBC=$HOME/apps/jboss/standalone/configuration | |
alias jb='$JB/bin/standalone.sh' | |
function startjboss() { $HOME/apps/jboss/bin/standalone.sh -Djava.nio.channels.spi.SelectorProvider=sun.nio.ch.KQueueSelectorProvider ; } | |
function stopjboss() { JAVA_OPTS="-Djava.nio.channels.spi.SelectorProvider=sun.nio.ch.KQueueSelectorProvider" $HOME/apps/jboss/bin/jboss-cli.sh --connect :shutdown ; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get full path of a file or directory | |
function fullpath() { | |
for FN in "$@"; do | |
FN="$(cd `dirname $FN` && pwd)/`basename $FN`" | |
echo -n "$FN " | |
done | |
} | |
# Convert cygwin path into windows full path | |
function wpath() { | |
for FN in "$@"; do | |
FN=`cygpath -wa "$FN"` | |
echo -n "$FN " | |
done | |
} | |
# Printing files | |
alias tail3='tail -300' | |
alias catall='head -n 999999' | |
# To terminate windows process in cygwin | |
alias kill2='/usr/bin/kill -f' | |
# A quickter 'find' command. eg: findit file1.txt | |
function findit() { | |
DIR=. | |
if [[ $# -ge 2 ]]; then | |
DIR=$2 | |
fi | |
find $DIR -name "*$1*" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Sun Solaris | |
# For each java process, check what TCP ports are open and print PID if match. | |
PORT=$1 | |
for PID in `jps | grep -v Jps | perl -ane 'print "$F[0] "'`; do | |
pfiles $PID |grep AF_INET | grep $PORT && echo $PID | |
done | |
## On linux | |
## For each java process, check what TCP ports are open and print PID if match. | |
#PORT=$1 | |
#lsof -i | grep java | grep $PORT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment