mirror of
https://github.com/ivuorinen/dotfiles.git
synced 2026-01-26 11:14:08 +00:00
90 lines
2.9 KiB
Bash
Executable File
90 lines
2.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
||
# shellcheck source="../scripts/shared.sh"
|
||
# shellcheck disable=1091,2139
|
||
source "$DOTFILES/scripts/shared.sh"
|
||
|
||
# Get installed php versions from brew and setup aliases
|
||
function x-set-php-aliases
|
||
{
|
||
have brew && {
|
||
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}"
|
||
|
||
# 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
|
||
}
|
||
}
|
||
|
||
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
|
||
|
||
# watch with: differences, precise, beep and color
|
||
alias watchx='watch -dpbc'
|
||
# delete .DS_Store files
|
||
alias zapds='find . -name ".DS_Store" -print -delete'
|
||
# tail with follow flag on
|
||
alias t='tail -f'
|
||
# directory usage, return only the total
|
||
alias dn='du -chd1'
|
||
# Mirror site with wget
|
||
alias mirror_site='wget -m -k -K -E -e robots=off'
|
||
# Mirror stdout to stderr, useful for seeing data going through a pipe
|
||
alias peek='tee >(cat 1>&2)'
|
||
|
||
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'
|
||
|
||
have irssi \
|
||
&& alias irssi="irssi --config='$IRSSI_CONFIG_FILE' --home='$IRSSI_CONFIG_HOME'"
|
||
|
||
if [[ -f "$HOME/.aliases.local" ]]; then
|
||
# shellcheck disable=SC1091
|
||
source "$HOME/.aliases.local"
|
||
fi
|
||
|
||
alias wget=wget --hsts-file="$XDG_DATA_HOME/wget-hsts"
|
||
alias svn="svn --config-dir $XDG_CONFIG_HOME/subversion"
|