Files
dotfiles/config/alias
Ismo Vuorinen e5d6cb37fd shell: have, path_(append|prepend|remove)
- have: command -v shorthand
- path_append: appends dir to PATH
- path_prepend: prepends dir to PATH
- path_remove: removes dir from PATH
2023-04-14 00:42:08 +03:00

86 lines
2.8 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
# shellcheck source="../scripts/shared.sh"
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 Apples 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