Compare commits

...
Author SHA1 Message Date
Ken van der Eerden 42a4ccb1b1 feat(laravel): add setting to override the php command (#14146)
Aliases always ran `php artisan`, so users of Laravel Herd (`herd php`)
or a versioned binary (`php8.4`) couldn't use them. The new
`zstyle ':omz:plugins:laravel' php` setting replaces `php` in every
alias; without it the aliases are unchanged.
2026-10-09 07:11:17 -07:00
Minh Vu 2d833b453d fix(copyfile): stop on clipboard failure (#14154) 2026-10-09 07:03:29 -07:00
dhairya d7aca552b3 fix(extract): preserve bzip2 archives and honor extraction destination (#14152) 2026-10-09 07:01:26 -07:00
5 changed files with 137 additions and 41 deletions

No files matched your search

+1 -1
View File
@@ -14,6 +14,6 @@ function copyfile {
return 1 return 1
fi fi
clipcopy $1 clipcopy $1 || return 1
echo ${(%):-"%B$1%b copied to clipboard."} echo ${(%):-"%B$1%b copied to clipboard."}
} }
+74
View File
@@ -0,0 +1,74 @@
#!/usr/bin/env zsh
emulate -LR zsh
source "${1:-${0:A:h:h}/copyfile.plugin.zsh}"
test_dir=$(mktemp -d) || exit 1
trap 'command rm -rf -- "$test_dir"' EXIT
typeset -i clipboard_status=0 failures=0 tests=0
typeset output expected_output
clipcopy() {
print -r -- "$#" "$1" >| "$test_dir/call"
if (( clipboard_status )); then
print -u2 -r -- "clipboard backend failed"
return $clipboard_status
fi
command cat -- "$1" >| "$test_dir/clipboard"
}
check_copyfile() {
local description="$1" expected_status="$2" expected_stdout="$3" expected_stderr="$4"
shift 4
output=$(copyfile "$@" 2> "$test_dir/stderr")
local actual_status=$?
(( tests++ ))
if [[ $actual_status == $expected_status && $output == "$expected_stdout" && $(<"$test_dir/stderr") == "$expected_stderr" ]]; then
print -r -- "PASS: $description"
else
print -u2 -r -- "FAIL: $description"
print -u2 -r -- " status: $actual_status (expected $expected_status)"
print -u2 -r -- " stdout: ${(qqq)output} (expected ${(qqq)expected_stdout})"
print -u2 -r -- " stderr: $(<"$test_dir/stderr") (expected $expected_stderr)"
(( failures++ ))
fi
}
for filename in plain.txt 'file with spaces.txt' 'unicode-ą.txt' empty.txt; do
if [[ $filename == empty.txt ]]; then
: >| "$test_dir/$filename"
else
print -r -- "contents of $filename" >| "$test_dir/$filename"
fi
expected_output=${(%):-"%B$test_dir/$filename%b copied to clipboard."}
clipboard_status=0
check_copyfile "successful copy of $filename" 0 "$expected_output" '' "$test_dir/$filename"
if [[ $(<"$test_dir/call") != "1 $test_dir/$filename" ]] || ! command cmp -s -- "$test_dir/$filename" "$test_dir/clipboard"; then
print -u2 -r -- "FAIL: clipboard received a different argument or contents for $filename"
(( failures++ ))
fi
for clipboard_status in 1 42 127; do
check_copyfile "clipboard exit $clipboard_status for $filename" 1 '' 'clipboard backend failed' "$test_dir/$filename"
done
done
command rm -f -- "$test_dir/call"
check_copyfile 'missing argument' 1 'Usage: copyfile <file>' ''
check_copyfile 'empty argument' 1 'Usage: copyfile <file>' '' ''
check_copyfile 'nonexistent file' 1 "Error: '$test_dir/missing.txt' is not a valid file." '' "$test_dir/missing.txt"
check_copyfile 'directory argument' 1 "Error: '$test_dir' is not a valid file." '' "$test_dir"
if [[ -e "$test_dir/call" ]]; then
print -u2 -r -- 'FAIL: invalid input invoked the clipboard backend'
(( failures++ ))
fi
print -r -- "$tests tests, $failures failures"
(( failures == 0 ))
+3 -1
View File
@@ -101,7 +101,9 @@ EOF
(*.tar.lz4) lz4 -c -d "$full_path" | tar xvf - ;; (*.tar.lz4) lz4 -c -d "$full_path" | tar xvf - ;;
(*.tar.lrz) (( $+commands[lrzuntar] )) && lrzuntar "$full_path" ;; (*.tar.lrz) (( $+commands[lrzuntar] )) && lrzuntar "$full_path" ;;
(*.gz) (( $+commands[pigz] )) && pigz -cdk "$full_path" > "${file:t:r}" || gunzip -ck "$full_path" > "${file:t:r}" ;; (*.gz) (( $+commands[pigz] )) && pigz -cdk "$full_path" > "${file:t:r}" || gunzip -ck "$full_path" > "${file:t:r}" ;;
(*.bz2) (( $+commands[pbzip2] )) && pbzip2 -d "$full_path" || bunzip2 "$full_path" ;; (*.bz2)
(( $+commands[pbzip2] )) && pbzip2 -cd "$full_path" > "${file:t:r}" \
|| bunzip2 -c "$full_path" > "${file:t:r}" ;;
(*.xz) xzcat "$full_path" > "${file:t:r}" ;; (*.xz) xzcat "$full_path" > "${file:t:r}" ;;
(*.lrz) (( $+commands[lrunzip] )) && lrunzip "$full_path" ;; (*.lrz) (( $+commands[lrunzip] )) && lrunzip "$full_path" ;;
(*.lz4) lz4 -d "$full_path" ;; (*.lz4) lz4 -d "$full_path" ;;
+15
View File
@@ -6,6 +6,21 @@ This plugin adds aliases and autocompletion for Laravel [Artisan](https://larave
plugins=(... laravel) plugins=(... laravel)
``` ```
## Settings
By default the aliases run `php artisan`. To use a different PHP command, such as
`herd php` (which runs the PHP version the [Laravel Herd](https://herd.laravel.com) site
is isolated to, instead of Herd's global version) or a specific version like `php8.4`,
set this before Oh My Zsh is sourced:
```zsh
zstyle ':omz:plugins:laravel' php 'herd php'
```
`php` in the aliases below is then replaced with that command.
## Aliases
| Alias | Description | | Alias | Description |
|:-:|:-:| |:-:|:-:|
| `artisan` | `php artisan` | | `artisan` | `php artisan` |
+44 -39
View File
@@ -1,51 +1,56 @@
#!zsh #!zsh
alias artisan='php artisan' # Command used to run artisan, e.g. `herd php` or `php8.4` (default: `php`)
alias bob='php artisan bob::build' zstyle -s ':omz:plugins:laravel' php _omz_laravel_php || _omz_laravel_php=php
alias artisan="$_omz_laravel_php artisan"
alias bob="$_omz_laravel_php artisan bob::build"
# Development # Development
alias pas='php artisan serve' alias pas="$_omz_laravel_php artisan serve"
alias pad='php artisan dev' alias pad="$_omz_laravel_php artisan dev"
alias pats='php artisan test' alias pats="$_omz_laravel_php artisan test"
# Database # Database
alias pam='php artisan migrate' alias pam="$_omz_laravel_php artisan migrate"
alias pamf='php artisan migrate:fresh' alias pamf="$_omz_laravel_php artisan migrate:fresh"
alias pamfs='php artisan migrate:fresh --seed' alias pamfs="$_omz_laravel_php artisan migrate:fresh --seed"
alias pamr='php artisan migrate:rollback' alias pamr="$_omz_laravel_php artisan migrate:rollback"
alias pads='php artisan db:seed' alias pads="$_omz_laravel_php artisan db:seed"
alias padw='php artisan db:wipe' alias padw="$_omz_laravel_php artisan db:wipe"
# Makers # Makers
alias pamm='php artisan make:model' alias pamm="$_omz_laravel_php artisan make:model"
alias pamc='php artisan make:controller' alias pamc="$_omz_laravel_php artisan make:controller"
alias pams='php artisan make:seeder' alias pams="$_omz_laravel_php artisan make:seeder"
alias pamt='php artisan make:test' alias pamt="$_omz_laravel_php artisan make:test"
alias pamfa='php artisan make:factory' alias pamfa="$_omz_laravel_php artisan make:factory"
alias pamp='php artisan make:policy' alias pamp="$_omz_laravel_php artisan make:policy"
alias pame='php artisan make:event' alias pame="$_omz_laravel_php artisan make:event"
alias pamj='php artisan make:job' alias pamj="$_omz_laravel_php artisan make:job"
alias paml='php artisan make:listener' alias paml="$_omz_laravel_php artisan make:listener"
alias pamn='php artisan make:notification' alias pamn="$_omz_laravel_php artisan make:notification"
alias pampp='php artisan make:provider' alias pampp="$_omz_laravel_php artisan make:provider"
alias pamcl='php artisan make:class' alias pamcl="$_omz_laravel_php artisan make:class"
alias pamen='php artisan make:enum' alias pamen="$_omz_laravel_php artisan make:enum"
alias pami='php artisan make:interface' alias pami="$_omz_laravel_php artisan make:interface"
alias pamtr='php artisan make:trait' alias pamtr="$_omz_laravel_php artisan make:trait"
alias pamv='php artisan make:view' alias pamv="$_omz_laravel_php artisan make:view"
alias pammig='php artisan make:migration' alias pammig="$_omz_laravel_php artisan make:migration"
# Clears # Clears
alias pacac='php artisan cache:clear' alias pacac="$_omz_laravel_php artisan cache:clear"
alias pacoc='php artisan config:clear' alias pacoc="$_omz_laravel_php artisan config:clear"
alias pavic='php artisan view:clear' alias pavic="$_omz_laravel_php artisan view:clear"
alias paroc='php artisan route:clear' alias paroc="$_omz_laravel_php artisan route:clear"
alias paopc='php artisan optimize:clear' alias paopc="$_omz_laravel_php artisan optimize:clear"
# queues # queues
alias paqf='php artisan queue:failed' alias paqf="$_omz_laravel_php artisan queue:failed"
alias paqft='php artisan queue:failed-table' alias paqft="$_omz_laravel_php artisan queue:failed-table"
alias paql='php artisan queue:listen' alias paql="$_omz_laravel_php artisan queue:listen"
alias paqr='php artisan queue:retry' alias paqr="$_omz_laravel_php artisan queue:retry"
alias paqt='php artisan queue:table' alias paqt="$_omz_laravel_php artisan queue:table"
alias paqw='php artisan queue:work' alias paqw="$_omz_laravel_php artisan queue:work"
unset _omz_laravel_php