Skip to content

Instantly share code, notes, and snippets.

@jcarsique jcarsique/.bash_aliases
Last active Oct 16, 2018

Embed
What would you like to do?
Bash config
alias cd..="cd .."
alias md="mkdir"
alias rd="rmdir"
alias mvni="mvn install -DskipTests=true -DskipITs=true"
alias mvnia="mvn install -DskipTests=true -DskipITs=true -Paddons,distrib,all-distributions"
alias mvnci="mvn clean install -DskipTests=true -DskipITs=true"
alias mvncia="mvn clean install -DskipTests=true -DskipITs=true -Paddons,distrib,all-distributions"
alias mvneclipse='mvn eclipse:clean eclipse:eclipse -Declipse.useProjectReferences=true -fae'
alias mvnecl='mvn eclipse:clean eclipse:eclipse -Declipse.useProjectReferences=true -Paddons,distrib,all-distributions -fae -nsu ; ~/workspace/nuxeo/fixeclipse'
alias mvn2ecl="mvn eclipse:clean eclipse:m2eclipse -Paddons,distrib,all-distributions -Declipse.useProjectReferences=true && ~/workspace/nuxeo/fixeclipse"
alias mvneclo='mvn eclipse:clean eclipse:eclipse -o -Paddons,distrib,all-distributions -Declipse.useProjectReferences=true -fae ; ~/workspace/nuxeo/fixeclipse'
alias mvn2eclo="mvn eclipse:clean eclipse:m2eclipse -o -Paddons,distrib,all-distributions -Declipse.useProjectReferences=true && ~/workspace/nuxeo/fixeclipse -o"
alias mvneclj="mvn eclipse:clean eclipse:eclipse -DdownloadJavadocs=true -Paddons,distrib,all-distributions -Declipse.useProjectReferences=true && ~/workspace/nuxeo/fixeclipse"
alias mvnecls="mvn eclipse:clean eclipse:eclipse -DdownloadSources=true -Paddons,distrib,all-distributions -Declipse.useProjectReferences=true && ~/workspace/nuxeo/fixeclipse"
alias mvnecla='mvn eclipse:clean eclipse:eclipse -DdownloadSources=true -DdownloadJavadocs=true -Paddons,distrib,all-distributions -Declipse.useProjectReferences=true -fae -nsu ; ~/workspace/nuxeo/fixeclipse'
alias mvn2ecla="mvn eclipse:clean eclipse:m2eclipse -DdownloadSources=true -DdownloadJavadocs=true -Paddons,distrib,all-distributions -Declipse.useProjectReferences=true && ~/workspace/nuxeo/fixeclipse"
alias hgl='hg glog|less'
alias hgi="hg id -nibt"
alias hgmerge="hg resolve --all -t fmmerge"
alias mvnpurge="mvn dependency:purge-local-repository -DresolutionFuzziness=version -DactTransitively=false"
alias matin="cd ~/workspace/nuxeo; ./clone.py -a -m '' master && mvncia -fae -nsu && mvn eclipse:clean eclipse:eclipse -DdownloadSources=true -DdownloadJavadocs=true -Paddons,distrib,all-distributions -Declipse.useProjectReferences=true -fae -nsu && (cd nuxeo-distribution && mvn clean install -DskipTests=true -DskipITs=true) && (cd addons && mvn eclipse:clean eclipse:eclipse -DdownloadSources=true -DdownloadJavadocs=true -Paddons -Declipse.useProjectReferences=true -fae -f pom-optionals.xml ; mvn eclipse:clean eclipse:eclipse -DdownloadSources=true -DdownloadJavadocs=true -Declipse.useProjectReferences=true -fae -nsu -f pom-optionals.xml) && ~/workspace/nuxeo/fixeclipse"
alias hgfpup="hgf pull && hgf up"
alias hgpup="hg pull && hg up"
# git clone https://github.com/lvv/git-prompt ~/git-prompt
alias git-prompt="source ~/git-prompt/git-prompt.sh"
alias gitconflicts="git diff --name-only --diff-filter=U | xargs $EDITOR"
alias git="LANG=en_US git"
#eval "$(hub alias -s)"
# git clone https://github.com/jcarsique/git-achievements ~/workspace/git-achievements
export PATH="$PATH:~/workspace/git-achievements"
alias git="git-achievements"
alias myip='dig +short myip.opendns.com @resolver1.opendns.com'
alias pbcopy='xclip -selection clipboard'
alias pbpaste='xclip -selection clipboard -o'
alias gitf-st='gitf st|egrep -B2 "^\s?[ACDMRTUXB]"'
alias gitfa-st='gitfa st|egrep -B2 "^\s?[ACDMRTUXB]"'
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
shopt -s globstar
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color) color_prompt=yes;;
esac
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
export PATH=${PATH}:~/bin/
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
# Add an "alert" alias for long running commands. Use like so:
# sleep 10; alert
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 definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
. /etc/bash_completion
fi
export PATH=${PATH}:/opt/adt-bundle-linux-x86_64/sdk/tools
export PATH=${PATH}:/opt/adt-bundle-linux-x86_64/sdk/platform-tools
export ANDROID_HOME=/opt/adt-bundle-linux-x86_64/sdk/
export MAVEN_OPTS="-Xmx4g -Xms512m -XX:MaxPermSize=1g"
#export MAVEN_OPTS="-Xmx4g -Xms512m -XX:MaxPermSize=1g -XX:+UseParNewGC"
#export MAVEN_OPTS="-Xmx4g -Xms512m -XX:MaxPermSize=1g -XX:+UseG1GC"
# hg and git functions
#. /home/julien/workspace/nuxeo-tools-parent/mercurial/.hgfunctions
#. /home/julien/workspace/nuxeo/scripts/hgfunctions.sh
#. /home/julien/workspace/nuxeo/scripts/gitfunctions.sh
source <(curl -s https://raw.githubusercontent.com/nuxeo/nuxeo/stable/scripts/gitfunctions.sh)
pf() {
find . -type d \( -name '.hg' -o -name '.svn' -o -name target -o -name bin \) -prune -o -name pom.xml \
-print0 | xargs -0 grep -Hn "$@" \{\} \; 2> /dev/null
}
pf0() {
find . -type d \( -name '.hg' -o -name '.svn' -o -name target -o -name bin \) -prune -o -name pom.xml \
-print0 | xargs -0 grep -Hln "$@" \{\} \; 2> /dev/null
}
pf2() {
find . -type d \( -name '.hg' -o -name '.svn' -o -name target -o -name bin \) -prune -o -name pom.xml \
-print0 | xargs -0 grep -C2 -Hn "$@" \{\} \; 2> /dev/null
}
jf() {
find . -type d \( -name '.hg' -o -name '.svn' -o -name 'target' -o -name bin \) -prune -or \( -name '*.xml' -or -name '*.java' -or \
-name '*.properties' -or -name '*.xhtml' -or -name '*.js' -or -name '*.ftl' -o -name '*.jsp' -o -name '*.txt' -o -name '*.md' \) -type f -print0 \
| xargs -0 grep -Hn "$@" \{\} \; 2> /dev/null
}
jf0() {
find . -type d \( -name '.hg' -o -name '.svn' -o -name 'target' -o -name bin \) -prune -or \( -name '*.xml' -or -name '*.java' -or \
-name '*.properties' -or -name '*.xhtml' -or -name '*.js' -or -name '*.ftl' -o -name '*.jsp' -o -name '*.txt' -o -name '*.md' \) -type f -print0 \
| xargs -0 grep -Hln "$@" \{\} \; 2> /dev/null
}
xf() {
find . -type d \( -name '.hg' -o -name '.svn' -o -name 'target' -o -name bin \) -prune -o \( -name '*.xml' \) -type f -print0 \
| xargs -0 grep -Hn "$@" \{\} \; 2> /dev/null
}
xf0() {
find . -type d \( -name '.hg' -o -name '.svn' -o -name 'target' -o -name bin \) -prune -o \( -name '*.xml' \) -type f -print0 \
| xargs -0 grep -Hln "$@" \{\} \; 2> /dev/null
}
rmrootprojects() {
for dir in $(find . -name pom.xml | xargs grep -Hl '<module>' | sed 's/pom.xml//'); do (
cd $dir
[ -e .project ] && (
[ -e .project.ok ] && (diff -q .project .project.ok || cp .project.ok .project.ok.bak)
) && mv .project .project.ok
); done
}
setrootprojects() {
for dir in $(find . -name pom.xml | xargs grep -Hl '<module>' | sed 's/pom.xml//'); do (
cd $dir
[ -e .project.ok ] && (
[ -e .project ] && (diff -q .project .project.ok || cp .project .project.bak)
) && cp .project.ok .project
); done
}
[ -z "$PS1" ] && return
set_path_and_prompt() {
if [ -z "$_OLD_DEFAULT_PS1" ]; then
_OLD_DEFAULT_PS1=$PS1
fi
if [ -z "$_OLD_DEFAULT_PATH" ]; then
_OLD_DEFAULT_PATH=$PATH
fi
PS1="${JAVA_PROMPT}${MAVEN_PROMPT}${_OLD_DEFAULT_PS1}"
export PS1
if [ -n "JAVA_HOME" ] && [ -n "M2_HOME" ]; then
PATH="${JAVA_HOME}/bin:${M2_HOME}/bin:${_OLD_DEFAULT_PATH}"
elif [ -n "JAVA_HOME" ]; then
PATH="${JAVA_HOME}/bin:${_OLD_DEFAULT_PATH}"
else
PATH="${M2_HOME}/bin:${_OLD_DEFAULT_PATH}"
fi
export PATH
}
set_jdk6_Sun() {
JAVA_HOME='/usr/lib/jvm/java-6-sun/'
JAVA_PROMPT='\[\033[1;32m\]Sjdk6 \[\033[0m\]'
export JAVA_HOME JAVA_PROMPT
set_path_and_prompt
}
set_jdk7_Sun() {
JAVA_HOME='/usr/lib/jvm/java-7-sun/'
JAVA_PROMPT='\[\033[1;32m\]Sjdk7 \[\033[0m\]'
export JAVA_HOME JAVA_PROMPT
set_path_and_prompt
}
set_jdk6_OpenJDK() {
JAVA_HOME='/usr/lib/jvm/java-6-openjdk/'
JAVA_PROMPT='\[\033[1;31m\]Ojdk6 \[\033[0m\]'
export JAVA_HOME JAVA_PROMPT
set_path_and_prompt
}
set_jdk7_OpenJDK() {
JAVA_HOME='/usr/lib/jvm/java-7-openjdk/'
JAVA_PROMPT='\[\033[1;31m\]Ojdk7 \[\033[0m\]'
export JAVA_HOME JAVA_PROMPT
set_path_and_prompt
}
unset_jdk() {
unset JAVA_HOME
unset JAVA_PROMPT
set_path_and_prompt
}
set_maven2() {
M2_HOME='/opt/maven'
MAVEN_PROMPT='\[\033[1;31m\]m2 \[\033[0m\]'
export M2_HOME MAVEN_PROMPT
set_path_and_prompt
}
set_maven3() {
M2_HOME='/opt/maven3'
MAVEN_PROMPT='\[\033[1;33m\]m3 \[\033[0m\]'
export M2_HOME MAVEN_PROMPT
set_path_and_prompt
}
set_maven32() {
M2_HOME='/opt/apache-maven-3.2.1'
MAVEN_PROMPT='\[\033[1;35m\]m3.2 \[\033[0m\]'
export M2_HOME MAVEN_PROMPT
set_path_and_prompt
}
unset_maven() {
unset M2_HOME
unset M2_REPO
unset MAVEN_PROMPT
set_path_and_prompt
}
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
# git@github.com:jcarsique/git.git
source ~/workspace/git/contrib/completion/git-prompt.sh
#source ~/.bash_completion_svn
source ~/workspace/git/contrib/completion/git-completion.bash
# git://github.com/defunkt/hub.git
source /home/julien/workspace/hub/etc/hub.bash_completion.sh
__git_complete gitf __git_main
__git_complete gitfa __git_main
GIT_PS1_SHOWDIRTYSTATE=1
GIT_PS1_SHOWUNTRACKEDFILES=1
GIT_PS1_SHOWSTASHSTATE=1
GIT_PS1_SHOWUPSTREAM="auto verbose name"
#GIT_PS1_SHOWCOLORHINTS=true
# Reduce PWD in prompt to last 30 chars of PWD
function truncate_pwd
{
newPWD="${PWD/#$HOME/~}"
local pwdmaxlen=50
if [ ${#newPWD} -gt $pwdmaxlen ]
then
newPWD="...${newPWD: -$pwdmaxlen}"
fi
}
PROMPT_COMMAND=truncate_pwd
PS1='$? [\[\033[1;35m\]$newPWD$(__git_ps1 " \[\033[1;34m\](%s)")\[\033[0m\]]\$ '
export PATH=/opt/eclipse/:$PATH
export PATH=/opt/node/bin/:$PATH
export PATH=~/workspace/fast-export/:$PATH
export PATH=/opt/build/tools/gradle-1.11/bin:$PATH
#set_jdk7_OpenJDK
set_jdk7_Sun
set_maven32
if [ -f ~/.wrap_alias ]; then
. ~/.wrap_alias
fi
$include /etc/inputrc
$if Bash
#do history expansion when space entered
Space: magic-space
$endif
# Custom
"\e[A": history-search-backward
"\e[B": history-search-forward
set show-all-if-ambiguous on
set completion-ignore-case on
# wrap_alias takes three arguments:
# $1: The name of the alias
# $2: The command used in the alias
# $3: The arguments in the alias all in one string
# Generate a wrapper completion function (completer) for an alias
# based on the command and the given arguments, if there is a
# completer for the command, and set the wrapper as the completer for
# the alias.
function wrap_alias() {
[[ "$#" == 3 ]] || return 1
local alias_name="$1"
local aliased_command="$2"
local alias_arguments="$3"
local num_alias_arguments=$(echo "$alias_arguments" | wc -w)
# The completion currently being used for the aliased command.
local completion=$(complete -p $aliased_command 2> /dev/null)
# Only a completer based on a function can be wrapped so look for -F
# in the current completion. This check will also catch commands
# with no completer for which $completion will be empty.
echo $completion | grep -q -- -F || return 0
local namespace=alias_completion::
# Extract the name of the completion function from a string that
# looks like: something -F function_name something
# First strip the beginning of the string up to the function name by
# removing "* -F " from the front.
local completion_function=${completion##* -F }
# Then strip " *" from the end, leaving only the function name.
completion_function=${completion_function%% *}
# Try to prevent an infinite loop by not wrapping a function
# generated by this function. This can happen when the user runs
# this twice for an alias like ls='ls --color=auto' or alias l='ls'
# and alias ls='l foo'
[[ "${completion_function#$namespace}" != $completion_function ]] && return 0
[[ "_longopt" = $completion_function ]] && return 0
# echo DEBUG: Wrapped $alias_name $completion_function
local wrapper_name="${namespace}${alias_name}"
eval "
function ${wrapper_name}() {
let COMP_CWORD+=$num_alias_arguments
args=( \"${alias_arguments}\" )
COMP_WORDS=( $aliased_command \${args[@]} \"\${COMP_WORDS[@]:1}\" )
$completion_function
}
"
# To create the new completion we use the old one with two
# replacements:
# 1) Replace the function with the wrapper.
local new_completion=${completion/-F * /-F $wrapper_name }
# 2) Replace the command being completed with the alias.
new_completion="${new_completion% *} $alias_name"
eval "$new_completion"
}
# For each defined alias, extract the necessary elements and use them
# to call wrap_alias.
eval "$(alias -p | grep -v '[\";|&]' | sed -e 's/alias \([^=][^=]*\)='\''\([^ ][^ ]*\) *\(.*\)'\''/wrap_alias \1 \2 '\''\3'\'' /')"
unset wrap_alias
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.