mirror of
https://github.com/ivuorinen/dotfiles.git
synced 2026-01-26 11:14:08 +00:00
76 lines
2.5 KiB
Bash
Executable File
76 lines
2.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
||
|
||
# Get installed php versions from brew and setup aliases
|
||
function x-set-php-aliases
|
||
{
|
||
if command -v brew &> /dev/null; then
|
||
local php_versions=()
|
||
while IFS="" read -r line; do php_versions+=("$line"); done < <(brew list | grep '^php')
|
||
|
||
php_error_reporting='-d error_reporting=22527'
|
||
|
||
for version in "${php_versions[@]}"; do
|
||
# drop the dot from version (8.0 -> 80)
|
||
local php_abbr="${version//\./}"
|
||
# replace "php@" with "p" so "php@80" becomes "p80"
|
||
local php_alias="${php_abbr//php@/p}"
|
||
|
||
# Skip php = php aliasing
|
||
# if [[ "$php_abbr" == "$php_alias" ]]; then continue; fi;
|
||
|
||
# Fetch the exec path once
|
||
php_exec="$(brew --prefix "$version")/bin/php"
|
||
|
||
# Raw PHP without error_reporting flag.
|
||
# shellcheck disable=SC2139
|
||
alias "${php_alias}"r="$php_exec"
|
||
# PHP with error_reporting flag.
|
||
# shellcheck disable=SC2139,SC2140
|
||
alias "$php_alias"="$php_exec $php_error_reporting"
|
||
# Local PHP Server.
|
||
# shellcheck disable=SC2139,SC2140
|
||
alias "${php_alias}s"="$php_exec -S localhost:9000"
|
||
# Use composer with specific PHP and error_reporting flag on.
|
||
# shellcheck disable=SC2139,SC2140
|
||
alias "${php_alias}c"="$php_exec $php_error_reporting $(which composer)"
|
||
done
|
||
fi
|
||
}
|
||
|
||
if [[ $(uname) == 'Darwin' ]]; then
|
||
|
||
x-set-php-aliases
|
||
|
||
# Laravel Sail shortcut
|
||
alias sail='[ -f sail ] && bash sail || bash vendor/bin/sail'
|
||
|
||
# Flush Directory Service cache
|
||
alias flushdns="sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder"
|
||
|
||
# Lock the screen
|
||
alias afk="osascript -e 'tell application \"System Events\" to keystroke \"q\" using {command down,control down}'"
|
||
|
||
# Empty the Trash on all mounted volumes and the main HDD
|
||
# Also, clear Apple’s System Logs to improve shell startup speed
|
||
alias emptytrash="sudo rm -rfv /Volumes/*/.Trashes; sudo rm -rfv ~/.Trash; sudo rm -rfv /private/var/log/asl/*.asl"
|
||
fi
|
||
|
||
alias watchx='watch -dpbc' # watch with: differences, precise, beep and color
|
||
alias zapds='find . -name ".DS_Store" -print -delete'
|
||
alias t='tail -f' # tail with follow flag on
|
||
alias dn='du -chd1' # directory usage, return only the total
|
||
|
||
alias code_scanner='docker run
|
||
--env SOURCE_CODE="$PWD"
|
||
--volume "${PWD}":/code
|
||
--volume /var/run/docker.sock:/var/run/docker.sock
|
||
registry.gitlab.com/gitlab-org/ci-cd/codequality:"${CODEQUALITY_VERSION:-latest}"
|
||
/code'
|
||
|
||
alias zedit='$EDITOR ~/.dotfiles'
|
||
|
||
if [[ -f "$HOME/.aliases.local" ]]; then
|
||
# shellcheck disable=SC1091
|
||
source "$HOME/.aliases.local"
|
||
fi
|