mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
Meta: Add basic Zsh completions for serenity.sh
This patch adds a basic Zsh completion script for the commands and targets provided by Meta/serenity.sh. There's some room for improvement here, e.g. we could provide completion for available CMake targets - currently completion stops after serenity.sh <command> <target>. You can enable it by adding this to your .zshrc before completions are loaded: fpath=($SERENITY_SOURCE_DIR/Meta/ShellCompletions/zsh $fpath)
This commit is contained in:
parent
a5625686cb
commit
696f23d7a0
Notes:
sideshowbarker
2024-07-18 19:15:07 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/696f23d7a0f Pull-request: https://github.com/SerenityOS/serenity/pull/6545
2 changed files with 64 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -4,6 +4,7 @@
|
||||||
!Makefile
|
!Makefile
|
||||||
!LICENSE
|
!LICENSE
|
||||||
!Base/**
|
!Base/**
|
||||||
|
!Meta/ShellCompletions/**
|
||||||
|
|
||||||
*.o
|
*.o
|
||||||
*.ao
|
*.ao
|
||||||
|
|
63
Meta/ShellCompletions/zsh/_serenity
Normal file
63
Meta/ShellCompletions/zsh/_serenity
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
#compdef serenity serenity.sh
|
||||||
|
|
||||||
|
_serenity() {
|
||||||
|
local args
|
||||||
|
args=(
|
||||||
|
'1:command:->commands'
|
||||||
|
'2:target:->targets'
|
||||||
|
'*:: :->args'
|
||||||
|
)
|
||||||
|
|
||||||
|
local commands
|
||||||
|
commands=(
|
||||||
|
'build'
|
||||||
|
'install'
|
||||||
|
'image'
|
||||||
|
'run'
|
||||||
|
'gdb'
|
||||||
|
'test'
|
||||||
|
'delete'
|
||||||
|
'recreate'
|
||||||
|
'rebuild'
|
||||||
|
'kaddr2line'
|
||||||
|
'addr2line'
|
||||||
|
'rebuild-toolchain'
|
||||||
|
'rebuild-world'
|
||||||
|
)
|
||||||
|
|
||||||
|
local targets
|
||||||
|
targets=(
|
||||||
|
'i686:Target i686 (default)'
|
||||||
|
'x86_64:Target x86_64'
|
||||||
|
'lagom:Target host machine'
|
||||||
|
)
|
||||||
|
|
||||||
|
_arguments -C -S "$args[@]"
|
||||||
|
|
||||||
|
local command
|
||||||
|
command="$line[1]"
|
||||||
|
|
||||||
|
local target
|
||||||
|
target="$line[2]"
|
||||||
|
|
||||||
|
case "$state" in
|
||||||
|
commands)
|
||||||
|
_describe 'command' commands
|
||||||
|
;;
|
||||||
|
targets)
|
||||||
|
case "$command" in
|
||||||
|
install|image|kaddr2line|rebuild-toolchain|rebuild-world)
|
||||||
|
# lagom target is not supported for these, remove from targets
|
||||||
|
targets[$targets[(i)lagom]]=()
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
_describe 'target' targets
|
||||||
|
;;
|
||||||
|
args)
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
_serenity
|
Loading…
Reference in a new issue