Compare commits

...

4 Commits

16 changed files with 200 additions and 286 deletions

View File

@@ -27,78 +27,9 @@ x-load-configs
# Import ssh keys in keychain
ssh-add -A 2>/dev/null
# Enable the subsequent settings only in interactive sessions
case $- in
*i*) ;;
*) return ;;
esac
# Path to your oh-my-bash installation.
export OSH="$HOME/.local/share/oh-my-bash"
[ -d "$OSH" ] && {
export OSH_THEME="powerline-multiline"
# PowerLine theme config
export POWERLINE_LEFT_PROMPT="cwd scm"
export POWERLINE_RIGHT_PROMPT="python_venv ruby in_vim battery user_info"
# Display red dots whilst waiting for completion.
export COMPLETION_WAITING_DOTS="true"
# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
export DISABLE_UNTRACKED_FILES_DIRTY="true"
# To disable the uses of "sudo" by oh-my-bash, please set "false" to
# this variable. The default behavior for the empty value is "true".
export OMB_USE_SUDO=true
# To enable/disable display of Python virtualenv and condaenv
export OMB_PROMPT_SHOW_PYTHON_VENV=true # enable
# OMB_PROMPT_SHOW_PYTHON_VENV=false # disable
# Which completions would you like to load? (completions can be found in ~/.oh-my-bash/completions/*)
# Custom completions may be added to ~/.oh-my-bash/custom/completions/
# Example format: completions=(ssh git bundler gem pip pip3)
# Add wisely, as too many completions slow down shell startup.
export completions=(
git
composer
ssh
)
# Which aliases would you like to load? (aliases can be found in ~/.oh-my-bash/aliases/*)
# Custom aliases may be added to ~/.oh-my-bash/custom/aliases/
# Example format: aliases=(vagrant composer git-avh)
# Add wisely, as too many aliases slow down shell startup.
export aliases=(
general
)
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-bash/plugins/*)
# Custom plugins may be added to ~/.oh-my-bash/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
export plugins=(
git
bashmarks
)
# Which plugins would you like to conditionally load? (plugins can be found in ~/.oh-my-bash/plugins/*)
# Custom plugins may be added to ~/.oh-my-bash/custom/plugins/
# Example format:
# if [ "$DISPLAY" ] || [ "$SSH" ]; then
# plugins+=(tmux-autoattach)
# fi
source "$OSH/oh-my-bash.sh"
# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
# export EDITOR='vim'
# else
# export EDITOR='mvim'
# fi
x-have rbenv && {
eval "$(rbenv init - bash)"
}
eval "$(starship init bash)"
source $DOTFILES/config/alias

View File

@@ -61,9 +61,9 @@ antigen bundle jreese/zsh-titles
antigen bundle zsh-users/zsh-completions
# these should be available if there's need
have brew && antigen bundle brew
have php && antigen bundle php
have python && antigen bundle MichaelAquilina/zsh-autoswitch-virtualenv
x-have brew && antigen bundle brew
x-have php && antigen bundle php
x-have python && antigen bundle MichaelAquilina/zsh-autoswitch-virtualenv
# nvm is a strange beast
zstyle ':omz:plugins:nvm' autoload yes
@@ -81,14 +81,24 @@ antigen apply
[ -f "${DOTFILES}/config/fzf/fzf.zsh" ] \
&& source "${DOTFILES}/config/fzf/fzf.zsh"
x-have op && {
eval "$(op completion zsh)"
compdef _op op
}
x-have rbenv && {
eval "$(rbenv init - zsh)"
}
# Autoupdate tmux window name
TMUX_WINDOW_NAME_PLUGIN="$DOTFILES/config/tmux/plugins/tmux-window-name/scripts/rename_session_windows.py"
[ -f "$TMUX_WINDOW_NAME_PLUGIN" ] && {
tmux-window-name() {
($TMUX_WINDOW_NAME_PLUGIN &)
tmux-window-name()
{
($TMUX_WINDOW_NAME_PLUGIN &)
}
add-zsh-hook chpwd tmux-window-name
}
# Start starship
eval "$(starship init zsh)"
source $DOTFILES/config/alias

View File

@@ -19,8 +19,8 @@ env:
window:
dynamic_title: true
dimensions:
columns: 130
lines: 40
columns: 200
lines: 100
# Adds this many blank pixels of padding around the window
# Units are physical pixels; this is not DPI aware.
@@ -31,7 +31,7 @@ window:
decorations: buttonless
opacity: 0.97
opacity: 0.98
# When true, bold text is drawn using the bright variant of colors.
draw_bold_text_with_bright_colors: true
@@ -104,9 +104,9 @@ colors:
cyan: '0x7dcfff'
white: '0xc0caf5'
indexed_colors:
- { index: 16, color: '0xff9e64' }
- { index: 17, color: '0xdb4b4b' }
# indexed_colors:
# - { index: 16, color: '0xff9e64' }
# - { index: 17, color: '0xdb4b4b' }
key_bindings:
- { key: V, mods: Command, action: Paste }

View File

@@ -1,68 +1,15 @@
#!/usr/bin/env bash
# shellcheck source="../scripts/shared.sh"
# shellcheck disable=1091,2139
DOTFILES="$HOME/.dotfiles"
# Get installed php versions from brew and setup aliases
function x-set-php-aliases
{
x-have brew && {
local php_versions=()
while IFS="" read -r line; do php_versions+=("$line"); done < <(bkt -- 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
# Be nice
alias please="sudo "
# Color the grep output
alias grep='grep --color'
alias grep="grep --color"
x-have eza && {
alias ls='eza -h -s=type --git --icons --group-directories-first'
alias ls="eza -h -s=type --git --icons --group-directories-first"
}
# Easier navigation: .., ..., ....
@@ -138,22 +85,35 @@ alias zedit='$EDITOR ~/.dotfiles'
alias irssi="irssi --config=$XDG_CONFIG_HOME/irssi/config --home=$XDG_CONFIG_HOME/irssi"
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"
if [[ $(uname) == 'Darwin' ]]; then
# 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"
x-set-php-aliases
fi
# Alacritty preexec hook to update dynamic title
function preexec()
preexec()
{
print -Pn "\e]0;$1%~\a"
}
# Update dotfiles
function dfu()
dfu()
{
(
cd "$DOTFILES" && git pull --ff-only && ./install -q
@@ -161,7 +121,7 @@ function dfu()
}
# Weather in Tampere, or other city
function weather()
weather()
{
# https://github.com/chubin/wttr.in#usage
local city="${1:-Tampere}"
@@ -169,19 +129,19 @@ function weather()
}
# Docker
function ssh-docker()
ssh-docker()
{
docker exec -it "$@" bash
}
# All the dig info
function digga()
digga()
{
dig +nocmd "$1" any +multiline +noall +answer
}
# Rector project to php version 8.2 by default.
function rector()
rector()
{
local php="${1:-82}"
docker run -v "$(pwd)":/project rector/rector:latest process \
@@ -191,7 +151,7 @@ function rector()
}
# Commit everything
function commit()
commit()
{
commitMessage="$*"
@@ -203,7 +163,7 @@ function commit()
eval "git commit -a -m '${commitMessage}'"
}
function scheduler()
scheduler()
{
while :; do
php artisan schedule:run

View File

@@ -2,11 +2,6 @@
# shellcheck shell=bash
# vim: filetype=zsh
# if cargo directory exists, add it to path
if [[ -d "$HOME/.local/share/cargo/bin" ]]; then
export PATH="$HOME/.local/share/cargo/bin:$PATH"
fi
# Cache commands using bkt if installed
if command -v bkt >&/dev/null; then
bkt()
@@ -26,7 +21,7 @@ fi
# shorthand for checking if the system has the bin in path,
# this version does not use caching
# usage: have_command php && php -v
function have_command
have_command()
{
command -v "$1" >&/dev/null
}
@@ -34,21 +29,21 @@ function have_command
# shorthand for checking if the system has the bin in path,
# this version uses caching
# usage: have php && php -v
function have
have()
{
bkt -- which "$1" >&/dev/null
}
function brew_installed
brew_installed()
{
bkt -- brew list
}
# shorthand for checking if brew package is installed
# usage: have_brew php && php -v
function have_brew
have_brew()
{
! have brew && return 125
! x-have brew && return 125
if bkt -- brew list "$1" &> /dev/null; then
return 0

View File

@@ -59,12 +59,6 @@ x-have node && {
# op (1Password cli) is present
export OP_CACHE="$XDG_STATE_HOME/1password"
x-have op && {
[ "$DOTFILES_CURRENT_SHELL" = "zsh" ] && {
eval "$(op completion zsh)"
compdef _op op
}
}
# Python
#
@@ -87,10 +81,6 @@ export BUNDLE_USER_PLUGIN="$XDG_DATA_HOME"/bundle
export RBENV_ROOT="$XDG_STATE_HOME/rbenv"
x-dc "$RBENV_ROOT"
x-have gem && export PATH="${GEM_HOME}/bin:$PATH"
x-have rbenv && {
[ "$DOTFILES_CURRENT_SHELL" = "zsh" ] && eval "$(rbenv init - zsh)"
[ "$DOTFILES_CURRENT_SHELL" = "bash" ] && eval "$(rbenv init - bash)"
}
# Rust / cargo
export RUSTUP_HOME="$XDG_DATA_HOME/rustup"

View File

@@ -1,7 +1,7 @@
# lakka exports
## LUA
have luarocks && $(luarocks path --bin)
x-have luarocks && $(luarocks path --bin)
export PATH="$HOME/.local/go/bin:$PATH"
@@ -17,4 +17,3 @@ export RVM_PATH="$HOME/.rvm"
export PATH="$RVM_PATH/bin:$PATH"
# shellcheck source=$HOME/.rvm/scripts/rvm
[[ -s "$RVM_PATH/scripts/rvm" ]] && source "$RVM_PATH/scripts/rvm" # Load RVM into a shell session *as a function*

View File

@@ -3,21 +3,6 @@
# shellcheck disable=1091,2046
# vim: filetype=bash
export DOTFILES="$HOME/.dotfiles"
# Explicitly set XDG folders
# https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
export XDG_CONFIG_HOME="$HOME/.config"
export XDG_DATA_HOME="$HOME/.local/share"
export XDG_STATE_HOME="$HOME/.local/state"
# custom variables
export XDG_BIN_HOME="$HOME/.local/bin"
export XDG_CACHE_HOME="$HOME/.cache"
export XDG_RUNTIME_DIR="$HOME/.local/run"
export LC_ALL=fi_FI.UTF-8
# Bash completion file location
export BASH_COMPLETION_USER_FILE="${XDG_CONFIG_HOME}/bash-completion/bash_completion"
@@ -38,13 +23,13 @@ export HISTORY_IGNORE="(ls|cd|cd -|pwd|exit|date|* --help)"
export LESSHISTFILE="$XDG_STATE_HOME"/less/history
# Highlight section titles in manual pages
export LESS_TERMCAP_md="$ORANGE"
# export LESS_TERMCAP_md="$ORANGE"
# zsh autoloaded terminfo
export TERMINFO="$XDG_DATA_HOME"/terminfo
export TERMINFO_DIRS="$XDG_DATA_HOME"/terminfo:/usr/share/terminfo
export TERMINFO="${XDG_DATA_HOME}/terminfo"
export TERMINFO_DIRS="${XDG_DATA_HOME}/terminfo":/usr/share/terminfo
# Dont clear the screen after quitting a manual page
# Don't clear the screen after quitting a manual page
export MANPAGER="less -X"
# Always enable colored `grep` output

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env bash
#
# shell functions
set -euo pipefail

View File

@@ -12,9 +12,14 @@ require("lazy").setup({
{
"LazyVim/LazyVim",
import = "lazyvim.plugins",
opts = {
colorscheme = "tokyonight",
},
},
{
"folke/tokyonight.nvim",
lazy = false,
priority = 1000,
opts = {
style = "night",
transparent = true,
@@ -23,6 +28,8 @@ require("lazy").setup({
sidebars = "transparent",
floats = "transparent",
},
dim_inactive = true,
lualine_bold = true,
},
},
{ import = "plugins" },

View File

@@ -15,6 +15,10 @@ return {
},
},
keys = {
{
"<leader>ba",
desc = "Annotations / Comments",
},
{
"<leader>baa",
function()
@@ -68,10 +72,12 @@ return {
-- Clarify and beautify your comments using boxes and lines.
-- https://github.com/LudoPinelli/comment-box.nvim
{ "LudoPinelli/comment-box.nvim", opts = {} },
-- Mason
-- https://github.com/williamboman/mason.nvim
{
"williamboman/mason.nvim",
opts = {
ensure_installed = {
opts = function(_, opts)
vim.list_extend(opts.ensure_installed, {
"actionlint",
"ansible-language-server",
"ansible-lint",
@@ -86,18 +92,24 @@ return {
"dockerfile-language-server",
"editorconfig-checker",
"fixjson",
"flake8",
"html-lsp",
"jq",
"jsonlint",
"luacheck",
"nginx-language-server",
"php-cs-fixer",
"phpcs",
"phpmd",
"semgrep",
"sonarlint-language-server",
"stylua",
"shellcheck",
"shfmt",
"flake8",
},
},
"sonarlint-language-server",
"stylelint",
"stylua",
"yamllint",
})
end,
},
-- Vim plugin for automatic time tracking and metrics generated from your programming activity.
-- https://github.com/wakatime/vim-wakatime

View File

@@ -1,24 +0,0 @@
return {
{
"williamboman/mason.nvim",
opts = {
ensure_installed = {
"actionlint",
"ansible-lint",
"bash-language-server",
"commitlint",
"flake8",
"intelephense",
"jsonlint",
"luacheck",
"phpcs",
"phpmd",
"shellcheck",
"shfmt",
"stylelint",
"stylua",
"yamllint",
},
},
},
}

View File

@@ -92,9 +92,6 @@ set-window-option -g mode-keys vi
# │ Theme │
# ╰──────────────────────────────────────────────────────────╯
# Set theme to tokyonight
# source-file ~/.dotfiles/config/tmux/tokyonight_storm.tmux
# Make sure status sides are long enough and centered is in the middle
set -g status-left-length "30"
set -g status-right-length "30"
@@ -143,9 +140,6 @@ set -g @mode_indicator_copy_mode_style 'bg=default,fg=yellow'
set -g @mode_indicator_empty_mode_style 'bg=default,fg=#7aa2f7'
set -g @mode_indicator_sync_mode_style 'bg=default,fg=red'
# Modified from tokyonight_storm to include tmux_mode_indicator
# set -g status-right "#[fg=#1f2335,bg=#1f2335,nobold,nounderscore,noitalics]#[fg=#7aa2f7,bg=#1f2335] #{prefix_highlight} #[fg=#3b4261,bg=#1f2335,nobold,nounderscore,noitalics]#[fg=#7aa2f7,bg=#3b4261] %Y-%m-%d  %H:%M #[fg=#7aa2f7,bg=#3b4261,nobold,nounderscore,noitalics]#[fg=#1d202f,bg=#7aa2f7,bold] #h #{tmux_mode_indicator}"
# ╭──────────────────────────────────────────────────────────╮
# │ Plugins │
# ╰──────────────────────────────────────────────────────────╯

View File

@@ -1,38 +0,0 @@
#!/usr/bin/env bash
# TokyoNight colors for Tmux
set -g mode-style "fg=#7aa2f7,bg=#3b4261"
set -g message-style "fg=#7aa2f7,bg=#3b4261"
set -g message-command-style "fg=#7aa2f7,bg=#3b4261"
set -g pane-border-style "fg=#3b4261"
set -g pane-active-border-style "fg=#7aa2f7"
set -g status "on"
set -g status-justify "left"
set -g status-style "fg=#7aa2f7,bg=#1f2335"
set -g status-left-length "100"
set -g status-right-length "100"
set -g status-left-style NONE
set -g status-right-style NONE
set -g status-left "#[fg=#1d202f,bg=#7aa2f7,bold] #S #[fg=#7aa2f7,bg=#1f2335,nobold,nounderscore,noitalics]"
set -g status-right "#[fg=#1f2335,bg=#1f2335,nobold,nounderscore,noitalics]#[fg=#7aa2f7,bg=#1f2335] #{prefix_highlight} #[fg=#3b4261,bg=#1f2335,nobold,nounderscore,noitalics]#[fg=#7aa2f7,bg=#3b4261] %Y-%m-%d  %I:%M %p #[fg=#7aa2f7,bg=#3b4261,nobold,nounderscore,noitalics]#[fg=#1d202f,bg=#7aa2f7,bold] #h "
if-shell '[ "$(tmux show-option -gqv "clock-mode-style")" == "24" ]' {
set -g status-right "#[fg=#1f2335,bg=#1f2335,nobold,nounderscore,noitalics]#[fg=#7aa2f7,bg=#1f2335] #{prefix_highlight} #[fg=#3b4261,bg=#1f2335,nobold,nounderscore,noitalics]#[fg=#7aa2f7,bg=#3b4261] %Y-%m-%d  %H:%M #[fg=#7aa2f7,bg=#3b4261,nobold,nounderscore,noitalics]#[fg=#1d202f,bg=#7aa2f7,bold] #h "
}
setw -g window-status-activity-style "underscore,fg=#a9b1d6,bg=#1f2335"
setw -g window-status-separator ""
setw -g window-status-style "NONE,fg=#a9b1d6,bg=#1f2335"
setw -g window-status-format "#[fg=#1f2335,bg=#1f2335,nobold,nounderscore,noitalics]#[default] #I  #W #F #[fg=#1f2335,bg=#1f2335,nobold,nounderscore,noitalics]"
setw -g window-status-current-format "#[fg=#1f2335,bg=#3b4261,nobold,nounderscore,noitalics]#[fg=#7aa2f7,bg=#3b4261,bold] #I  #W #F #[fg=#3b4261,bg=#1f2335,nobold,nounderscore,noitalics]"
# tmux-plugins/tmux-prefix-highlight support
set -g @prefix_highlight_output_prefix "#[fg=#e0af68]#[bg=#1f2335]#[fg=#1f2335]#[bg=#e0af68]"
set -g @prefix_highlight_output_suffix ""

View File

@@ -2,35 +2,76 @@
# Load our configuration files
# Copyright (c) 2023 Ismo Vuorinen. All Rights Reserved.
# Set verbosity with VERBOSE=1 x-load-configs
: "${VERBOSE:0}"
set -euo pipefail
DOTFILES="$HOME/.dotfiles"
# Set verbosity with VERBOSE=1 x-load-configs
VERBOSE="${VERBOSE:=0}"
[ "$VERBOSE" = "1" ] && {
set -x
}
CONFIG_PATH="$DOTFILES/config"
# Load the shell dotfiles, and then some:
HOST="$(hostname -s)"
[ "$VERBOSE" = "1" ] && {
echo "x-load-config-fn: VERBOSE=1"
echo "x-load-config-fn: HOST: $HOST"
echo "x-load-configs: VERBOSE=1"
echo "x-load-configs: HOST: $HOST"
}
for FILE in $CONFIG_PATH/{exports,alias,functions}; do
FILENAME="$FILE"
configFile()
{
echo "$CONFIG_PATH/$1"
}
configMsg()
{
printf 'x-load-configs: %s %s\n' "$1" "$2"
}
loadConfigFiles()
{
CONFIG_FILE=$1
SECRET_FILE=$CONFIG_FILE-secret
HOST_FILE=$CONFIG_FILE-$HOST
SECRET_HOST=$HOST_FILE-secret
[ "$VERBOSE" = "1" ] && configMsg "?" "$CONFIG_FILE"
# global (exports|alias|functions) FILENAME for all hosts
# shellcheck source=../config/exports
[ -r "$FILENAME" ] && source "$FILENAME" \
&& [ "$VERBOSE" = "1" ] && echo "x-load-config-fn: $FILENAME"
[ -r "$CONFIG_FILE" ] && {
source "$CONFIG_FILE" && [ "$VERBOSE" = "1" ] && configMsg "Found" "$CONFIG_FILE"
}
# global secret FILENAME, git ignored
# shellcheck source=../config/exports-secret
[ -r "$FILENAME-secret" ] && source "$FILENAME-secret" \
&& [ "$VERBOSE" = "1" ] && echo "x-load-config-fn: $FILENAME-secret"
[ "$VERBOSE" = "1" ] && configMsg "?" "$SECRET_FILE"
[ -r "$SECRET_FILE" ] && {
source "$SECRET_FILE" && [ "$VERBOSE" = "1" ] && configMsg "Found" "$SECRET_FILE"
}
# host specific (exports|alias|functions) FILENAME
# shellcheck source=../config/exports
[ -r "$FILENAME-$HOST" ] && source "$FILENAME-$HOST" \
&& [ "$VERBOSE" = "1" ] && echo "x-load-config-fn: $FILENAME-$HOST"
[ "$VERBOSE" = "1" ] && configMsg "?" "$HOST_FILE"
[ -r "$HOST_FILE" ] && {
source "$HOST_FILE" && [ "$VERBOSE" = "1" ] && configMsg "Found" "$HOST_FILE"
}
# host specific (exports|alias|functions) FILENAME, git ignored
# shellcheck source=../config/exports
[ -r "$FILENAME-$HOST-secret" ] && source "$FILENAME-$HOST-secret" \
&& [ "$VERBOSE" = "1" ] && echo "x-load-config-fn: $FILENAME-$HOST-secret"
done
[ "$VERBOSE" = "1" ] && configMsg "?" "$SECRET_HOST"
[ -r "$SECRET_HOST" ] && {
source "$SECRET_HOST" \
&& [ "$VERBOSE" = "1" ] && configMsg "Found" "$SECRET_HOST"
}
}
FILE_EXPORTS=$(configFile "exports")
FILE_FUNCTIONS=$(configFile "functions")
FILE_ALIAS=$(configFile "alias")
loadConfigFiles "$FILE_EXPORTS"
loadConfigFiles "$FILE_FUNCTIONS"
loadConfigFiles "$FILE_ALIAS"
exit 0

50
local/bin/x-set-php-aliases Executable file
View File

@@ -0,0 +1,50 @@
#!/usr/bin/env bash
# Check which php versions are installed with brew, and create aliases for each installation.
# Copyright (c) 2023 Ismo Vuorinen. All Rights Reserved.
set -euo pipefail
# Set verbosity with VERBOSE=1 x-load-configs
VERBOSE="${VERBOSE:=0}"
[ "$VERBOSE" = "2" ] && {
set -x
}
! x-have brew && {
exit 0
}
# Get installed php versions from brew and setup aliases
php_versions=()
while IFS="" read -r line; do php_versions+=("$line"); done < <(bkt -- brew list | grep '^php')
php_error_reporting='-d error_reporting=22527'
for version in "${php_versions[@]}"; do
[ "$VERBOSE" = "1" ] && echo "Setting aliases for $version"
# drop the dot from version (8.0 -> 80)
php_abbr="${version//\./}"
# replace "php@" with "p" so "php@80" becomes "p80"
php_alias="${php_abbr//php@/p}"
# Fetch the exec path once
php_exec="$HOMEBREW_PREFIX/opt/$version/bin/php"
[ -f "$php_exec" ] && {
[ "$VERBOSE" = "1" ] && echo "-> php_exec $php_exec"
# 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