-
-
Save Seldaek/fe3676f8b1ade7b9eb65abd5f5508b3a to your computer and use it in GitHub Desktop.
WSL Setup
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
# Adds Ubuntu PPAs for PHP releases, latest nginx and hub (https://github.com/github/hub) | |
sudo add-apt-repository ppa:ondrej/php | |
sudo add-apt-repository ppa:nginx/stable | |
sudo add-apt-repository ppa:cpick/hub | |
# Adds PPAs for NodeJS 8.x and Yarn | |
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - | |
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - | |
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list | |
# Update all sources and upgrade all packages | |
sudo apt update | |
sudo apt upgrade | |
# Install utilities and build tools | |
sudo apt install make g++ git gitk htop postgresql-client mysql-client unzip hub | |
# Install PHP/Node/Yarn | |
sudo apt install nodejs yarn php7.2-cli php7.2-fpm php7.2-intl php7.2-xdebug php7.2-xml php7.2-zip php7.2-curl php7.2-mbstring php7.2-pgsql php7.2-mysql | |
# Install Redis/Nginx | |
sudo apt install redis-server nginx-full | |
# Install some global yarn dependencies | |
yarn global add diff-so-fancy gulp-cli | |
# composer global require ... etc |
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
### 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 |
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
server { | |
listen 80; | |
server_name example.lo; | |
root /mnt/c/Users/XXX/Web/example.lo/web; | |
rewrite ^/app\.php/?(.*)$ /$1 permanent; | |
location / { | |
index app.php; | |
if (-f $request_filename) { | |
break; | |
} | |
rewrite ^(.*)$ /app.php$1 last; | |
} | |
location ~ ^/(app|app_dev)\.php(/|$) { | |
fastcgi_pass unix:/var/run/php-fpm.sock; | |
fastcgi_split_path_info ^(.+\.php)(/.*)$; | |
include fastcgi_params; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
fastcgi_param HTTPS off; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment