Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
dotfiles/shell/.functions
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
158 lines (129 sloc)
3.89 KB
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
# Run tests | |
function p() { | |
if [ -f vendor/bin/pest ]; then | |
vendor/bin/pest "$@" | |
else | |
vendor/bin/phpunit "$@" | |
fi | |
} | |
function pf() { | |
if [ -f vendor/bin/pest ]; then | |
vendor/bin/pest --filter "$@" | |
else | |
vendor/bin/phpunit --filter "$@" | |
fi | |
} | |
# Docker | |
function ssh-docker() { | |
docker exec -it "$@" bash | |
} | |
# Create a new directory and enter it | |
function mkd() { | |
mkdir -p "$@" && cd "$@" | |
} | |
# Start an HTTP server from a directory, optionally specifying the port | |
function server() { | |
local port="${1:-9000}" | |
sleep 2 && open "http://localhost:${port}/" & | |
# Set the default Content-Type to `text/plain` instead of `application/octet-stream` | |
# And serve everything as UTF-8 (although not technically correct, this doesn’t break anything for binary files) | |
python -c $'import SimpleHTTPServer;\nmap = SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map;\nmap[""] = "text/plain";\nfor key, value in map.items():\n\tmap[key] = value + ";charset=UTF-8";\nSimpleHTTPServer.test();' "$port" | |
} | |
# Start a PHP server from a directory, optionally specifying the port | |
# (Requires PHP 5.4.0+.) | |
function phpserver() { | |
local port="${1:-4000}" | |
local ip=$(ipconfig getifaddr en0) | |
sleep 2 && open "http://${ip}:${port}/" & | |
php -S "${ip}:${port}" | |
} | |
# All the dig info | |
function digga() { | |
dig +nocmd "$1" any +multiline +noall +answer | |
} | |
function tinker() | |
{ | |
if [ -z "$1" ] | |
then | |
php artisan tinker | |
else | |
php artisan tinker --execute="dd($1);" | |
fi | |
} | |
#shortcut voor zhs quick-look command | |
function ql() { | |
quick-look "$1" | |
} | |
archive () { | |
zip -r "$1".zip -i "$1" ; | |
} | |
function removehost() { | |
ssh-keygen -R "$1" | |
} | |
function weather() { | |
local city="${1:-Antwerp}" | |
curl http://wttr.in/${city// /+}\?F | |
} | |
alias mysqladm='mysql -u root' | |
# Scrape a single webpage with all assets | |
function scrapeUrl() { | |
wget --adjust-extension --convert-links --page-requisites --span-hosts --no-host-directories "$1" | |
} | |
function rector() { | |
docker run -v $(pwd):/project rector/rector:latest process /project/$1 --set php80 --autoload-file /project/vendor/autoload.php | |
} | |
# Commit everything | |
function commit() { | |
commitMessage="$*" | |
git add . | |
if [ "$commitMessage" = "" ]; then | |
aicommits | |
return | |
fi | |
eval "git commit -a -m '${commitMessage}'" | |
} | |
xdebug() { | |
iniFileLocation="/usr/local/etc/php/7.4/php.ini"; | |
currentLine=`cat $iniFileLocation | grep xdebug.so` | |
if [[ $currentLine =~ ^#zend_extension ]]; | |
then | |
sed -i -e 's/^#zend_extension/zend_extension/g' $iniFileLocation | |
echo "xdebug is now active"; | |
else | |
sed -i -e 's/^zend_extension/#zend_extension/g' $iniFileLocation | |
echo "xdebug is now inactive"; | |
fi | |
} | |
function db { | |
if [ "$1" = "refresh" ]; then | |
mysql -uroot -e "drop database $2; create database $2" | |
elif [ "$1" = "create" ]; then | |
mysql -uroot -e "create database $2" | |
elif [ "$1" = "drop" ]; then | |
mysql -uroot -e "drop database $2" | |
elif [ "$1" = "list" ]; then | |
mysql -uroot -e "show databases" | perl -p -e's/\|| *//g' | |
fi | |
} | |
function opendb () { | |
[ ! -f .env ] && { echo "No .env file found."; exit 1; } | |
DB_CONNECTION=$(grep DB_CONNECTION .env | grep -v -e '^\s*#' | cut -d '=' -f 2-) | |
DB_HOST=$(grep DB_HOST .env | grep -v -e '^\s*#' | cut -d '=' -f 2-) | |
DB_PORT=$(grep DB_PORT .env | grep -v -e '^\s*#' | cut -d '=' -f 2-) | |
DB_DATABASE=$(grep DB_DATABASE .env | grep -v -e '^\s*#' | cut -d '=' -f 2-) | |
DB_USERNAME=$(grep DB_USERNAME .env | grep -v -e '^\s*#' | cut -d '=' -f 2-) | |
DB_PASSWORD=$(grep DB_PASSWORD .env | grep -v -e '^\s*#' | cut -d '=' -f 2-) | |
DB_URL="${DB_CONNECTION}://${DB_USERNAME}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_DATABASE}" | |
echo "Opening ${DB_URL}" | |
open $DB_URL | |
} | |
function scheduler () { | |
while :; do | |
php artisan schedule:run | |
echo "Sleeping 60 seconds..." | |
sleep 60 | |
done | |
} | |
function silent() { | |
"$@" >& /dev/null | |
} | |