Last active
November 27, 2019 10:18
-
-
Save 321zeno/bdf022ebb681404a476af1c8422aafbd to your computer and use it in GitHub Desktop.
.bashrc
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
# Formatting json | |
alias jq=/d/Tools/jq-win64.exe | |
# Enable highlighting in grep | |
alias grep='grep --color=auto' | |
# Better file listing | |
alias ll='ls -lhFA --color --group-directories-first' | |
# alias ports='netstat -tulanp' | |
alias ..="cd .." | |
# Search processes table ex: psg bash, psg apache2 | |
alias psg="ps aux | grep -v grep | grep -i -e VSZ -e" | |
# Always create the parent directories on the fly | |
alias mkdir="mkdir -p" | |
# Always retry for a download | |
alias wget="wget -c" | |
# Tail file and grep for line | |
# ex: tgrep ./laravel/storage/logs/laravel-cli-2019-07-22.log ERROR | |
function tgrep { | |
if [ -z "$1" ]; then return; fi | |
tail -f "$1" | grep "$2" | |
} | |
# Create a directory and enter | |
function mcd { | |
mkdir -p $1 | |
cd $1 | |
} | |
# Interact with json APIs using curl | |
# ex: json GET https://my-json-server.typicode.com/typicode/demo/posts {} | |
function json { | |
curl -X $1 $2 -H 'Accept: application/json' -H 'Content-Type: application/json' -d $3 | jq '.' | |
} | |
# List all containers that match a string | |
# ex: containers-ps prospectus-admin | |
function containers-ps { | |
docker ps -a -f name="$1" | awk '{if (NR!=1) print $1}' | |
} | |
# Stop all containers that match a string | |
# ex: containers-stop prospectus-admin | |
function containers-stop { | |
docker stop $(docker ps -a -f name="$1" | awk '{if (NR!=1) print $1}') | |
} | |
# Remove all containers by name | |
# ex: containers-rm prospectus-admin | |
function containers-rm { | |
docker rm $(docker ps -a -f name="$1" | awk '{if (NR!=1) print $1}') | |
} | |
# SSH into a workspace container | |
# ex: workspace prospectus-admin | |
function workspace { | |
docker exec -it $1_workspace_1 bash | |
} | |
# Run Squizlabs PHP CodeSniffer with the global ruleset | |
# Example: | |
# sniff - will run in current dir | |
# sniff File.php - will run on specified file only | |
function sniff { | |
local path="." | |
if [ "$1" ]; then path=$1; fi | |
phpcs --standard="/d/Sites/documentation/documentation/coding-standards/PHP/CodeSniffer/CustomPHPCS" --extensions=php $@ | |
} | |
# Fix Squizlabs PHP CodeSniffer issues with the global ruleset | |
function fix { | |
local path="." | |
if [ "$1" ]; then path=$1; fi | |
phpcbf --standard="/d/Sites/documentation/documentation/coding-standards/PHP/CodeSniffer/CustomPHPCS" --extensions=php $@ -p | |
} | |
# Sniffs only staged files | |
function gitsniff { | |
local files=$(git ls-files -om --exclude-standard \*.php) | |
if [ -z "$files" ]; then | |
echo 'No files to check'; | |
else | |
sniff $files; | |
fi | |
} | |
# fix only staged files | |
function gitfix { | |
local files=$(git ls-files -om --exclude-standard \*.php) | |
if [ -z "$files" ]; then | |
echo 'No files to check'; | |
else | |
fix $files | |
fi | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hacks