mirror of
https://github.com/oh-my-fish/oh-my-fish.git
synced 2025-02-15 09:34:04 +08:00
![Pablo Santiago Blum de Aguiar](/assets/img/avatar_default.png)
Since Fish Shell 3.0 [1], `?` as a glob is deprecated. Fixes #644 1. https://github.com/fish-shell/fish-shell/releases/tag/3.0.0
52 lines
1.1 KiB
Fish
52 lines
1.1 KiB
Fish
function omf -d "Oh My Fish"
|
|
# Parse any options before the command name.
|
|
while set -q argv[1]
|
|
switch $argv[1]
|
|
case '-h' '--help'
|
|
set command help
|
|
|
|
case '-v' '--version'
|
|
set command version
|
|
|
|
case '-*'
|
|
echo (omf::err)"Unknown option: $argv[1]"(omf::off) >&2
|
|
return $OMF_UNKNOWN_OPT
|
|
|
|
case '*'
|
|
break
|
|
end
|
|
|
|
set -e argv[1]
|
|
end
|
|
|
|
# Also extract a help flag from the last argument.
|
|
switch "$argv[-1]"
|
|
case '-h' '--help'
|
|
set command help
|
|
set -e argv[-1]
|
|
end
|
|
|
|
# Extract the command name from the remaining arguments.
|
|
if not set -q command
|
|
if set -q argv[1]
|
|
set command $argv[1]
|
|
set -e argv[1]
|
|
else
|
|
set command help
|
|
end
|
|
end
|
|
|
|
# Lookup the function for the requested command.
|
|
if not set command_name (omf.command $command)
|
|
echo (omf::err)"Unknown command: $command"(omf::off) >&2
|
|
return $OMF_UNKNOWN_OPT
|
|
end
|
|
|
|
# Execute the command.
|
|
echo "function __omf_last_command --no-scope-shadowing
|
|
omf.cli.$command_name \$argv
|
|
end" | source
|
|
|
|
__omf_last_command $argv
|
|
end
|