|
### Exports |
|
################# |
|
|
|
# set prompt |
|
export PS1='\[\033[01;32m\]\u:\[\033[01;34m\]\w\[\033[00m\]\n\$ ' |
|
|
|
# set proper charsets |
|
export LANG=en_US.UTF-8 |
|
export LESSCHARSET=utf-8 |
|
export LESS='-r --quiet' |
|
|
|
# allows using X apps (requires VcXsrv running in Windows) |
|
export DISPLAY=:0 |
|
|
|
# set JAVA_HOME if not defined and java is in the PATH |
|
if [ -z "$JAVA_HOME" -a "" != "`which java 2> /dev/null`" ]; then |
|
export JAVA_HOME=`dirname "\`which java\`"` |
|
fi |
|
|
|
### Colors |
|
################# |
|
|
|
alias ls='ls --color=auto' |
|
alias dir='dir --color=auto' |
|
alias vdir='vdir --color=auto' |
|
|
|
### Smarter Defaults |
|
################# |
|
|
|
alias grep='grep --perl-regexp --color=auto --exclude-dir=.svn --exclude-dir=.git' |
|
alias fgrep='fgrep --color=auto --exclude-dir=.svn --exclude-dir=.git' |
|
alias egrep='egrep --color=auto --exclude-dir=.svn --exclude-dir=.git' |
|
alias ls='ls -ah --color' |
|
alias ll='ls -alh --color' |
|
alias mysql='mysql -b' |
|
|
|
### Aliases |
|
################# |
|
|
|
alias .='cd ..' |
|
alias ..='cd ../..' |
|
alias ...='cd ../../..' |
|
alias ....='cd ../../../..' |
|
alias .....='cd ../../../../..' |
|
alias c="composer" |
|
|
|
### Runs Symfony console from project root |
|
con() { |
|
if [ -e app/console ] |
|
then |
|
app/console $@ |
|
else |
|
bin/console $@ |
|
fi |
|
} |
|
|
|
### Runs notepad for Windows-filesystem files (with translated path) and nano otherwise |
|
n() { |
|
if [ "$1" == "" ] |
|
then |
|
nano |
|
return |
|
fi |
|
|
|
winPath=$(wslpath -m "$1" 2>/dev/null) |
|
if [ $? -eq 0 ] |
|
then |
|
notepad.exe "$winPath" |
|
else |
|
nano "$1" |
|
fi |
|
} |
|
|
|
### Opens directory argument in Sublime Text with translated path |
|
subl() { |
|
if [ "$1" == "" ] |
|
then |
|
"/mnt/c/Program Files/Sublime Text 3/subl.exe" |
|
return |
|
fi |
|
|
|
winPath=$(wslpath -m "$1" 2>/dev/null) |
|
if [ $? -eq 0 ] |
|
then |
|
"/mnt/c/Program Files/Sublime Text 3/subl.exe" "$winPath" |
|
else |
|
echo 'Can not edit linux-filesystem from Windows' |
|
exit 1 |
|
fi |
|
} |
|
|
|
### Opens Windows Explorer with translated path |
|
exp() { |
|
if [ "$1" == "" ] |
|
then |
|
explorer.exe . |
|
return |
|
fi |
|
|
|
winPath=$(wslpath -m "$1" 2>/dev/null) |
|
if [ $? -eq 0 ] |
|
then |
|
explorer.exe "$winPath" |
|
else |
|
explorer.exe "$1" |
|
fi |
|
} |
|
|
|
### VCS Aliases |
|
################# |
|
|
|
alias h='hub' |
|
alias g='git' |
|
alias gd='git diff --color $@ | diff-so-fancy' |
|
alias gp='git push' |
|
alias st='if [ -d .svn ]; then svn status --ignore-externals; else git status; fi' |
|
alias a="git add -p" |
|
|
|
### SSH Agent |
|
################ |
|
|
|
declare -x SSH_ENV="$HOME/.ssh/environment-wsl" |
|
|
|
# start the ssh-agent |
|
function start_agent { |
|
# spawn ssh-agent |
|
ssh-agent | sed 's/^echo/#echo/' > "$SSH_ENV" |
|
chmod 600 "$SSH_ENV" |
|
source "$SSH_ENV" > /dev/null |
|
ssh-add |
|
} |
|
|
|
# test for identities |
|
function test_identities { |
|
# test whether standard identities have been added to the agent already |
|
ssh-add -l | /bin/grep "The agent has no identities" > /dev/null |
|
if [ $? -eq 0 ]; then |
|
ssh-add |
|
# $SSH_AUTH_SOCK broken so we start a new proper agent |
|
if [ $? -eq 2 ];then |
|
start_agent |
|
fi |
|
fi |
|
} |
|
|
|
# check for running ssh-agent with proper $SSH_AGENT_PID |
|
if [ -n "$SSH_AGENT_PID" ]; then |
|
ps -f -u $USER | /bin/grep "$SSH_AGENT_PID" | /bin/grep ssh-agent > /dev/null |
|
if [ $? -eq 0 ]; then |
|
test_identities |
|
fi |
|
else |
|
if [ -f "$SSH_ENV" ]; then |
|
source "$SSH_ENV" > /dev/null |
|
fi |
|
ps -f -u $USER | /bin/grep "$SSH_AGENT_PID" | /bin/grep ssh-agent > /dev/null |
|
if [ $? -eq 0 ]; then |
|
test_identities |
|
else |
|
start_agent |
|
fi |
|
fi |